Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Dear all, is there a maple call to calculate the space curve connecting two points of a 3d plane?

e.g. the plane is defined by: f(x,y) = -x^2/9 + y^2/4

The two points are: P = (1,2,0), Q=(1,-1,0)

Searched: space curve laying on 3d plane connecting the two points.

Thanks

restart

with(PDEtools)

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

(1)

with(DEtools)

NULL

with(DifferentialAlgebra)

"with(Student[ODEs][Solve]): "

with(IntegrationTools)

with(inttrans)

with(PDEtools)

with(Physics)

with(PolynomialTools)

with(RootFinding)

with(SolveTools)

with(LinearAlgebra)

with(sumtools)

pde := I*(diff(psi(x, t), t))+alpha*(diff(psi(x, t), `$`(x, 2)))+(beta[3]*abs(psi(x, t))+beta[4]*abs(psi(x, t))^2)*psi(x, t)+gamma*(diff(abs(psi(x, t))^2, `$`(x, 2)))*psi(x, t)/abs(psi(x, t)) = 0

case1 := {k = k, lambda = sqrt(-1/(18*alpha*beta[4]+18*gamma*beta[4]))*beta[3], w = -(9*alpha*k^2*beta[4]+2*beta[3]^2)/(9*beta[4]), A[0] = -beta[3]/(3*beta[4]), A[1] = beta[3]/(3*beta[4]), B[1] = 0}

" psi(x,t):=U(xi)*exp(I*(-k*x+w*t+theta))"

proc (x, t) options operator, arrow, function_assign; U(xi)*exp(I*(-k*x+w*t+theta)) end proc

(2)

" U(xi):=-(beta[3] (cosh(xi)-sinh(xi)))/(3 beta[4] cosh(xi))"

proc (xi) options operator, arrow, function_assign; -(1/3)*beta[3]*(cosh(xi)-sinh(xi))/(beta[4]*cosh(xi)) end proc

(3)

convert(U(xi), trig)

-(1/3)*beta[3]*(cosh(xi)-sinh(xi))/(beta[4]*cosh(xi))

(4)

xi := sqrt(-1/(18*alpha*beta[4]+18*gamma*beta[4]))*beta[3]*(2*alpha*kt+x)

(-1/(18*alpha*beta[4]+18*gamma*beta[4]))^(1/2)*beta[3]*(2*alpha*kt+x)

(5)

S := psi(x, t)

-(1/3)*beta[3]*(cosh((-1/(18*alpha*beta[4]+18*gamma*beta[4]))^(1/2)*beta[3]*(2*alpha*kt+x))-sinh((-1/(18*alpha*beta[4]+18*gamma*beta[4]))^(1/2)*beta[3]*(2*alpha*kt+x)))*exp(I*(-k*x+t*w+theta))/(beta[4]*cosh((-1/(18*alpha*beta[4]+18*gamma*beta[4]))^(1/2)*beta[3]*(2*alpha*kt+x)))

(6)

solution := subs(case1, S)

-(1/3)*beta[3]*(cosh((-1/(18*alpha*beta[4]+18*gamma*beta[4]))^(1/2)*beta[3]*(2*alpha*kt+x))-sinh((-1/(18*alpha*beta[4]+18*gamma*beta[4]))^(1/2)*beta[3]*(2*alpha*kt+x)))*exp(I*(-k*x-(1/9)*(9*alpha*k^2*beta[4]+2*beta[3]^2)*t/beta[4]+theta))/(beta[4]*cosh((-1/(18*alpha*beta[4]+18*gamma*beta[4]))^(1/2)*beta[3]*(2*alpha*kt+x)))

(7)

