MaplePrimes Questions

We've come over another annoying "feature" in units handling.

Maple isn't able to compare variables that have similar units, but are defined differently (like MPa and N/mm^2).

Did a quick check in Mathcad, seems to work there.

Compare_units.mw

I use odeadvisor a lot to tell me the type of the ode. It is one of the best tools in Maple.

But sometimes it overlooks some types of ODE's, if the ODE is written in different way. This does not happen alot. Here is an example

ode:=diff(y(x),x) = (2*x+y(x))/(3-x+3*y(x)^2);
DEtools:-odeadvisor(ode)


And advisor says it is rational, which is correct. 

But it does not also say it is exact. By rewriting as follows, it now see it is exact as well as rational:

ode2:=(denom(rhs(ode)))*diff(y(x),x)-(numer(rhs(ode)))=0;
DEtools:-odeadvisor(ode2);

And now it says [_exact, _rational]. It is the same ODE, just written different.

This is not a complaint about the advisor, I know it is not easy to figure the type of the ODE under different trasformations, but may be something to look into to improve it to be able to detect more types.

Maple 2020.1 

One thing I always liked about Maple, is that it does not do automatic simplifications or automatic re-write of expressions without the user explicitly asking for it like some other CAS systems do, which I think this is the right way.

So I was surprised when I set up a rational expression of a numerator and denominator, then when I asked for its denom and numer, I found Maple did automatic rewrite (even though on the screen the expression remained as it was originally). This caused a bug in my program (since it assumed as long as no simplifcation is made on the expression, numer and denom will remain as it was orginally placed). Here is an example

restart;
num:=-(1-x/exp(y));
den:=(exp(y)+x);
expr:=num/den;

So now, one would expect, by looking at the screen, when asking for numer(expr) to obtain back -(1-x/exp(y))  but this is not what happens

numer(expr)

And 

denom(expr)

So Maple's internal representation of numer and denom, is not what "appears" on the screen for the user. Maple automatically replaced -1+x/exp(y) by (-exp(y)+x)/exp(y) and then moved denominator of this, which is exp(y), down to the denominator of the orginal expression.

I was surprised by this, since as I said, my experence with Maple is that it keeps expressions as entered and will change them only when the user asks for a change.

How common is such behavior in Maple? and why did Maple do this under the cover manipulation in this case? It is probably documented somewhere if I search hard enough.

 

 

 

ode := diff(x(t), t, t) = - sin(x(t)^3)/x(t)^2

ics := x(0) = 0.7, D(x)(0) = 0.8

sol := dsolve({ics, ode}, numeric)

How can I  plot the derivative of the function x(t)?

I tried something like that:

odeplot(diff(sol, t), t = 0 .. 20) 

but not working

 

How to create procedure "mySumOfMatrixDiagonal(M)" which calculates the sum of the square of diagonal components for any given square matrix

Good day.

I have a simple function that I would like to plot, but am finding this awkward to do. My objective is to plot the function for varying k-values and I tried doing this using implicitplot and sequencing values of k.

The function in question is:
y := k*x*sqrt(z*(1-z));

The constant, k, takes the values: 5, 10, 15, ..., 100
The variables lie in the range: 0 ≤ x < 1 and 0 ≤ z < 1

So, if someone can tell me how to construct a plot of multiple solution curves for varying k, I would be most grateful.

Thanks for reading!

MaplePrimes_Plot.mw

 

Hello all, 

When I tried to extract the RHS of the answer from 'solve()' command, the attempt failed. 


 

restart;

sys := U__s^2 = ((1+sigma)*U__T2N - u__rN * U__T2N/(1+sigma))^2+(u__xN * U__T2N/(1+sigma))^2;

U__s^2 = ((1+sigma)*U__T2N-u__rN*U__T2N/(1+sigma))^2+u__xN^2*U__T2N^2/(1+sigma)^2

(1)

answer := solve( sys, {U__T2N} );

{U__T2N = (1+sigma)*U__s/(sigma^4+4*sigma^3-2*sigma^2*u__rN+6*sigma^2-4*sigma*u__rN+u__rN^2+u__xN^2+4*sigma-2*u__rN+1)^(1/2)}, {U__T2N = -(1+sigma)*U__s/(sigma^4+4*sigma^3-2*sigma^2*u__rN+6*sigma^2-4*sigma*u__rN+u__rN^2+u__xN^2+4*sigma-2*u__rN+1)^(1/2)}

