nm

11353 Reputation

20 Badges

13 years, 19 days

MaplePrimes Activity


These are questions asked by nm

What is the letter O doing inside this pde solution by Maple 2020.2 and what does it mean? There is no O in the PDE itself and it is not a name of a mathematical special function 

restart;
interface(version);
pde :=  diff(w(x,y),x)+ (a*x^2*y+b*y^3)*diff(w(x,y),y) = 0;
sol:=pdsolve(pde,w(x,y));

 

lprint(sol)

w(x,y) = _F1(1/9*(2*2^(2/3)*3^(5/6)*b*x*O*y^2-3*2^(2/3)*3^(1/3)*b*x*GAMMA(1/3,-\
2/3*x^3*a)*GAMMA(2/3)*y^2+9*O*GAMMA(2/3)*exp(2/3*x^3*a))/O/GAMMA(2/3)/y^2)

 

Please see this example. This Latex generated gives Latex compile error.

restart;
Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= mixed, ## computernotation,
      leavespaceafterfunctionname = true,
      cacheresults = false,
      spaceaftersqrt = true  
);

L:=3;
c:=4;
h:=1/10;
b:=Pi*c/L;
f:=piecewise(0<x and x<L/3,3*h/L*x,L/3<x and x<L,h);
pde := diff(u(x,t),t$2) + b*diff(u(x,t),t) = c^2*diff(u(x,t),x$2);
bc  := u(0,t)=0,D[1](u)(L,t)=0;
ic  := D[2](u)(x,0)=0,u(x,0)=f;
sol:=pdsolve([pde,bc,ic],u(x,t));

The Latex generated does not compile:

Latex(sol)


u \left(x , t\right) = 
\Mapleoverset{\infty}{\Mapleunderset{n =0}{\sum}}\left\{\begin{array}{44}\frac{4 \,{\mathrm e}^{-\frac{2 t \pi}{3}} \left(t \pi +\frac{3}{2}\right) \sin \left(\frac{\pi  x}{6}\right)}{5 \pi^{2}} & n =0 \\\frac{3 \sin \left(\frac{\left(1+2 n \right) \pi  x}{6}\right) \left(\sqrt{3}\, \sin \left(\frac{\pi  n}{3}\right)+\cos \left(\frac{\pi  n}{3}\right)\right) \left(\left(2 \sqrt{n}\, \sqrt{n +1}+i\right) {\mathrm e}^{\frac{2 i \pi  \left(-2 \sqrt{n}\, \sqrt{n +1}+i\right) t}{3}}-{\mathrm e}^{\frac{2 i \pi  \left(2 \sqrt{n}\, \sqrt{n +1}+i\right) t}{3}} \left(-2 \sqrt{n}\, \sqrt{n +1}+i\right)\right)}{10 \sqrt{n}\, \sqrt{n +1}\, \pi^{2} \left(1+2 n \right)^{2}} & \mathit{otherwise}  \end{array}\right.

Gives

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{maplestd2e}  

\begin{document}
\[
u \left(x , t\right) = 
\Mapleoverset{\infty}{\Mapleunderset{n =0}{\sum}}\left\{\begin{array}{44}\frac{4 \,{\mathrm e}^{-\frac{2 t \pi}{3}} 
   \left(t \pi +\frac{3}{2}\right) \sin \left(\frac{\pi  x}{6}\right)}{5 \pi^{2}} 
    & n =0 \\\frac{3 \sin \left(\frac{\left(1+2 n \right) \pi  x}{6}\right) 
    \left(\sqrt{3}\, \sin \left(\frac{\pi  n}{3}\right)+\cos \left(\frac{\pi  n}{3}\right)\right) 
    \left(\left(2 \sqrt{n}\, \sqrt{n +1}+i\right) {\mathrm e}^{\frac{2 i \pi  \left(-2 \sqrt{n}\, 
    \sqrt{n +1}+i\right) t}{3}}-{\mathrm e}^{\frac{2 i \pi  \left(2 \sqrt{n}\, \sqrt{n +1}+i\right) t}{3}} 
    \left(-2 \sqrt{n}\, \sqrt{n +1}+i\right)\right)}{10 \sqrt{n}\, \sqrt{n +1}\, \pi^{2} \left(1+2 n \right)^{2}} 
    & \mathit{otherwise}  \end{array}\right.
\]

\end{document}

This, using latest TeXLive on Linux, gives  Illegal character in array arg.

lualatex foo5.tex
This is LuaHBTeX, Version 1.12.0 (TeX Live 2020)
 restricted system commands enabled.
(./foo5.tex
LaTeX2e <2020-10-01> patch level 2


 L3 programming layer <2020-12-07> xparse <2020-03-03> (/usr/local/texlive/2020/texmf-dist/tex/latex/base/article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size11.clo)) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/mnt/g/public_html/styles/maplestd2e.sty
Package: maple2e 2005/03/17 v1.16
Defining Maple Utility Macros
(/mnt/g/public_html/styles/mapleenv.def)
Defining Maple Plot Environemnts
 ...Defaults to "dvips" Driver
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/epsfig.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphicx.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphics.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/trig.sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/graphics.cfg) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-def/dvips.def))))
Defining Automatic Style Generation Macros
Defining Maple Spreadsheet Environments
Maple Spreadsheet and Table Support
) (/usr/local/texlive/2020/texmf-dist/tex/latex/l3backend/l3backend-luatex.def) (./foo5.aux) (/usr/local/texlive/2020/texmf-dist/tex/latex/base/ts1cmr.fd)

! LaTeX Error: Illegal character in array arg.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...haracter\or Missing @-exp\or Missing p-arg\fi \space in array arg.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help\@err@

