## 9406 Reputation

12 years, 26 days

 > pde:=diff(u(x,t),x$2)-(v-2)*u(x,t)-(v-v1/mu)*(-u(x,t)^3+u(x,t)^5)=0  > xx:=solve(zeta=sqrt(k)*(x-c*t),x);  > tr:={x=xx,u(x,t)=U(zeta)};  >  > pde2:=PDEtools:-dchange(tr,pde,{U,zeta},'known'={u(x,t)},'unknown'={U(zeta)})  > pde3:=PDEtools:-dchange({U(zeta)=sqrt(W(zeta))},pde2,{W},'known'={U(zeta)},'unknown'={W(zeta)})  > expand(pde3*sqrt(W(zeta)))  > collect(%,W(zeta));  > Download transformation.mw ## reply... convert the result to set, this will automatically remove duplicates.  > restart;  > interface(rtablesize=70); result:=Array(1..0): phi := (p__1, p__2, p__3, p__4, q__1, q__2, q__3, q__4, xi) -> (p__1*cosh(xi) - p__2*sinh(xi))/(p__3*cosh(xi) + p__4*sinh(xi)); xi := x: for p__1 in [1, -1, I, -I] do for p__2 in [1, -1, I, -I] do for p__3 in [1, -1, -I, I] do for p__4 in [0] do for q__1 in [1, -1, I, -I] do for q__2 in [1, -1, I, -I] do for q__3 in [1, -1, I, -I] do for q__4 in [1, -1, I, -I] do result ,=evalf(phi(p__1, p__2, p__3, p__4, q__1, q__2, q__3, q__4, xi)): #print('phi'(p__1, p__2, p__3, p__4, q__1, q__2, q__3, q__4, xi) = result1); od: od: od: od: od: od: od: od:  > print("Before, the size was ",numelems(result)); result_no_duplidates:=convert(convert(result,set),list): print("After remvoing duplicates, the size is ",nops(result_no_duplidates)); map(X->[''phi(p__1, p__2, p__3, p__4, q__1, q__2, q__3, q__4, xi)'' = X],result_no_duplidates): Matrix(%);  > Download A.mw ## reply... I do not think there is conversion builtin in Maple for this, at least I could not find one. But see if this does what you want for now. I only tested it on your input ! e0:=int(x^(1/2),x); evalindets(e0,sqrt,F->sqrt(op(1,F)^numer(op(2,F))))  Update For more general cases, (for your other comment below also) you can try this function called mySimplify  > restart;  > mySimplify :=e->evalindets(e,^,F->if( op(2,F)::fraction, surd( op(1,F)^numer(op(2,F)), denom(op(2,F))),F)): test_cases:=[ int( (x^2)^(1/3),x), int(x^(1/2),x), x^(2/3) ]: Matrix(map(X->[X,mySimplify(X)], test_cases))  > Download mysimplify.mw ## reply... while running my code i am not able to edit it If you mean you are running something in the worksheet, and while it is sitll running you can't edit or do anything? If so, then this is by design. Maple interface can't handle making any changes to worksheet while it is running something. You have to wait until computation is done. Make sure you set each worksheet to separate engine. This is a nice feature in Maple. This way while one sheet is busy, you can always open new worksheet and use that because each will be using new engine. See options on how to change this setting. although my code is working for one pde but while changing pde it is giving me error why? Good chance you have made some error typing the new pde or the new command. The error message you get should make it clear why. some times it takes alot of time to evaluate is there any error in the code or should i change my laptop? You should use the command timelimit look it up in help. You set a timeout how long some computation should take. The general format for doing this can be something like try result := timelimit(30, some_maple_command); #30 seconds timeout catch: print("Warning, The command has timed out"); result:= FAIL; end try;  You do not need to get new laptop. Many CAS computations take long time or hang. So you should always use timelimit to guard against this. Ofcourse having faster PC with more memory is not going to hurt if you can afford it. ## reply... PDEtools:-Infinitesimals compute the infinitesimals of symmetry groups admitted by a given PDE system  > pde:= diff(u(t,x,y),t$2)+2*a(t)*diff(u(t,x,y),x)^2+2*b(t)*u(t,x,y)*diff(u(t,x,y),x$2)+diff(u(t,x,y),y$2)=0; PDEtools:-Infinitesimals(pde,u(t,x,y))