(2)

answer[1];

{U__T2N = (1+sigma)*U__s/(sigma^4+4*sigma^3-2*sigma^2*u__rN+6*sigma^2-4*sigma*u__rN+u__rN^2+u__xN^2+4*sigma-2*u__rN+1)^(1/2)}

(3)

rhs(answer[1]);

Error, invalid input: rhs received {U__T2N = (1+sigma)*U__s/(sigma^4+4*sigma^3-2*sigma^2*u__rN+6*sigma^2-4*sigma*u__rN+u__rN^2+u__xN^2+4*sigma-2*u__rN+1)^(1/2)}, which is not valid for its 1st argument, expr

 

 


Perhaps, the failure might be related to the fact that the equation is contained in curly brackets, but I could not come up with a solution. 

Please let me have a chance to learn the way to do the 'rhs()' operation in the correct way. 

Thank you, 

In Kwon Park 

Download Qprime_20200710.mw

I want to define a vector function, then plot it, differentiate it, etc.

The best I've been able to do so far is to define it two different ways: one for evaluating, one for symbolic manipulation

with(plots): with(VectorCalculus):
r:= < cos(t), sin(t), t >;  # symbolic version of function, for example to take derivative
# returns derivative,
diff(r,t);
rf := (t)->evalf( < cos(t), sin(t), t > );   # returns numerical value of function
# we use numerical version to plot
rCurve := spacecurve( rf(t), t = -1 .. 1 );
# But how to return value of derivative?? Next line doesn't work.
df := (t)->evalf( diff(r,t) );

But how do I plot the derivative? The last line doesn't work. I've tried various variations but no luck.

I don't think this approach is write (why define two different ways?) but haven't been able to figure out how to do it.

Various online docs haven't helped.

 

I was trying to compare my solution with Maple on this ode, when I noticed Maple gives solution with no y(x)= in it. 

restart;
ode:=(y(x)-x*diff(y(x),x))/(y(x)^2+diff(y(x),x))=(y(x)-x*diff(y(x),x))/(1+x^2*diff(y(x),x));
sol:=dsolve(ode)

When there is more than one solution, Maple write y(x) on each. For an example

dsolve(diff(y(x),x)^2=x)

How to explain this output?

Maple 2020.1

I think I've seen such a problem before but thought it was fixed.

Here is an example, where depending on what one calls the constant of integration, maple can or not, verify the solution of the ode.

This should not happen.

When calling the constant of integration C[1] or _C Maple does not verify the solution. Only when using _C1 it does.