l.8 \Mapleoverset{\infty}{\Mapleunderset{n =0}{\sum}}\left\{\begin{array}{44}
                                                                           \frac{4 \,{\mathrm e}^{-\frac{2 t \pi}{3}}
?

fyi. No errors are generated from the old latex() command.

The following is another example, with the same Latex error. 

restart;
Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions= mixed, ## computernotation,
      leavespaceafterfunctionname = true,
      cacheresults = false,
      spaceaftersqrt = true  
);

c:=3;
f:=piecewise(4<x and x<5,1,true,0);
pde := diff(u(x, t), t$2) = c^2*(diff(u(x, t), x$2));
bc  := eval( diff(u(x,t),x),x=0)=0;
ic  := u(x,0)=f(x),eval(diff(u(x,t),t),t=0)=0;
sol:=pdsolve([pde, bc,ic],u(x,t)) assuming x>0,t>0;

Latex(sol);  #gives Latex that do not compile

Maple 2020.2, with Physics 897

colect(expr,y)  and collect(expr,y,factor) do not work on these.  The expression can be anything. No necessarily a polynomial in y.

I have as input an expression, which has y  in it, and I want to find if I can write it  as   y*(....)  of y^2*(...) or y^3*(...), etc...

Basically, I want to see if can be taken out as common term. Just like we do by hand. 

So, given expression as  y^2+y^3*sin(x)+3*x*y^5 then I want to see if it can be written as y^2*(1+y*sin(x)+3*x*y^3)

In the above y^2 was extracted as common term. I found that simplify sometimes work, but I can't depend on simplify, since it is not guranteed to work all the time. Here is an example where it worked

expr:=y^2+y^3*sin(x);
simplify(expr)

but if expression is this, then it did not extract out y^2

expr:=y^2+y^3*sin(x)+3*x*y^5;
simplify(expr)

I am doing this  all in code, without looking at the expression and decide what to do. 

I just know  is the name of the variable, and the expression will be a function of  and I just want to know if I can extract a common y^n  term out, so the result is y^n*g(y)

For example, for expr:=y^2+y^3*sin(x)+3*x; it will fail, since  I can't extract from all terms. In this case the result will be  y^2*(1+y*sin(x))+3*x  and this is not type(`*`). So it is ok for the method to fail, if it can not do it. I can always check the result to see if it failed or not.

Does Maple have build in method to do this? Or one has to program this? I wanted to ask first before if there is some hidden Maple function that can do this I did not see.

Sometimes math is easier to do by hand than using the computer :)

Maple 2020.2

Thanks.

edit: I also tried factor, but it does not work on everything. An example where it did not work

expr:=y^2+y^3*sin(x)+3*x*y^(7/2);
factor(expr);

It did not factor out y^2 because of y^(7/2) is not "integer, rational. numeric, or algebraic coefficients"? according to help.

Edit:

Thanks to all the answers. I used a combination of all of them to check if it can be factored or not, and now it is working for every example I tried it on. So if one method failed, I try the next method shown in the answers. 

 


 

I have function that accept keyword argument. From this function, I need to pass this argument to another function using the same signature and using same name for the keyword. But it is not possible to do. 

Easier to explain with an example.   This is what I want to do

restart;
foo:=proc(n::integer,{ic::`=`:=[]})   
   post_process(n+1,'ic'=ic);
end proc;

post_process:=proc(n::integer,{ic::`=`:= []})
    print("in postprocess, n=",n, "ic=",ic);
end proc;

foo(3,'ic'=(y(0)=5))

Gives 

The problem is that when calling post_process(), using 'ic'=ic it does not work. Currently I have to change the keyword name as workaround, like this

restart;
foo:=proc(A::integer,{ic::`=`:=[]})
   print("in foo, A=",A, "ic=",ic);
   post_process(A,'new_ic'=ic);
end proc;

post_process:=proc(A::integer,{new_ic::`=`:= []})
    print("in postprocess, A=",A, "ic=",new_ic);
end proc;

foo(3,'ic'=(y(0)=5))

Which gives

Now it passed it. I would have liked to keep same keyword name ic in both function signatures instead of coming up with new name.

Is there a way to do that? 

This is not the only problem. The problem with this workaround, is that it does not work when the keyword argument is not passed to the first function. Because now it will use the default values of [].

Hence when calling the post_process() function, it fails due to type mismatch. This now gives an error

restart;
foo:=proc(A::integer,{ic::`=`:=[]})
   print("in foo, A=",A, "ic=",ic);
   post_process(A,'new_ic'=ic);
end proc;

post_process:=proc(A::integer,{new_ic::`=`:= []})
    print("in postprocess, A=",A, "ic=",new_ic);
end proc;

foo(3)

 

Error, (in foo) invalid input: post_process expects value for keyword parameter new_ic to be of type `=`, but received []

So the way I do this now, is to add an extra check each time, like this

restart;
foo:=proc(A::integer,{ic::`=`:=[]})
   if nargs = 2 then #is ic passed in?     
      post_process(A,'new_ic'=ic);
   else
      post_process(A);
   fi;
end proc;

post_process:=proc(A::integer,{new_ic::`=`:= []})
    print("in postprocess, A=",A, "ic=",new_ic);
end proc;

foo(3)# now it works

But in my actual code, I have more than one keyword argument, and I have to keep checking for correct number of arguments each time, to know which arggument to pass along. 

So far, I did not find an easy way around this.

Any suggestion how to do this better? passing keyword argument with default values? from one function to another without getting into these problems?

Maple 2020.2

 

Why Maple gives this error and is this a known issue?

restart;
pdsolve( [diff(u(x,t),t)=diff(u(x,t),x)*diff(u(x,t),x$2), u(x,0)=0],u(x,t))

Maple 2020.2 with Physics 893 on windows 10.

 

First 99 100 101 102 103 104 105 Last Page 101 of 199