pdetest(psi(x, t) = -beta[3]*(cosh(sqrt(-1/(18*alpha*beta[4]+18*gamma*beta[4]))*beta[3]*(2*alpha*k+x))-sinh(sqrt(-1/(18*alpha*beta[4]+18*gamma*beta[4]))*beta[3]*(2*alpha*k+x)))*exp(I*(-k*x-(9*alpha*k^2*beta[4]+2*beta[3]^2)*t/(9*beta[4])+theta))/(3*beta[4]*cosh(sqrt(-1/(18*alpha*beta[4]+18*gamma*beta[4]))*beta[3]*(2*alpha*k+x)))*exp(I*(-k*x-(9*alpha*k^2*beta[4]+2*beta[3]^2)*t/(9*beta[4])+theta)), pde)

Error, (in pdetest) unable to determine the indeterminate function

 

NULL

 

 

 

 

Download pde-solve.mw

Dear all, in the example below I create a matrix(3x2) and each element contains a vector. How can I avoid the double brackets of the matrix elements or eliminate the double brackets?

Thanks for help

restart;
with(PolynomialTools);
with(RootFinding);
with(SolveTools);
with(LinearAlgebra);
NULL;
NULL;
E1 := (-alpha*k^2*A[1] - alpha*k^2*B[1] + 3*A[0]^2*A[1]*beta[4] + 3*A[0]^2*B[1]*beta[4] + A[1]^3*beta[4] + 3*A[1]^2*B[1]*beta[4] + 3*A[1]*B[1]^2*beta[4] + B[1]^3*beta[4] + 2*A[0]*A[1]*beta[3] + 2*A[0]*B[1]*beta[3] - w*A[1] - w*B[1])*cosh(xi)^6 + (-alpha*k^2*A[0] + A[0]^3*beta[4] + 3*A[0]*A[1]^2*beta[4] + 6*A[0]*A[1]*B[1]*beta[4] + 3*A[0]*B[1]^2*beta[4] + A[0]^2*beta[3] + A[1]^2*beta[3] + 2*A[1]*B[1]*beta[3] + B[1]^2*beta[3] - w*A[0])*sinh(xi)*cosh(xi)^5 + (2*alpha*k^2*A[1] + alpha*k^2*B[1] - 2*alpha*lambda^2*A[1] + 2*alpha*lambda^2*B[1] - 2*gamma*lambda^2*A[1] + 2*gamma*lambda^2*B[1] - 6*A[0]^2*A[1]*beta[4] - 3*A[0]^2*B[1]*beta[4] - 3*A[1]^3*beta[4] - 6*A[1]^2*B[1]*beta[4] - 3*A[1]*B[1]^2*beta[4] - 4*A[0]*A[1]*beta[3] - 2*A[0]*B[1]*beta[3] + 2*w*A[1] + w*B[1])*cosh(xi)^4 + (alpha*k^2*A[0] - A[0]^3*beta[4] - 6*A[0]*A[1]^2*beta[4] - 6*A[0]*A[1]*B[1]*beta[4] - A[0]^2*beta[3] - 2*A[1]^2*beta[3] - 2*A[1]*B[1]*beta[3] + w*A[0])*sinh(xi)*cosh(xi)^3 + (-alpha*k^2*A[1] + 4*alpha*lambda^2*A[1] + 4*gamma*lambda^2*A[1] + 3*A[0]^2*A[1]*beta[4] + 3*A[1]^3*beta[4] + 3*A[1]^2*B[1]*beta[4] + 2*A[0]*A[1]*beta[3] - w*A[1])*cosh(xi)^2 + (3*A[0]*A[1]^2*beta[4] + A[1]^2*beta[3])*sinh(xi)*cosh(xi) - 2*alpha*lambda^2*A[1] - 2*gamma*lambda^2*A[1] - A[1]^3*beta[4] = 0;
N := 6;
for i from 0 to N do
    equ[1][i] := coeff(E1, {cosh(xi)^i, sinh(xi)^i}, i) = 0;
end do;
             //        2               2     
