acer

17333 Reputation

29 Badges

14 years, 119 days

On google groups. (comp.soft-sys.math.maple and sci.math.symbolic)

On stackoverflow.

On math.stackexchange.com.

MaplePrimes Activity


These are answers submitted by acer

plots:-animate(plot, [[cos(x+2*a), cos(x-2*a)], x = 0 .. 4*Pi],
               a = 1 .. 10, frames=117);

You have used the syntax for function application, rather than multiplication.

You are missing multiplication symbols between your brackets, if your code was entered as (plaintext) 1D Maple Notation.

Even in 2D Input mode you'd still need either explicit multiplication symbols or spaces between the brackets to denote multiplication implicitly.

S := Sum(1/i(i + 1)(i + 2)(i + 3), i = 1 .. infinity);
evalf(S);

Sum(1/((i(i+1))(i+2))(i+3), i = 1 .. infinity)

Float(-infinity)

S2 := Sum(1/(i*(i + 1)*(i + 2)*(i + 3)), i = 1 .. infinity);
evalf(S2);

Sum(1/(i*(i+1)*(i+2)*(i+3)), i = 1 .. infinity)

0.5555555556e-1

sum(1/(i*(i + 1)*(i + 2)*(i + 3)), i = 1 .. infinity);

1/18

evalf(%);

0.5555555556e-1

restart

S := Sum(1/((i(i+1))(i+2))(i+3), i = 1 .. infinity); evalf(S)

Sum(1/((i(i+1))(i+2))(i+3), i = 1 .. infinity)

Float(-infinity)

restart

S := Sum(1/(i*(i+1)*(i+2)*(i+3)), i = 1 .. infinity); evalf(S)

Sum(1/(i*(i+1)*(i+2)*(i+3)), i = 1 .. infinity)

0.5555555556e-1

``

Download syntaxmult.mw

Perhaps it will help you a little to go through it a step at a time.

Notice that I'm only using the formula on the right hand side of each equation returned by solve. (There are other ways to accomplish the goal, but this might make it a little more clear.)

restart;

g := z -> (a + b*z + c*z^2)/(d + e*z + f*z^2):

eqn := y = g(z);

y = (c*z^2+b*z+a)/(f*z^2+e*z+d)

sols := solve({eqn}, {z});

{z = (1/2)*(e*y-b+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2))/(-f*y+c)}, {z = -(1/2)*(-e*y+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2)+b)/(-f*y+c)}

expr1 := eval(z, sols[1]);

(1/2)*(e*y-b+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2))/(-f*y+c)

f1 := unapply(expr1, y);

proc (y) options operator, arrow; (1/2)*(e*y-b+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2))/(-f*y+c) end proc

simplify( (g@f1)(y) );

y

expr2 := eval(z, sols[2]);

-(1/2)*(-e*y+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2)+b)/(-f*y+c)

f2 := unapply(expr2, y);

proc (y) options operator, arrow; -(1/2)*(-e*y+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2)+b)/(-f*y+c) end proc

simplify( (g@f2)(y) );

y

 

Download tima_inv.mw

This question is vague and underspecified, because it only gives two examples, which both happen to have 1 nonzero digit on the left of the decimal point in the input as well as the output under default display.

So about the only way that I can make sense of the request is that the OP wants 1 leading nonzero digits to the left of the decimal place, and no trailing zeros after the right-most nonzero digit.

restart;

H:=proc(x::float) local s;
  uses StringTools;
  s:=CharacterMap("0"," ",sprintf("%ld",abs(op(1,x))));
  s:=CharacterMap(" ","0",TrimRight(s));
  `if`(s="",0.,signum(op(1,x))*parse(cat(s[1],".",s[2..])));
end proc:

H( 2.55 *10^(-90) );

2.55

H( 2.22 *10^(-87) );

2.22

H( -0.0000045600060000 *10^(-87) );

-4.560006

H( 617.123789 );

6.17123789

 

Download leaddig.mw

The RiemannSum command accepts an option partition which can be used to specify the partition values as a list.

For example,

restart;

f := x^2:

P := [-1, -1/4, 1/4, 3/4, 1]:

Student:-Calculus1:-RiemannSum(f, x=-1..1,
                               method=lower, partition=P);

               0.2187500000

For this example it's easy enough to check that result,

add(minimize(f,x=P[i]..P[i+1])*(P[i+1]-P[i]), i=1..nops(P)-1);

                  7 
                  --
                  32
