Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

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?

Hello

I had to save previous results of a calculation to files as the number of elements is too big for my computer to handle in one go.   Here it is an idea of what I am doing to read the files and perform the calculations.

mainproc:=proc(arg1,arg2,arg3,arg4) ... end proc:

Grid:-Set(mainproc):
Grid:-Set(arg2,arg3,arg4):   #  They don't change ever.

for i from 1 to number_of_files do 
   read(...):  # it reads arg1 from a file
   Grid:-Set(arg1):
   ans:=Grid:-Seq(mainproc(arg1[i],arg2,arg3,arg4),i=1..numelems(arg1))):
   Grid:-Wait():
   save ans, ....:
   unassign('arg1'):
   unassign('ans'):
   gc():  # An attempt
end do:

The actual code works but, for every step in the loop, the memory used by Maple increases by a certain amount that seems to be mostly related to arg1 (as if arg1 is piling up from iteration to iteration). 

I read some of the earlier posts on a similar subject dated 5 to 10 years old.  I wonder if there is something new that can be done to minimize the usage of memory.   

Many thanks

Ed

PS. I am aware of tasksize, numcpus and Threads.   

I have a simple matrix, 11 rows x 3 columns, with header row.  <<

I multiply column 1 and 2 to get <<0.,0.031,0.218,0.657,1.084,1.095,0.654,0.217>>

Now, I just want to add up these elements, but 'sum' doesn't work 'Sum' doesn't work either. Is there a simpel way to do this?
 

m1 := `<|>`(`<,>`("# girls", 0, 1, 2, 3, 4, 5, 6, 7, 8), `<,>`("P(x)", 0.4e-2, 0.31e-1, .109, .219, .271, .219, .109, 0.31e-1, 0.4e-2), `<,>`("x*P(x)", 0, 0, 0, 0, 0, 0, 0, 0, 0))

Matrix(%id = 18446745635438952446)

(1)

m1[2 .. 9, 3] := `~`[`*`](m1[2 .. 9, 1], m1[2 .. 9, 2])

Vector[column](%id = 18446745635417541318)

(2)

"Sum?"

Vector[column](%id = 18446745635493441398)

(3)

"sum?"

Error, (in LinearAlgebra:-Multiply) invalid arguments

 

``


 

Download Untitled_(3).mw

Does this condition happen when the character is too long?

Hello everybody,

i am trying to use PDEchangecoords to transform a system of differential equations from Cartesian coordinates to toroidal coordinates. However, when i use a user defined coordinate transform from toroidal to Cartesian, i don't get the initial equations. Please find attached a minimal working environment.

i would highly appreciate your hints and suggestions!

Thank you

Best regards,

F

question.mw
 

NULL

NULL

NULL

restart; with(DEtools); addcoords(invToroidal, [xi, eta, phi], [sinh(xi)*cos(phi)/(cosh(xi)-cos(eta)), sinh(xi)*sin(phi)/(cosh(xi)-cos(eta)), sin(eta)/(cosh(xi)-cos(eta))]); PDEchangecoords(diff(f(x, y, z), z), [x, y, z], toroidal, [xi, eta, phi]); PDEchangecoords(%, [xi, eta, phi], invToroidal, [x, y, z]); print("i would expect here to get", diff(f(x, y, z), z))

"i would expect here to get", diff(f(x, y, z), z)

(1)

NULL


 

Download question.mw

 

Hello Everyone!

I have one more challenge for you.

How can I find for a Free-Pinned-Pinned-Free (3-span) beam (Picture A below) using the Krylov–Duncan Method (Literature links and references below):

- the matrix of the system?

- the transcendental equation in order to determine the natural frequencies?

- the first three mode shapes?

I tried to do it as you can see from my MAPLE (file below), but I got stuck when I use the command "determinant" and it did not find the transcendental equation.

Krylov_function_free_pinned_pinned_free_beam.mw

 

Picture_A

References:

Krylov–Duncan Method
https://link.springer.com/content/pdf/10.1007%2F978-1-4419-1047-9_14.pdf
 

Krylov–Duncan Functions - page 96

You can find that book using the https://libgen.is/
https://www.amazon.com/Formulas-Structural-Dynamics-Tables-Solutions/dp/0071367128

Hello.

I would like to solve numerically highly nonlinear and cumbersome the second order differential equation. 

Applying the numerical procedure I got an error "Error, (in dsolve) found wrong extra argument(s): range = 0 .. 4*Pi, type = numerical". The similar problem has been described earlier here however I can't realize my problem. 

Below is my code

restart;

A1 := 8*Pi^3*R^2*n(x)^4*m+(2*Pi*sin((1/2)*x)*m*omega0*p+Pi*sin((1/2)*x)*m*omega0+3*Pi^2*(diff(n(x), x, x)))*n(x)^3+(-2*sin((1/2)*x)^2*m^2*omega0^2*p^2+2*cos((1/2)*x)^2*m^2*omega0^2*p^2-2*sin((1/2)*x)^2*m^2*omega0^2*p+2*cos((1/2)*x)^2*m^2*omega0^2*p)*n(x)^2+(-4*(diff(n(x), x, x))*sin((1/2)*x)^2*m^2*omega0^2*p^2-8*sin((1/2)*x)*(diff(n(x), x))*cos((1/2)*x)*m^2*omega0^2*p^2-4*(diff(n(x), x, x))*sin((1/2)*x)^2*m^2*omega0^2*p-8*sin((1/2)*x)*(diff(n(x), x))*cos((1/2)*x)*m^2*omega0^2*p)*n(x)+8*sin((1/2)*x)^2*(diff(n(x), x))^2*m^2*omega0^2*p^2+8*sin((1/2)*x)^2*(diff(n(x), x))^2*m^2*omega0^2*p;

R := 1; m := 1; p := 10; omega0 := 1000;

A2 := A1;

with(plots):
A3 := dsolve({A2, n(0) = n(4*Pi), (D(n))(0) = (D(n))(4*Pi)}, type = numerical, range = 0 .. 4*Pi):

odeplot(A3);


I appreciate for any help and suggestion.

 

Help required to plot the real part only in  multiple plots. i have written some codes  please help me to rectify the errors.Thanks in advance

 

restart:
with(plots):
n:=0.75:Eh:=100:mn:=1:t0:=0.2:
a1:=(mn/t0)^((n-1)/(n))*(tb)^(1/n):a3:=Eh/tb:a4:=(Eh)^2:
U1:=(a1/Eh)*(-1+(a3*r/Eh))^(1/n)*(n*a4/(1+n))*(1/a3-(r/Eh))-a1*(-1+(1/tb))^(1/n)*(n/(n+1)*(tb-1)):
plot([Re(seq(eval(U1,tb=j),j in[0.8,0.9,1.0]))],r=0..1,legend = [tb =0.8, tb=0.9,tb =1.0],  labels = ["z ", "U"], labeldirections = ["horizontal", "vertical"],  linestyle = [solid,dash,dot],color = [black, red,green]);

First 402 403 404 405 406 407 408 Last Page 404 of 2097