Do not know if this will work for what you are doing or not.

 > restart;

 > interface(typesetting=extended);

 > make_nice:=proc(k::anything)      evalindets(k,&*(anything,'specfunc(ln)'),F->InertForm:-MakeInert(F)); end proc;

 > k:=3/8*ln(55/52);

 > make_nice(k)

 > k:=3/8*ln(55/52)+sin(x)+3/4*exp(x);

 > make_nice(k)

 >

From help it says subs does not work on contravariant indecies. Only on covariant. So need to use SubstituteTensorIndices from Physics package, See help page on SubstituteTensorIndices for more info.  It says to use subs on contra need to use ~=~ format then it should work.

I am using V 2024. If this does not work for you, may be it is version issue then,

 > restart;

 > with(Physics): Setup(mathematicalnotation = true); Define(A, B): e:=g_[alpha, mu] * A[~mu] * g_[~alpha, ~nu] * B[nu, sigma, ~rho];

 > subs(alpha = beta,e); #does not change contra

 > SubstituteTensorIndices(alpha = beta,e); #changes contra and covariant

 > #help says this should work. subs(~alpha = ~beta,e); #changes contra only OK

I never heard of the method of isodine. May be you meant isoclines  ?

To make slope plot do

ode:= x+y(x)*diff(y(x),x)=0;
DEtools:-DEplot(ode,y(x),x=-2..2,y=-3..3)

To get the solution, the command is

dsolve(ode)

To get step by step solution the command is

Student:-ODEs:-ODESteps(ode);


evalb(expand(sin(x + y))= sin(x)*cos(y) + cos(x)*sin(y));

true

Maple does not expand by default. (which is a good thing)

Can you recommend a good way to find out if two terms are equivalent?

There are few ways. One easy way is to do simplify(A-B) and see if you get zero

simplify(sin(x + y) - (sin(x)*cos(y) + cos(x)*sin(y)))

0

But ofcourse this depends how good the simplify command is. Also you can help the simplify with assumptions if needed.

There is also the command is and coulditbe to try

is(sin(x + y) = sin(x)*cos(y) + cos(x)*sin(y))

true

There might be other ways.  I had few false positives from coulditbe so be careful with it.

worksheet below generates this pdf

THis is latex generated