evalf(%);

               0.2187500000

Applying a command such as simplify may have more significant effects on the elements, so is not a really good solution.

Here are three or four reasonable ways. The 1-level evaluation might have least effects in general, but is not the briefest to type.

restart

v := `<,>`(v1, v2)

Vector[column](%id = 18446883833686440406)

v1 := 3.2; v2 := b

`~`[eval](v)

Vector[column](%id = 18446883833686435710)

`~`[eval](v, 1)

Vector[column](%id = 18446883833686437150)

rtable_eval(v)

Vector[column](%id = 18446883833686430534)

copy(v)

Vector[column](%id = 18446883833686432094)

``

Download Vector_Display_Problem_ac.mw

This code allows you to produce 2D contour plots with labels inlined.

This code allows you to produce legends easily and flexibly on 2D contour plots.

These are easily found using the Search facility of this site. Did you not try that?

 

Your claim that they have the same dimensions is false. The number of dimensions is different, which is what the error message states.

The following elementwise multiplication is done in few keystrokes:

M := Matrix([[2],[3],[4]]);

Vector(3, {(1) = 2, (2) = 3, (3) = 4})

VC := Vector([-1,1,5]);

Vector(3, {(1) = -1, (2) = 1, (3) = 5})

M *~ <VC>;

Vector(3, {(1) = -2, (2) = 3, (3) = 20})

 

Download mvelem.mw

The result from the above is a Matrix.

One might ask, should the result be a Vector or a Matrix? That is not clear, which relates to why it doesn't happen unless syntax is used to make it unambiguous.

The facility provides %, %%, and %%% for the last, second last, and third last results respectively.

There is a Help page for it, with the Topic ditto .

That Help page should also be available by searching for % in the Help system.

In the GUI you can also use Equation Labels to refer to previous output (if you like that sort of thing).

You can inform GlobalSolve which names are the variables (since it lacks a mechanism for recognizing and excluding a, the name of the dummy variable of integration).

restart;
with(GlobalOptimization):

GlobalSolve(Int(a*x-2,a=0..2), x=0..2,
            method=diffevol, variables=[x]);
                                                     -7
        [-3.99999997615814, [x = 0.119209289550781 10  ]]

Alternatively you could utilize the operator form calling sequence,

restart;
with(GlobalOptimization):                                                                    

GlobalSolve(proc(x) local a; Int(a*x-2,a=0..2); end proc,
            0..2, method=diffevol);

           [-3.99999997615814, [                    -7]]
                                [0.119209289550781 10  ]

Using Maple 2019.1, below I use the stylesheet option to the DrawGraph command.

See also the Help page for Topic GraphDrawingOptions for more description.

restart;

with(GraphTheory):

G := Graph({[[1,2], 1], [[2,3], 2], [[3,4], 3], [[4,5], 4], [[5,1], 5]}):

DrawGraph(G);

DrawGraph(G, stylesheet=[vertexpadding=20]);

DrawGraph(G, stylesheet=[vertexpadding=20,
                         vertexfontsize=20]);

 

Download graphvertexsize.mw

My results agree approximately with that of mmcdara.

