Maple 2018 Questions and Posts

These are Posts and Questions associated with the product, Maple 2018

Why does Maple dsolve give this strange error from dsolve? I do not see that the input is wrong

restart;
F := x * ( y(x) + x*sqrt(x*y(x)) + sqrt(x^3*y(x)) );
ode:= diff(y(x),x) = F;
dsolve(ode,y(x));

I do not see where the input is invalid. I stared at it for 5 minutes.

Mathematica can solve this as follows

ode = y'[x] == x ( y[x] + x Sqrt[x y[x]] + Sqrt[x^3 y[x]]  )
DSolve[ode, y[x], x]

Did I type something wrong in Maple?

Physics:-Version();
    2018, June 12, 1:40 hours, MapleCloud version: 60

 

 

I want z  to becomes abs(z) then later on, remove abs() and obtain z back in the same form it was.

I found that Maple changes z when I put it inside abs. Like this

expr:=(-y^2+1);
abs(expr);
op(1,%);

So instead of 1-y^2, I end up now with  y^2-1. I want to keep the same expression I started with.

Mathematica does not do this:

expr = 1 - y^2
Abs[expr]
%[[1]]

Is there a way or option to tell Maple not change the expression when I put it inside abs()?

This complicates what I am trying to do in Maple.

thank you

What is the correct idiom in Maple to do subexpression replacement?

Suppose I want to replace each occurance of ln(anything) by ln(abs(anything)) in an expression.

Currently I call indets and then loop over each entry and use patmatch to do the replacement.

Is there a better method than what I doing now? Here is an example

restart;
expr := 7*ln(arcsin(x))-(1/2)*ln(x-1)*sin(x)-(1/2)*ln(x+1)+f;
lis:=indets(expr):
for z in lis do
    a:='a';b:='b';c:='c';
    if patmatch(z,a::anything*ln(b::anything)*c::anything,'la') then
       map(z0->assign(z0),la);
       expr:=subs(z = a*ln(abs(b))*c, expr);
    fi;
od:
expr;

I do not know if this will fails on some other cases yet.

There are many questions that complain about Latex conversion in Maple.

I'd like to again request that Maplesoft improves Latex output of its expressions. If Maple can just fix how it generates fractions, that will good enough for now.

I am willing to send Maplesoft a personal check of the amount of one month salary for one of your developers to do this fix if you are willing to do it. It should not take more than one month to do this simple fix in your code. It might even take one day if someone knows the code.

The problem comes when there is a fraction in the expression. the Latex output instead of using proper latex code using "\frac{}{}", it instead uses "/" which makes the output terrible.

Another case, where Maple generate (expression)^{-1} instead of \frac{1}{expression}.

It can't be that hard to fix these 2 issues, which can go a long way towards making the latex generated by Maple much better. Here is an example

eq:=-(1/2)*1/y = (1/3)*x^3+z:
sol:=solve(eq,y);

latex(sol);
-3/2\, \left( {x}^{3}+3\,z \right) ^{-1}

Which renders as

Which is terrible. The screen output is much better.

Compare this to Mathematica

eq = -(1/2)*(1/y) == (1/3)*x^3 + z;
sol = y /. First@Solve[eq, y];
TeXForm[sol]

   -\frac{3}{2 \left(x^3+3 z\right)}

Which renders in Latex as

If Maplesoft does not think Latex is improtant, then they are completely wrong. CAS support in Latex is very important. Ignoring Latex means you will lose customers who want good Latex support of the math output of Maple. After all, Math and Latex go togother. And Maple is supposed to be all about Mathematics.

Any chance of Maplesoft taking some time to fix these issues in Latex? Maple has not had any improvement in Latex for years and years. I keep buying Maple each year, and nothing changes in its Latex export.

thank you

When I finished the following code, I can not export the .eps file for the densityplot

 

 

restart; t := 1; a[1] := 0; a[2] := 2; a[4] := 0; a[5] := 1; a[6] := -1; a[8] := 0; g := t*a[3]+x*a[1]+y*a[2]+a[4]; h := t*a[7]+x*a[5]+y*a[6]+a[8]; f := g^2+h^2+a[9]; a[3] := -(3*a[1]^3+a[1]*a[2]^2+3*a[1]*a[5]^2-a[1]*a[6]^2+2*a[2]*a[5]*a[6])/(3*(a[1]^2+a[5]^2)); a[7] := -(3*a[1]^2*a[5]+2*a[1]*a[2]*a[6]-a[2]^2*a[5]+3*a[5]^3+a[5]*a[6]^2)/(3*(a[1]^2+a[5]^2)); a[9] := (3*(a[1]^6+3*a[1]^4*a[5]^2+3*a[1]^2*a[5]^4+a[5]^6))/(a[1]*a[6]-a[2]*a[5])^2; u := (4*(2*a[1]^2+a[5]^2))/f-8*(g*a[1]+h*a[5])^2/f^2; with(plots); plot3d(u, x = -20 .. 20, y = -20 .. 20, axes = frame, labels = ["x", "y", "z"], labeldirections = ["horizontal", "horizontal", "horizontal"], labelfont = ["TIMES", 16], style = patchnogrid); densityplot(u, x = -10 .. 10, y = -10 .. 10, axes = frame, labels = ["x", "y"], labeldirections = ["horizontal", "horizontal"], labelfont = ["TIMES", 16], colorstyle = HUE, style = patchnogrid); contourplot(u, x = -5 .. 5, y = -5 .. 5, labels = ["x", "y"], labeldirections = ["horizontal", "horizontal"], labelfont = ["TIMES", 16])

