MaplePrimes Questions

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

I must do some formula manipulation
 

Classification of conic sections

restart; with(student):

A*x^2+B*y^2+C*x+D*y+E=0;

A*x^2+B*y^2+C*x+D*y+E = 0

(1)

f:= A*x^2+B*y^2+C*x+D*y+E;

A*x^2+B*y^2+C*x+D*y+E

(2)

completesquare(f, x);

A*(x+(1/2)*C/A)^2-(1/4)*C^2/A+B*y^2+D*y+E

(3)

f:= A*x^2+B*y^2+C*x+D*y+E;

A*x^2+B*y^2+C*x+D*y+E

(4)

ans:=Student[Precalculus][CompleteSquare]( (4), [y] );

B*(y+(1/2)*D/B)^2+A*x^2+C*x+E-(1/4)*D^2/B

(5)

ans1:=Student[Precalculus][CompleteSquare]( (4), [x] );

A*(x+(1/2)*C/A)^2-(1/4)*C^2/A+B*y^2+D*y+E

(6)

ans+ans1;

B*(y+(1/2)*D/B)^2+A*x^2+C*x+2*E-(1/4)*D^2/B+A*(x+(1/2)*C/A)^2-(1/4)*C^2/A+B*y^2+D*y

(7)

B*(y + D/(2*B))^2 + A*x^2 + C*x + 2*E - D^2/(4*B) + A*(x + C/(2*A))^2 - C^2/(4*A) + B*y^2 + D*y = 0;

B*(y+(1/2)*D/B)^2+A*x^2+C*x+2*E-(1/4)*D^2/B+A*(x+(1/2)*C/A)^2-(1/4)*C^2/A+B*y^2+D*y = 0

(8)

Now i must  get this form A( )^2 +B( )^2 = M  

 


 

Download vraag_herleiding_conic_sections_formule.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

 

Dear Community,

I would like to have an inverse interpolation with a 2D lookup table in MapleSim. The usual 2D lookup interpolation has u1 column values, and u2 row values, and a corresponding   y   table values, i.e. y = f(u1,u2). Now I would like to go the reverse way. Suppose I know y, and u2, and I would like to get u1. How can I implement this in MapleSim? An additional information is, that the 3D surface represented by the f(u1, u2) function is a smooth, slightly curved, monotonically sloping surface, so to any  y  value a unique pair of u1 and u2 values belong.

 

With my specific data, which are attached in the TestVLP.xlsx file:

 

  • u2 values are: 1st row, cells 2 .. 14
  • u1 values are  1st column, rows 2 .. 11
  • tabulated values are all the rest, i.e. from cell(2,2) .. cell(11,14)

 

Now for my case:

 

  • u2 = 42000.0
  • y   = 94.5614

 

How much is u1? I know the correct answer from elsewhere, it should be something very close to u1 ~ 85. This  y  value is in the rectangle bordered by columns 7 .. 8  and rows 5 .. 6 in the Excel file.

 

So my question is how do I correctly implement this in MapleSim? As visible from the attached TestInverse2DInterpolation.msim file I tried to do it with an Inverse Block Constraints component and a horizontally flipped 2D Lookup Table (VLP) and Constants for y and u2, but upon running MapleSim I get an error message that no solution is found, although the solution is relatively easy and straightforward. May I ask you to have a look at it, what can be the problem here, what do I do wrong? I’m using MapleSim 2019.2.

 

Your kind help is appreciated in advance

best regards

 

Andras

TestInverse2DInterpolation.msim

TestVLP.xlsx

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

First 242 243 244 245 246 247 248 Last Page 244 of 2143