equ[1][0] := \\-alpha k  A[1] - alpha k  B[1]

           2                      2                    3        
   + 3 A[0]  A[1] beta[4] + 3 A[0]  B[1] beta[4] + A[1]  beta[4]

           2                           2               3        
   + 3 A[1]  B[1] beta[4] + 3 A[1] B[1]  beta[4] + B[1]  beta[4]

                                                                \ 
   + 2 A[0] A[1] beta[3] + 2 A[0] B[1] beta[3] - w A[1] - w B[1]/ 

          6   /        2            3        
  cosh(xi)  + \-alpha k  A[0] + A[0]  beta[4]

                2                                   
   + 3 A[0] A[1]  beta[4] + 6 A[0] A[1] B[1] beta[4]

                2               2               2        
   + 3 A[0] B[1]  beta[4] + A[0]  beta[3] + A[1]  beta[3]

                               2                 \          
   + 2 A[1] B[1] beta[3] + B[1]  beta[3] - w A[0]/ sinh(xi) 

          5   /         2               2     
  cosh(xi)  + \2 alpha k  A[1] + alpha k  B[1]

                   2                      2     
   - 2 alpha lambda  A[1] + 2 alpha lambda  B[1]

                   2                      2     
   - 2 gamma lambda  A[1] + 2 gamma lambda  B[1]

           2                      2             
   - 6 A[0]  A[1] beta[4] - 3 A[0]  B[1] beta[4]

           3                 2             
   - 3 A[1]  beta[4] - 6 A[1]  B[1] beta[4]

                2                              
   - 3 A[1] B[1]  beta[4] - 4 A[0] A[1] beta[3]

                                            \         4   /      
   - 2 A[0] B[1] beta[3] + 2 w A[1] + w B[1]/ cosh(xi)  + \alpha 

   2            3                      2        
  k  A[0] - A[0]  beta[4] - 6 A[0] A[1]  beta[4]

                                    2                 2        
   - 6 A[0] A[1] B[1] beta[4] - A[0]  beta[3] - 2 A[1]  beta[3]

                                 \                  3   /
   - 2 A[1] B[1] beta[3] + w A[0]/ sinh(xi) cosh(xi)  + \
        2                      2                      2     
-alpha k  A[1] + 4 alpha lambda  A[1] + 4 gamma lambda  A[1]

           2                      3        
   + 3 A[0]  A[1] beta[4] + 3 A[1]  beta[4]

           2                                            \ 
   + 3 A[1]  B[1] beta[4] + 2 A[0] A[1] beta[3] - w A[1]/ 

          2
  cosh(xi) 

     /           2               2        \                  
   + \3 A[0] A[1]  beta[4] + A[1]  beta[3]/ sinh(xi) cosh(xi)

                   2                      2            3           
   - 2 alpha lambda  A[1] - 2 gamma lambda  A[1] - A[1]  beta[4] = 

   \    
  0/ = 0


                       equ[1][1] := 0 = 0

                       equ[1][2] := 0 = 0

                       equ[1][3] := 0 = 0

                       equ[1][4] := 0 = 0

                       equ[1][5] := 0 = 0

                       equ[1][6] := 0 = 0

NULL;
NULL;

Download loop_for_coeficent.mw

Is the a print or plot function that can generate from an expression an expression tree

and/or the corresponding expression DAG

 

Taken from ?ProgrammingGuide,Chapter02

I was just using Maple to do a simple calculation but the units came out all complicated. 

The expression in question is work done by a van der Waals gas. The units should come out to Joules per mol. 

When I do the calculation manually (second expression below) I do get that result, albeit in more basic units than Joules.

In the first expression, in which I am using subs to sub in values with units into the expression, the final expression is very complicated. Why?

with(Units:-Simple)

simplify(subs({R = 8.314*Unit('J'/('K'*'mol')), T = 298*Unit('K'), V__1 = Unit('L'/'mol'), V__2 = 50*Unit('L'/'mol'), a = 2.283*Unit('L'^2*'bar'/'mol'^2), b = 0.4278e-1*Unit('L'/'mol')}, -R*T*ln((V__2-b)/(V__1-b))+a*(1/V__1-1/V__2)))