If you do symbolic integration then the symbolic result require high (Digits possibly as high as 150, but I didn't find a tight bound) working precision in order to avoid numeric roundoff error.

But if you set it up with purely numeric integration then a siimilar result can be obtained with much lower working precision in just a few seconds.

XZ_for_MPac.mw

The Statistics:-BoxPlot command already offers options to control the offset and width of the box. I deliberately do a translation (transformation) instead of using those. And I stick in a point at the origin, as one easy way to force the axes to be displayed at the origin.

(There are several other ways to get all these effects. It's a matter of taste, mostly. They all require a little bookkeeping or fiddling, IMO. How much fiddling depends on whether you want to be able to get the a-axis above just as easily, or whether you also want easy control over the box width, etc. Again, note that your code forced the size option, which I kept.)

I didn't find your description and question very clear, so I may not have guessed correctly about what details you're after.

restart;

BoxP:=proc(xd::list, {yshift::realcons:=0})
        local P,s;
        uses Statistics:
        s := evalf(yshift);
        if s<0 then s:=s-1; end if;
        P:=BoxPlot(xd,':-deciles'=false,':-orientation'=':-horizontal');
        P:=plottools:-transform((x,y)->[x,y+s])(P);
        return plots:-display(P,plot([[0,0]]),':-size'=[400,200],
                              ':-axis'[2]=[':-color'="white",':-tickmarks'=[]],
                              ':-axes'=':-normal');
    end proc:

f:=rand(1..100):
L:=[seq(f(),i=1..100)]:

 

Here's the basic idea.

 

\BoxP(L, yshift=0.5);

 

If you shift farther away, with the fixed `size` and normal `axes,
then you get more vertical scaling (compression).

 

BoxP(L, yshift=1.0);

 

If you want the x-axis on top (...there are other ways to get this).

 

BoxP(L, yshift=-0.5);

 

Again, you can shift farther away.

 

BoxP(L, yshift=-1.0);

 

Download boxp_idea.mw

Once again, let me point out that you can control all this and more by using the offset, width, and distance options of the BoxPlot command. But even then you may prefer to omit the size option, or allow an unconstrained scaling, or still need to include a fixed reference such as the origin point. It's a bit of a trade-off: easy control for just your particular case, or slightly more awkward control for a wider set of cases.

 

Here are some ideas that might help you get started with the surface defined by your formula.

I've constructed an explicit solution for m__yy as a function of m__zz and n. This is used to plot a surface quickly, that looks smoother and responds better in the GUI than a 3D implicit plot. And you may find use for the explict formula.

I've laid some 3D contours lines on that surface. I've also shown how the equivalent 2D contour plots can be obtained. Let me know if you want a 2D version more like a fully-shaded densityplot (or both, overlaid).

(The original can also be solved for m__zz explicitly, but getting a sharp and full plot boundary is a little more effort.)

I don't know how you are currently dealing with your irregularly spaced 3D data. Are you generating an interpolating procedure? Please post the actual data. 

restart;

a := 45/100;
#a := 2/3:

9/20

UC := proc(n, m__yy, m__zz)
  piecewise(1/5 < n, m__yy^2/min(1,(1-n)/(1-1/2*aa))^2
                     +(m__zz/piecewise(n <= aa, 1, 1-(n-aa)^2/(1-aa)^2))^(5*n),
                     m__yy^2/min(1,(1-n)/(1-1/2*aa))^2
                     +m__zz/piecewise(n <= aa, 1, 1-(n-aa)^2/(1-aa)^2));
end proc:

eval(UC(n, m__yy, m__zz), aa = a):

KK := simplify(%);

KK := piecewise(n <= 1/5, m__yy^2+m__zz, n <= 9/40, m__yy^2+m__zz^(5*n), n <= 9/20, 961*m__yy^2/(1600*(n-1)^2)+m__zz^(5*n), 9/20 < n, 961*m__yy^2/(1600*(n-1)^2)+(-121*m__zz/(400*n^2-360*n-40))^(5*n))

RR := solve({KK = 1, 0 < m__zz, 0 < n, m__zz < 1, n < 1}, {m__yy}):
RRR := (simplify(RR) assuming (0 < n, n < 1, 0 < m__zz, m__zz < 1)):
RRRR := subsindets(RRR, list, uu -> eval(m__yy, uu[1]));

RRRR := piecewise(n <= 1/5, sqrt(1-m__zz), n <= 9/40, sqrt(1-m__zz^(5*n)), n <= 9/20, -40*sqrt(1-m__zz^(5*n))*(n-1)*(1/31), 9/20 < n, -40*sqrt(1-m__zz^(5*n)*(-25937424601/(102400000*(10*n^2-9*n-1)^5))^n)*(n-1)*(1/31))

FF := [solve({RRRR = 0}, {m__zz})];
FFF := (eval(m__zz, simplify(%[1])[1]) assuming (a < n));
evalf(eval(FFF, n = 0.7));

FF := [piecewise(n <= 9/20, [{m__zz = 1}], 9/20 < n, [{m__zz = 40/(121*(-1/(10*n^2-9*n-1)^5)^(1/5))}])]

(40/121)/(-1/(10*n^2-9*n-1)^5)^(1/5)

.7933884298

P1s := plot3d([RRRR, m__zz, n],
               m__zz = 0 .. piecewise(n <= a, 1, FFF) - 0.1*10^(-8),
               n = 0 .. 1, labels = [m__yy, m__zz, n],
               view = [0 .. 1, 0 .. 1, 0 .. 1], style = surface):
P1s;

P1c := plot3d([RRRR, m__zz, n],
              m__zz = 0 .. piecewise(n <= a, 1, FFF) - 0.1*10^(-8),
              n = 0 .. 1, labels = [m__yy, m__zz, n],
              view = [0 .. 1, 0 .. 1, 0 .. 1],
              colorscheme = ["zgradient", ["LightGreen", "Blue"]],
              style = contour, contours = [1/5, a/2, a, 0.7], thickness = 3):
P1c;

P2c2D := plots:-contourplot(RRRR, m__zz = 0 .. piecewise(n <= a, 1, FFF) - 0.1*10^(-8),
                            n = 0 .. 1, labels = [m__zz, n], view = [0 .. 1, 0 .. 1],
                            thickness = 3, contours = [0.2, 0.4, 0.6, 0.9],
                            coloring = [red, yellow]):
P2c2D;

P2c := plots:-display(plottools:-transform((a, b, c) -> [eval(RRRR, [n = b, m__zz = a]), a, b])(P2c2D)):

plots:-display(P1s, P1c, P2c);

P1c2D := plots:-contourplot([RRRR, m__zz, n],
                            m__zz = 0 .. piecewise(n <= a, 1, FFF) - 0.1*10^(-8),
                            n = 0 .. 1 - 0.1*10^(-8), labels = [m__yy, m__zz],
                            view = [0 .. 1, 0 .. 1], coloring = ["LightGreen", "Blue"],
                            contours = [1/5, a/2, a, 0.7], thickness = 3):
P1c2D;

 

Download testd3.mw

You might give this a whirl.

restart;

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

fsolve({c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55},{a, c});

fsolve({c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55}, {a, c})

fsolve([c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55],{a, c});

fsolve([c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55], {a, c})

fsolve([c*exp(-2*a)+18 = 55, c*exp(-8*a)+18 = 36],{a, c});

{a = .1200910258, c = 47.04478236}

 

A "hot fix", to correct line 52 (from return FAIL to break) of either `fsolve/sysnewton`
or fsolve:-sysnewton, in relevant versions.

If it works for you then you could try it in an initialization file.

 

proc()
  local str,pp,KK,uu,oldop;
  oldop:=kernelopts(':-opaquemodules'=false);
  try
    str:=sprintf("%a",kernelopts(':-version'))[8..13];
    if str="2015.2" then
      pp:=:-`fsolve/sysnewton`;
    elif
      parse(str)>=2016 and parse(str)<2020 then
      pp:=:-fsolve:-sysnewton;
    else;
      error "targeted version not detected";
    end if;
    KK:=ToInert(eval(pp)):
    if op([5,14,6,10,6,4,1,2,1,1,2],KK)
       = _Inert_STATSEQ(_Inert_RETURN(_Inert_NAME("FAIL",
           _Inert_ATTRIBUTE(_Inert_NAME("protected",
             _Inert_ATTRIBUTE(_Inert_NAME("protected"))))))) then
      unprotect(pp);
      uu:=true;
      assign(pp,FromInert(subsop([5,14,6,10,6,4,1,2,1,1,2]
                            =_Inert_STATSEQ(_Inert_BREAK()),KK)));
    end if:
  catch:
  finally
    kernelopts(':-opaquemodules'=oldop);
    if uu=true then
      protect(pp);
    end if;
  end try;
  NULL;
end proc();

 

fsolve({c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55},{a, c});

{a = .1200910258, c = 47.04478236}

fsolve([c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55],{a, c});

{a = .1200910258, c = 47.04478236}

fsolve([c*exp(-2*a)+18 = 55, c*exp(-8*a)+18 = 36],{a, c});

{a = .1200910258, c = 47.04478236}

 

Download sysnewtonhotfix.mw

Consider line 52 of fsolve:-sysnewton (it was `fsolve/sysnewton` in Maple 2015 and earlier) under showstat. The purpose of that line seems to be to bail out early on a iteration it considers futile. In Maple 18 it followed a conditional test that could never work (it compared a vector directly against a list). In Maple 2015 that was amended with a test that could work (and probably fixed some other example). But at that point it bails out by a hard return from the whole procedure (when the rare condition happens to get triggered), which seems like a coding mistake. A better way might be merely to break out of the current do-loop and allow the outer loop to proceed normally and produce further initial-point guesses and iteration attempts -- and so that's an idea for amending the procedure.

I don't advise pasting the code in as 2D Input.

3 4 5 6 7 8 9 Last Page 5 of 200