\documentclass[12pt,a4paper]{article}
\usepackage[letterpaper,margin=1.2in]{geometry}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=\arabic*)]
\item $A(-12; 2; -1)$,\quad $B(-11; 1; -5)$ \quad $C(-10; -2; 3)$, \quad $(P) :10 x +6 y +z +109 = 0$
\item $A(-12; 2; -1)$,\quad $B(-11; 1; -5)$ \quad $C(-10; 6; 3)$, \quad $(P) :2 x -2 y +z +29 = 0$
\item $A(-12; 2; -1)$,\quad $B(-11; 1; -5)$ \quad $C(-9; 5; -7)$, \quad $(P) :3 x -y +z +39 = 0$
\end{enumerate}
\end{document}

 > restart;

 > mylist := [[[-12, 2, -1], [-11, 1, -5], [-10, -2, 3], 10*x + 6*y + z + 109 = 0], [[-12, 2, -1], [-11, 1, -5], [-10, 6, 3], 2*x - 2*y + z + 29 = 0], [[-12, 2, -1], [-11, 1, -5], [-9, 5, -7], 3*x - y + z + 39 = 0]]

 > currentdir("C:/tmp"); #CHANGE TO WHERE YOU WANT TO SAVE LATEX FILE

 > latex:-Settings(useimaginaryunit=i,           usecolor = false,           powersoftrigonometricfunctions= mixed, ## computernotation,           leavespaceafterfunctionname = true,           cacheresults = false,           spaceaftersqrt = true,           usetypesettingcurrentsettings=true,           linelength=1000000       );

 > do_my_list:=proc(L::list,file_name::string)    local file_id;    local s::string,item;    local toX:= e->latex(e,'output'='string'):    local my_format:=proc(e)::string;       local s::string;       s:=toX(e);       s:=StringTools:-Substitute(s,"[","(");       s:=StringTools:-Substitute(s,"]",")");       s:=StringTools:-SubstituteAll(s,",",";");    end proc:    try        file_id := fopen(file_name,WRITE);    catch:        error StringTools:-FormatMessage(lastexception[2..-1]);    end try;      s:=cat("\\documentclass[12pt,a4paper]{article}\n",    "\\usepackage[letterpaper,margin=1.2in]{geometry}\n",    "\\usepackage{enumitem}\n",    "\\begin{document}\n",    "\\begin{enumerate}[label=\\arabic*)]\n"):    fprintf(file_id,"%s",s);    for item in L do       s:=cat("\\item $A",my_format(item[1]),"$,\\quad $B", my_format(item[2]),"$ \\quad $C",my_format(item[3]), "$, \\quad $(P) :",toX(item[4]),"$\n");       fprintf(file_id,"%s",s);    od;    s:="\\end{enumerate}\n\\end{document}\n";    fprintf(file_id,"%s",s);    fclose(file_id);     end proc:
 > file_name:=cat(currentdir(),"/HW.tex"); do_my_list(mylist,file_name);
 >

I am no expert on this. I find that using pattern matching in CAS to be more natural than using structured types to do this sort of thing. It also does not help that Maple documentation of its most important thing, which is structured typing, has so few examples to learn from. May be if Maple help had extensive examples, doing this sort of thing will not be like black magic any more to new users.

But here is an attempt. I am sure there is better way to do this in Maple.

 > f := -4*sin(x) + 2*exp(y^2) + 5 - 5*cos(x^3)*sin(y^2) + 5*sinh(x^2); # I want to extract terms with sin, sinh, and exp in this expression type_1:=''*'({anything,Or('specfunc(sin)','specfunc(sinh)','specfunc(exp)')})': indets(f,type_1)

 > #I want to get terms having sin(x) and sin(y^2), type_2:=*(And(anything,Or('specfunc(identical(y^2),sin)','specfunc(identical(x),sin)'))); select(hastype,f,type_2);

 > # for terms including sinh(x^3), I want to get Void output. type_3:='specfunc(identical(x^3),sinh)'; indets(f,type_3);

look at evalc

expr:= exp(alpha[i]*I*t);
evalc(expr)


one way

sol := (-v + sqrt(-4*a^2*R^2 + v^2))/(2*a*omega*L);
expand(sol);
map(X->if( hastype(X,'anything'^(1/2)),sqrt(X^2),X),%)


Another using pattern matching

sol := (-v + sqrt(-4*a^2*R^2 + v^2))/(2*a*omega*L);
f:=proc(x)
local a,b,c,la;
if patmatch(x,b::nonunit(anything)*sqrt(a::nonunit(anything)),'la') then
assign(la);
RETURN(sqrt(a*b^2));
else
RETURN(x);
fi;
end proc;
map(X->f(X),expand(sol));


note that in all the above,  sqrt(a)/b is same as sqrt(a/b^2) assuming b>0

Yes, this happens, but the important thing is that the corresponding order with the correct eigenvalue do not change.

i.e the way to read the outout is that the first eigenvalue goes with the first column, the second eigenvalue goes with the second column and so on.

So it does not matter if the eigenvector columns change positions, as long the the corresponding eigenvalues change in same way

btw, if you for some reason need to have same order of eigenvectors each time, you could always sort the eigenvector matrix columns using the numerical values of the corresponding eigenvalues as key for sorting. Something like

 > LI:=LinearAlgebra; M:=Matrix([[0,1],[1,0]]);

 > a,b:=LI:-Eigenvectors(M): b[.., sort(a,output=permutation)]

 > a,b:=LI:-Eigenvectors(M): b[.., sort(a,output=permutation)]

 > a,b:=LI:-Eigenvectors(M): b[.., sort(a,output=permutation)]

 > a,b:=LI:-Eigenvectors(M): b[.., sort(a,output=permutation)]

 > a,b:=LI:-Eigenvectors(M): b[.., sort(a,output=permutation)]

 > a,b:=LI:-Eigenvectors(M): b[.., sort(a,output=permutation)]