(-9798.522418*Units:-Unit(J/(K*mol))*Units:-Unit(K)*Units:-Unit(L/mol)+2.23734*Units:-Unit(L^2*bar/mol^2))/Units:-Unit(L/mol)

(1)

How do we simplify the units above so they become the same as the units in the same (manual) calculation below?

-(8.314*Unit('J'/('K'*'mol'))*298)*Unit('K')*ln((50*Unit('L'/'mol')-0.4278e-1*Unit('L'/'mol'))/(Unit('L'/'mol')-0.4278e-1*Unit('L'/'mol')))+2.283*Unit('L'^2*'bar'/'mol'^2)/Unit('L'/'mol')

-9570.222418*Units:-Unit(m^2*kg/(s^2*mol))

(2)

NULL

Download Units_-_Subs.mw

restart;
Proc := proc(t) local t4, l3, R, r, eq, sol; _EnvHorizontalName := 'x'; _EnvVerticalName := 'y'; t4 := thickness = 4; l3 := linestyle = dot; R := 9; r := 1/2*R; geometry:-point(OO, 0, 0); geometry:-circle(Cir, [OO, R]); geometry:-point(K, R*cos(t), R*sin(t)); geometry:-point(Omega, r*cos(t), r*sin(t)); geometry:-circle(cir, [Omega, r]); eq := geometry:-Equation(cir); geometry:-line(XXp, y = 0); geometry:-line(YYp, x = 0); geometry:-line(L1, y = x); geometry:-line(L2, y = -x); geometry:-projection(M1, K, XXp); geometry:-coordinates(M1); geometry:-point(K2, geometry:-coordinates(M1)[1] - 2*R, 0); geometry:-coordinates(K2); geometry:-segment(sT, K2, M1); geometry:-point(N1, 0, R*sin(t)); subs(y = x, eq); sol := solve(%, x); geometry:-point(N2, sol[2], sol[2]); subs(y = -x, eq); sol := solve(%, x); geometry:-point(N3, sol[2], -sol[2]); plots:-display(geometry:-draw([Cir(color = blue, t4), cir(color = grey, t4), sT(color = black, t4), XXp(color = black, l3), YYp(color = black, l3), L1(color = black, l3), L2(color = black, l3), N1(color = blue, symbol = solidcircle, symbolsize = 15), N2(color = blue, symbol = solidcircle, symbolsize = 15), N3(color = blue, symbol = solidcircle, symbolsize = 15), M1(color = blue, symbol = solidcircle, symbolsize = 15)]), axes = none, view = [-30 .. 10, -10 .. 10], size = [800, 800]); end proc;
plots:-animate(Proc, [t], t = 0 .. 2*Pi, frames = 200);
NULL;
I am trying to program  this drawing, how to improve this code ? Thank you.

I know this question has been asked time and time again. Starting of with the expr . That is the end goal I want to achieve.  How would I reduce the expansion to get it into 1-f(x,y,z)/g(x,y,z) format?. I have tried all sorts of approaches.
 

restart

#

expr:=1 - (x__1*x__2 + y__1*y__2 - z__1*z__2)^2/((x__1^2 + y__1^2 - z__1^2)*(x__2^2 + y__2^2 - z__2^2))

1-(x__1*x__2+y__1*y__2-z__1*z__2)^2/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(1)

normal( (1) );

(x__1^2*y__2^2-x__1^2*z__2^2-2*x__1*x__2*y__1*y__2+2*x__1*x__2*z__1*z__2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2+2*y__1*y__2*z__1*z__2-y__2^2*z__1^2)/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(2)

simplify( (2) );

((y__2^2-z__2^2)*x__1^2-2*x__2*(y__1*y__2-z__1*z__2)*x__1+(y__1^2-z__1^2)*x__2^2-(y__1*z__2-y__2*z__1)^2)/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(3)

radnormal(%)