Does anybody mind clarifying what the three argument signum means?

I have the expression

signum(0,R-sqrt(R^2+z^2),1)

in which z>0, R>0. I guess I know what signum means, however in this case according to the help it is considering signum of 0 and then in the help it is talking about some environment variable. I just dont quite understand...

Does it mean Maple has issues to clarify the sign of R-sqrt(R^2+z^2) ??

Thanks

I found that when changing constant of integration from _C1 to C1, Maple now fails to verify solution.

Is one supposed to only use constant with _ in it for this? I prefer to use C1 instead of _C1. Why does Maple odetest fail in this case? Is there a way around this?

Here is an example

restart;
ode:=diff(y(x),x)=x*ln(y(x)):
implicit_sol := -Ei(1, -ln(y(x)))+C1=(1/2)*x^2;
explicit_sol := solve(implicit_sol,y(x)):
odetest(y(x)=explicit_sol,ode);

Now changing C1 to _C1 and nothing else, odetest verifies the solution

implicit_sol:= subs(C1=_C1,implicit_sol);
explicit_sol := solve(implicit_sol,y(x)):
odetest(y(x)=explicit_sol,ode);

I understand the using symbol with _ is a convention in Maple for global symbols. But I want to use C1 and not _C1 as it is easier to read.

 

How do I convert a complex number to abs and arg presentation.

For example:

z=1+1*I would be z=sqrt(2)*exp(I*Pi/4)

or when doing a calculation how can I tell him to always present these number in that form and do not expand out.

Thanks

How I can convert my maple code to matlab?.

dsolv.mw
 

 

restart;

``

 

fdsolve := proc({alpha:=NULL, t0:=NULL,
                 t1:=NULL, x0:=NULL, y0:=NULL,
                 N:=NULL}, params)
    local t, h, h1, h2, c, b, x, y, L, n, l, X, Y, f, g;
    eval(F(t,x,y), params);
    f := unapply(%, [t,x,y]);
    eval(G(t,x,y), params);
    g := unapply(%, [t,x,y]);
    L := floor(1/alpha);
    h := (t1 - t0)/N;
    h1 := h^alpha/GAMMA(alpha+1);
    h2 := h^alpha/GAMMA(alpha+2);
    c := (i,n) ->
        `if`(i=0,
            (n-1)^(alpha+1) - (n-1-alpha)*n^alpha,
            (n-i+1)^(alpha+1) + (n-i-1)^(alpha+1) - 2*(n-i)^(alpha+1));
    b := (i,n) -> (n-i)^alpha - (n-1-i)^alpha;
    t := Array(0..N, i-> (1-i/N)*t0 + i/N*t1, datatype=float[8]);
    x[0], y[0] := x0, y0;
    for n from 0 to N-1 do
        X[0], Y[0] :=
            x[0] + h1*add(b(i,n+1)*f(t[i],x[i],y[i]), i=0..n),
            y[0] + h1*add(b(i,n+1)*g(t[i],x[i],y[i]), i=0..n);
        for l from 1 to L do
            X[l], Y[l] :=
                x[0] + h2*add(c(i,n+1)*f(t[i],x[i],y[i]), i=0..n)
                     + h2*f(t[n+1], X[l-1], Y[l-1]),
                y[0] + h2*add(c(i,n+1)*g(t[i],x[i],y[i]), i=0..n)
                     + h2*g(t[n+1], X[l-1], Y[l-1]);
        end do;
        x[n+1], y[n+1] := X[L], Y[L];
        #printf("y[%d]=%a\n", n+1, y[n+1]);
    end do;
    return Array(0..N, i -> [t[i], x[i], y[i]]);
end proc:

 

F := (t,x,y) -> r*x*(1-x/k) - beta*x*y/(a+x^2);
G := (t,x,y) -> mu*beta*x*y/(a+x^2) - d*y - eta*x*y;

proc (t, x, y) options operator, arrow; r*x*(1-x/k)-beta*x*y/(a+x^2) end proc

 