This is a problem, since I do not use _C1 or _C2  in my solution (so not to conflict with Maple's), I use C[1] and C[2].

Is there a workaround for this? 

Example 1

ode:=diff(z(x),x)+z(x)*cos(x)=z(x)^n*sin(2*x);
mysol:=z(x) = 1/((_C1*exp(sin(x)*(n - 1))*n - _C1*exp(sin(x)*(n - 1)) + 2*sin(x)*n - 2*sin(x) + 2)/(n - 1))^(1/(n - 1));
odetest(mysol,ode);

    0

Now I just changed _C1 to C[1] 

restart;
ode:=diff(z(x),x)+z(x)*cos(x)=z(x)^n*sin(2*x);
mysol:=z(x) = 1/(( C[1]*exp(sin(x)*(n - 1))*n - C[1]*exp(sin(x)*(n - 1)) + 2*sin(x)*n - 2*sin(x) + 2)/(n - 1))^(1/(n - 1));
odetest(mysol,ode);

 

and I get 2 pages full of stuff thrown at the screen. Same when using C as constant of integration.

I could change my C[1] and C[2] to _C1 and _C2 each time just before calling odetest as workaround.

But would like to ask if this is supposed to happen and why it happens. I depend on odetest alot, as I use it to tell me if my solution is correct or not and I do not want false negatives.

I have found additional ones. May be these will help locate the problem

Example 2

restart;
ode:=diff(y(x),x) = (1+x+y(x))^(1/2);
mysol1:=y(x) = LambertW(-exp(-x/2 - 1 + C[1]/2))^2 + 2*LambertW(-exp(-x/2 - 1 + C[1]/2)) - x:
odetest(mysol1,ode);

gives

But when using _C1 instead of C[1], this is the answer

restart;
ode:=diff(y(x),x) = (1+x+y(x))^(1/2):
mysol2:=y(x) = LambertW(-exp(-x/2 - 1 + _C1/2))^2 + 2*LambertW(-exp(-x/2 - 1 + _C1/2)) - x:
odetest(mysol2,ode);

Example 3

restart;
ode:=diff(y(x),x) = f(x)*y(x)+g(x)*y(x)^k:
mysol1:=y(x) = (-exp(-(k - 1)*Int(f(x), x))*(int(g(x)*exp((k - 1)*Int(f(x), x)), x)*k - int(g(x)*exp((k - 1)*Int(f(x), x)), x) - C[1]))^(-1/(k - 1)):
odetest(mysol1,ode);

   #long output is given

Changing C[1] to _C1 gives 0 right away

restart;
ode:=diff(y(x),x) = f(x)*y(x)+g(x)*y(x)^k:
mysol2:=y(x) = (-exp(-(k - 1)*Int(f(x), x))*(int(g(x)*exp((k - 1)*Int(f(x), x)), x)*k - int(g(x)*exp((k - 1)*Int(f(x), x)), x) - _C1))^(-1/(k - 1)):
odetest(mysol2,ode);

     0

 

Example 4

restart;
ode:=3*y(x)*diff(y(x),x)+5*cot(x)*cot(y(x))*cos(y(x))^2 = 0:
mysol1:=y(x) = RootOf(10*ln(sin(x))*cos(_Z)^2 - 3*cos(_Z)*sin(_Z) + 30*C[1]*cos(_Z)^2 + 3*_Z):
odetest(mysol1,ode);

Gives pages long output. Changing C[1] to _C1 gives zero

restart;
ode:=3*y(x)*diff(y(x),x)+5*cot(x)*cot(y(x))*cos(y(x))^2 = 0:
mysol2:=y(x) = RootOf(10*ln(sin(x))*cos(_Z)^2 - 3*cos(_Z)*sin(_Z) + 30*_C1*cos(_Z)^2 + 3*_Z):
odetest(mysol2,ode);

    0

 

Example 5

restart;
ode:=x*(x-a*y(x))*diff(y(x),x) = y(x)*(y(x)-a*x);
mysol1:=y(x) = exp((-a + 1)*RootOf(x*exp(ln(x)*a + _Z*a + C[1]*a + C[1]) + exp(ln(x)*a + _Z*a + C[1]*a - _Z + C[1])*x - 1) - ln(x)*a - C[1]*(a + 1)):
odetest(mysol1,ode);

gives

Changing C[1] to _C1 gives zero

restart;
ode:=x*(x-a*y(x))*diff(y(x),x) = y(x)*(y(x)-a*x);
mysol2:=y(x) = exp((-a + 1)*RootOf(x*exp(ln(x)*a + _Z*a + _C1*a + _C1) + exp(ln(x)*a + _Z*a + _C1*a - _Z + _C1)*x - 1) - ln(x)*a - _C1*(a + 1)):
odetest(mysol2,ode);

              0

 

Example 6

restart;
ode:=x*diff(y(x),x)^2-a*y(x)*diff(y(x),x)+b = 0:
mysol1:=y(x) = x*RootOf(2*x*_Z^2*a - 2*C[1]*_Z^((2*a - 1)/(a - 1))*a - x*_Z^2 + C[1]*_Z^((2*a - 1)/(a - 1)) - b)/a + b/(RootOf(2*x*_Z^2*a - 2*C[1]*_Z^((2*a - 1)/(a - 1))*a - x*_Z^2 + C[1]*_Z^((2*a - 1)/(a - 1)) - b)*a):
odetest(mysol1,ode);

gives many pages of output. Changing C[1] to _C1 gives zero

restart;
ode:=x*diff(y(x),x)^2-a*y(x)*diff(y(x),x)+b = 0:
mysol2:=y(x) = x*RootOf(2*x*_Z^2*a - 2*_C1*_Z^((2*a - 1)/(a - 1))*a - x*_Z^2 + _C1*_Z^((2*a - 1)/(a - 1)) - b)/a + b/(RootOf(2*x*_Z^2*a - 2*_C1*_Z^((2*a - 1)/(a - 1))*a - x*_Z^2 + _C1*_Z^((2*a - 1)/(a - 1)) - b)*a):
odetest(mysol2,ode);

             0

and more. I think the above should hopefully help locate the issue.

Maple 2020.1 with Physics 708

 

The general solution of x2y'' + 3xy' + λy = 0 is (from Example 4 here)

Why does dsolve(x^2*diff(y(x), x, x) + 3*x*diff(y(x), x) + lambda*y(x) = 0) give only the third case instead of the whole solution?

How to find all solutions [xi,yi] to the following system of equations  

x3y=1

y-sin(12x)=0

which satisfies condition 1,2<x<2  

I want to show the animation of the polar equation r=cos(2theta) be plotted from theta=0 to 2pi

Hello,The system of equations is as follows:

I'd like to find all integer solutions in [1,20], when I use isolve ,the results are not good.  Since at least one variable is equal to 0 in evey solution.

{isolve}({a+b+c=a1+b1+c1, a^2+b^2+c^2=(a1)^2+(b1)^2+(c1)^2,a*b*c=2*a1*b1*c1})

 In maple I did not  want to use less efficient for-loop like C programing as following.

#include <math.h>
#include <stdio.h>
void main()
{
    long int a,b,c,d,e,f;
    for(a=1;a<20;a++)
    {
        for(b=1;b<20;b++)
        {
            for(c=1;c<20;c++)
            {
                for(d=1;d<20;d++)
                {
                    for(e=1;e<20;e++)
                    {
                        for(f=1;f<20;f++)
                        {
                            if(a+b+c==d+e+f&&a*a+b*b+c*c==d*d+e*e+f*f&&a*b*c==2*d*e*f)                                             printf("a=%d,b=%d,c=%d,d=%d,e=%d,f=%d\n",a,b,c,d,e,f);
                        }
                    }
                }
            }
        }
    }
}
a=3,b=5,c=16,d=1,e=8,f=15
a=3,b=5,c=16,d=1,e=15,f=8
a=3,b=5,c=16,d=8,e=1,f=15
a=3,b=5,c=16,d=8,e=15,f=1
a=3,b=5,c=16,d=15,e=1,f=8
a=3,b=5,c=16,d=15,e=8,f=1
a=3,b=16,c=5,d=1,e=8,f=15
a=3,b=16,c=5,d=1,e=15,f=8
a=3,b=16,c=5,d=8,e=1,f=15
a=3,b=16,c=5,d=8,e=15,f=1
a=3,b=16,c=5,d=15,e=1,f=8
a=3,b=16,c=5,d=15,e=8,f=1
a=5,b=3,c=16,d=1,e=8,f=15
a=5,b=3,c=16,d=1,e=15,f=8
a=5,b=3,c=16,d=8,e=1,f=15
a=5,b=3,c=16,d=8,e=15,f=1
a=5,b=3,c=16,d=15,e=1,f=8
a=5,b=3,c=16,d=15,e=8,f=1
a=5,b=16,c=3,d=1,e=8,f=15
a=5,b=16,c=3,d=1,e=15,f=8
a=5,b=16,c=3,d=8,e=1,f=15
a=5,b=16,c=3,d=8,e=15,f=1
a=5,b=16,c=3,d=15,e=1,f=8
a=5,b=16,c=3,d=15,e=8,f=1
a=16,b=3,c=5,d=1,e=8,f=15
a=16,b=3,c=5,d=1,e=15,f=8
a=16,b=3,c=5,d=8,e=1,f=15
a=16,b=3,c=5,d=8,e=15,f=1
a=16,b=3,c=5,d=15,e=1,f=8
a=16,b=3,c=5,d=15,e=8,f=1
a=16,b=5,c=3,d=1,e=8,f=15
a=16,b=5,c=3,d=1,e=15,f=8
a=16,b=5,c=3,d=8,e=1,f=15
a=16,b=5,c=3,d=8,e=15,f=1
a=16,b=5,c=3,d=15,e=1,f=8
a=16,b=5,c=3,d=15,e=8,f=1

Does Maple have more good ways to solve that?

First 408 409 410 411 412 413 414 Last Page 410 of 2308