(x__1^2*y__2^2-x__1^2*z__2^2-2*x__1*x__2*y__1*y__2+2*x__1*x__2*z__1*z__2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2+2*y__1*y__2*z__1*z__2-y__2^2*z__1^2)/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(4)

Test:=combine(%)

(x__1^2*y__2^2-x__1^2*z__2^2-2*x__1*x__2*y__1*y__2+2*x__1*x__2*z__1*z__2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2+2*y__1*y__2*z__1*z__2-y__2^2*z__1^2)/((x__1^2+y__1^2-z__1^2)*(x__2^2+y__2^2-z__2^2))

(5)

 

n:={op(numer(Test))}

{x__1^2*y__2^2, x__2^2*y__1^2, -x__1^2*z__2^2, -x__2^2*z__1^2, -y__1^2*z__2^2, -y__2^2*z__1^2, -2*x__1*x__2*y__1*y__2, 2*x__1*x__2*z__1*z__2, 2*y__1*y__2*z__1*z__2}

(6)

d:={op(expand(denom(Test)))}

{x__1^2*x__2^2, x__1^2*y__2^2, x__2^2*y__1^2, y__1^2*y__2^2, z__1^2*z__2^2, -x__1^2*z__2^2, -x__2^2*z__1^2, -y__1^2*z__2^2, -y__2^2*z__1^2}

(7)

d subset n

false

(8)

d intersect n

{x__1^2*y__2^2, x__2^2*y__1^2, -x__1^2*z__2^2, -x__2^2*z__1^2, -y__1^2*z__2^2, -y__2^2*z__1^2}

(9)

add(%[i],i=1..nops(%))

x__1^2*y__2^2-x__1^2*z__2^2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2-y__2^2*z__1^2

(10)

factor( (10) );

x__1^2*y__2^2-x__1^2*z__2^2+x__2^2*y__1^2-x__2^2*z__1^2-y__1^2*z__2^2-y__2^2*z__1^2

(11)

n minus d

{-2*x__1*x__2*y__1*y__2, 2*x__1*x__2*z__1*z__2, 2*y__1*y__2*z__1*z__2}

(12)

 


 

Download 2024-07-20_Q_Simplify_Reformat.mw

We are pleased to announce that the registration for the Maple Conference 2024 is now open.

Like the last few years, this year’s conference will be a free virtual event. Please visit the conference page for more information on how to register.

This year we are offering a number of new sessions, including more product training options and an Audience Choice session.
You can find an overview of the program on the Sessions page. Those who register before September 10th, 2024 will have a chance to vote for the topics they want to learn more about during the Audience Choice session.

We hope to see you there!

Good afternoon, please I have the following question to see if someone can help me.

I am calculating an integral with a root and when Maple gives me the result it does so in power. I want the result to be given in square root, both this integral and others that I am going to solve.

Whenever I call RandomGraph(20,200), Maple crashes both on the laptop and on the PC: any suggestion?

with(GraphTheory); with(RandomGraphs)

interface(version)

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

(1)

G := RandomGraph(20, 200)


Download crash.mw

This is some serious problem in Latex in Maple 2024.1

I went back to using _C1, _C2 for my own constants of integration.

But I want to get the nice latex for c__1,c__2.

So to do that, my understanding is that I just need to call Maple's dsolve after restart on some random ode in order to set c__1,c__2 for display only and also for latex.

This below seems to confirm this.  But now the latex generated is all wrong and messed up on some places. 

My question is: I want to use use _C1,_C2 (i.e. the traditional constants) in my own code I write which generates solution to an ode, but for Latex, I'd like these to come out as c__1,c__2 since they look nicer.

What is the correct way to do this? What Am I doing wrong here? I do not see it.

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

#EXAMPLE showing using _C1 for input and latex. All works OK
restart;

sol:=y(x) = x+_C1/x^2;

y(x) = x+_C1/x^2

#correct latex. No problem compiling, but not nice looking _C1
latex(sol)

y \! \left(x \right) = x +\frac{\textit{\_C1}}{x^{2}}