proc (t, x, y) options operator, arrow; mu*beta*x*y/(a+x^2)-d*y-eta*x*y end proc

(1)

params := { r=0.05, a=0.8, mu=0.8, d=0.24,
            eta=0.01, beta=0.6, k=1.6 };

{a = .8, beta = .6, d = .24, eta = 0.1e-1, k = 1.6, mu = .8, r = 0.5e-1}

(2)

T := 300.0;  # time interval: 0 < t < T
q := 100;    # divide the time interval into q subintervals

300.0

 

100

(3)

We produce several solutions starting from various initial data x__0, y__0.

This reproduces the phase diagran in the cited article's Figure 2  (alpha=0.98):

sol := fdsolve(alpha=0.98, t0=0.0, t1=T, x0=2.5, y0=0.14, N=q, params):
p1 := plot([seq([sol[i][2], sol[i][3]], i=0..q)])

 

 

 


 

Download dsolv.mw

 

I want to check that all entries in a list are of some value. Say 0. (or in general, if all entries satisfy some condition).

So, If any entry is not zero, then it returns false. It returns true only if all elements meet this conditions.

What would be the right way to do this in Maple? I know I could write a loop. But I am asking if there is a build-in function in Maple. Here is an example

ode:=y(x)*diff(y(x),x)=x*(y(x)^2+2):
sol:= dsolve(ode,y(x)):
check:=map(z->odetest(z,ode1),[sol]);

                       check := [0, 0]

I want to check that all entries in check are zero. This tells me all my solution are correct.

I can't use member(check,0) since this only check if at least one entry is zero. I want to chek that all entries are zero.

In Mathematica, it has AllTrue function. Like this

check = {0, 0, 0};
AllTrue[check, # == 0 &]

     True

The "#==0&"  is the test to do. It uses this test on each element automatically. If all satisfy this test, then it returns true.

Again, I can easily write a small function in Maple to do this,

alltrue :=proc(arr,value)
    local z;
    for z in arr do
        if z<>value then
           return(false);
        fi;
    od;
    return(true);
end proc:

alltrue(check,0) return true.

But I am asking if there is a build-in such function similar to the above one in Mathematica, which accepts a more general test function to use.

why

expr:=1-3*y;
patmatch(expr, b::integer - a::integer*y,'la');

gives false but

expr:=1-3*y;
patmatch(expr, b::integer + a::integer*y,'la');

gives true?

Should one then use `+` for matching with `+` and `-`? This result was a little confusing to me. 

It is actually good that it behaves this way. Makes it easier to write the pattern (less cases to cover). But I would have expected both to return true, that is all.

I found I can start Maple itself 2 times on my windows PC. (I think my license allows max of 2, but I could be wrong).

I want to run a program which takes long time. But I want to use Maple at same time.

Which is the recommended approach:

1) Start 2 separate Maple applications. Use one to run the long program, and then I can use the second Maple for other things while the first is running)

2) Start one Maple, but set the "How should Maple handle the create of new Math engine" to "Ask me each time"

for me, choice 1 seems more safe. But thought to ask if there is something else I should consider when making which choice to pick.

Update

Found out that actually when clicking on Maple icon, I was not starting a new Maple at all. It was just starting a new worksheet using the currently running Maple ! This is confusing. With Mathematica, clicking on its icon actually starts a new complete separate Mathematica application. Not a new notebook using the currently running Mathematica.

So the question I have now is: Can one start 2 separate Maple applications on windows?  And if so, how?

Why does

MultiSeries:-series(LegendreQ(-1/2,x),x=-1))

not work?

series(LegendreQ(-1/2,x),x=-1))

seems to work, but does it give the correct result?

I actually thought there was a pole at -1.

Thx

PS: or is the cut between -1 and 1 with both logarithmic singularities?

I'm still wondering about the behaviour of MultiSeries

is there a way  for a proc() in a parent module to call an exported proc in a child module, without having to use long form of the call    child:-child_proc() and just do child_proc()?  Here is an example

A:=module()
  option package;
  export foo;
  local B; #child module

  B:=module()     
     export boo;
     boo:=proc()
        print("in B:-boo()");
     end proc;
  end module;
  
  foo:=proc()
     B:-boo();  #how can one just type  boo() here?
  end proc;
end module;

B:-foo(); now works ok. But I'd like to just use  boo() and not B:-boo() since the name of the child module is too long. 

I can't figure how to do it. I can't use with(B) in the parent, Maple complains. 

 

Hi 

I have a question about function as parameter in procedure

is it possible that I type 

f := x-> x+1

Test (f(x))

instead of Test(f) ? 

where Test is a simple procedure that takes in one function parameter 

Test := proc (f)
return f(1) + f (2) 

 

First 32 33 34 35 36 37 38 Page 34 of 40