#Example showing what happens when making call to dsolve initially
restart;

dsolve(diff(y(x),x$2)=0); #this call is used to just activate display of nicer constants

y(x) = c__1*x+c__2

sol:=y(x) = x+_C1/x^2;

y(x) = x+c__1/x^2

#bad latex, gives error when compiling with texlive
latex(sol)

y \! \left(x \right) = x +\frac{c}{_}

 

 

Download latex_problem_maple_2024_july_18_2024.mw

And to confirm this is new problem in Maple 2024, I run the same exact worksheet now in Maple 2023.2, and there it works correctly. i.e. Latex generated is correct in both cases. Here is the Maple 2023.2 worksheet, you can see below the difference in Latex.

interface(version);

`Standard Worksheet Interface, Maple 2023.2, Windows 10, November 24 2023 Build ID 1762575`

#EXAMPLE showing using _C1 for input and latex. All works OK
restart;

38296

sol:=y(x) = x+_C1/x^2;

y(x) = x+_C1/x^2

#correct latex. No problem compiling, but not nice looking _C1
latex(sol)

y \! \left(x \right) = x +\frac{\textit{\_C1}}{x^{2}}

#Example showing what happens when making call to dsolve initially
restart;

38296

dsolve(diff(y(x),x$2)=0); #this call is used to just activate display of nicer constants

y(x) = c__1*x+c__2

sol:=y(x) = x+_C1/x^2;

y(x) = x+c__1/x^2

#good Latex now in Maple 2023.2.
latex(sol)

y \! \left(x \right) = x +\frac{c_{1}}{x^{2}}

 

 

Download latex_problem_maple_2023.2.mw

If it makes any difference to Maple, I am using the typesetting EXTENDED now for everything. But I do not think Latex should care about this, but thought to mention it just in case.

Hello

Consider,  as an example,  the following (simple) transcendental equation. 

alpha*((epsilon-1)*x+y-3*x*z-epsilon/3*x^3+b*sin(w)+3)

How to retrieve the coefficients and the terms considering that the unknowns are x,y,z and w?   Something like [x,y,x*z,x^3,sin(w),1] and their coefficients.  

many thanks

I have thought before that Maple's dsolve will try to return implicit solution automatically if unable to find explicit one or for some  other reasons it prefers implicit.

But In this ode, we see Maple returns no solution at all for this first order quadrature ode, even though it can find solution when given implicit option.

Is this a correct behaviour? Should it not have returned this solution automatically?

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1774 and is the same as the version installed in this computer, created 2024, July 16, 17:18 hours Pacific Time.`

restart;

ode:=diff(y(x),x)=sin(y(x));
IC:=y(a)=b;

diff(y(x), x) = sin(y(x))

y(a) = b

maple_sol:=dsolve([ode,IC]);

maple_sol:=dsolve([ode,IC],explicit);

maple_sol:=dsolve([ode,IC],implicit);

x-ln(csc(y(x))-cot(y(x)))-a+ln(csc(b)-cot(b)) = 0

 

 

Download why_no_solution_by_dsolve_july_18_2024.mw

I want to obtain the partial derivative of a piecewise function. How it is possible to calculate  the derivative in (0,0) with diff?

I should get, as answer,  a new piecewise function

with(student);
f := (x, y) -> piecewise((x, y) = (0, 0), 0, (x^3*y - x*y^3)/(y^2 + x^2));
 f := proc (x, y) options operator, arrow; piecewise((x, y) = 

    (0, 0), 0, (x^3*y-x*y^3)/(y^2+x^2)) end proc

fx := (x, y) -> diff(f(x, y), x);
fx := proc (x, y) options operator, arrow; diff(f(x, y), x) end 

   proc

fx(0, 0);
Error, (in fx) invalid input: diff received 0, which is not valid for its 2nd argument

but i obtain an error

anna rita

1 2 3 4 5 6 7 Last Page 1 of 2127