Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

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

Hi, 

I have developed many transfer functions derived by several solve() functions for an electrical design.  I need to pass on to the software guys the actual transfer equations without all of the maple details.  For example, I have an equation that showstat displays as follows:

fadc_vmon := proc(vmon)
   1   1638.400000*vmon+200.
end proc

I would like to output this as follows for the programmers:

adc(vmon) = 1638.400000*vmon+200

In addition, I would like to be able to have control over the number of digits displayed by the various parameters.

Is this something can be done?

 

Thanks,

David

 

Key in below command, the Ag2O is not recogonised

h_Ag2O := Property("Hmolar", " Ag2O", "temperature" = T)

 

I have a function F(x,y), for example, F=x+y,and a relation between x and y,which we denote it by G(x,y)=0, and x can not be solved explicitly, For example, G(x,y)= x^5+x^4*y+x^3*y+2*x^2*y^2+x*y^5+y^5-1. and I want to plot F(x,y) with respect to y, where x satisfy G(x,y)=0, How can I do this?

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. 

 


 

Dear maple users.

Greetings for the day.

I hope you are all fine and safe.

In the below mention code, I need to plot "ax" at 0..1 when N=1 and N=2.

But the code only working for the N=0 case.

How to tackle this situation and plot the function for various values of "ax" at ax=0..1.

waiting for your reply.

JBV.mw

Code:

restart;
PDEtools[declare](f(x), t(x), g(x), prime = (x));

N := 2; m := .2; pa := 3.14*(1/3); ax := ax; h2 := 1+.2*ax+.3*sin((2*3.14)*(ax-.2)); h1 := -1-.2*ax-.1*sin((2*3.14)*(ax-.2)+pa); a2 := 1.4+.1*sin((2*3.14)*(ax-.2))+.3*sin((2*3.14)*(ax-.2)+pa);

f(x):=sum(p^j*f[j](x),j=0..N);  t(x):=sum(p^j*t[j](x),j=0..N);

g(x):=sum(p^j*g[j](x),j=0..N);

Eq1 := (1-p)*(diff(f(x), `$`(x, 4)))+p*((1+.2)*(diff(f(x), `$`(x, 4)))-(.2*(1/3))*(diff((diff(f(x), `$`(x, 2)))^3, `$`(x, 2)))-2*(diff(f(x), `$`(x, 2)))+diff(t(x), `$`(x, 1))+diff(g(x), `$`(x, 1)));

Eq2 := (1-p)*(1+1.2)*(diff(t(x), `$`(x, 2)))+p*((1+1.2)*(diff(t(x), `$`(x, 2)))+.1*(diff(t(x), `$`(x, 1)))*(diff(g(x), `$`(x, 1)))+.2*(diff(t(x), `$`(x, 1)))^2+.5*(diff(f(x), `$`(x, 1)))^2);

Eq3 := (1-p)*(diff(g(x), `$`(x, 2)))+p*(diff(g(x), `$`(x, 2))+diff(t(x), `$`(x, 2)));

for j from 0 to N do
equ1[j] := coeff(Eq1, p, j) = 0; 
equ2[j] := coeff(Eq2, p, j) = 0;
equ3[j] := coeff(Eq3, p, j) = 0;
end do;

con[1][0] := f[0](h2) = (1/2)*a2, (D(f[0]))(h2) = 0, f[0](h1) = -(1/2)*a2, (D(f[0]))(h1) = 0; con[2][0] := t[0](h2) = 1, t[0](h1) = 0; con[3][0] := g[0](h2) = 1, g[0](h1) = 0;

for i to N do

con[1][i] := f[i](h2) = 0, (D(f[i]))(h2) = 0, f[i](h1) = 0, (D(f[i]))(h1) = 0; con[2][i] := t[i](h2) = 0, t[i](h1) = 0; con[3][i] := g[i](h2) = 0, g[i](h1) = 0 end do;

for i from 0 to N do
P:=dsolve({equ1[i],equ2[i],equ3[i],con[1][i],con[2][i],con[3][i]},{f[i](x),t[i](x),g[i](x)}):
f[i](x):=rhs(P[1]);
t[i](x):=rhs(P[2]);
g[i](x):=rhs(P[3]);
end do:

f(x):=evalf(simplify(sum(f[n](x),n=0..N)));
Am := (1+.2)*(diff(f(x), `$`(x, 3)));
with(plots);

display(plot(eval(Am, x = .6), ax = 0 .. 1, numpoints = 200, color = blue));
 


Digits := 6:
f := (t,x,y) -> diff(x(t),t$2) = -x(t)/(x(t)^2+y(t)^2)^(3/2):
g := (t,x,y) -> diff(y(t),t$2) = -y(t)/(x(t)^2+y(t)^2)^(3/2):

t0 := 0:
x0:=1: y0:=0: tf := 3: n := 12:                 # number of subintervals
m := 2:                  # to print every mth step
h := evalf((tf - t0)/n): # step size

t:=t0: x:=x0: y:=y0:

fmt := `%10.0f %10.4f %10.4f \n`:

for i from 1 to n do
   k1 := f(t,x,y):
   l1 := g(t,x,y):                    # left-hand slopes
   k2 := f(t+h/2,x+h*k1/2,y+h*l1/2):
   l2 := g(t+h/2,x+h*k1/2,y+h*l1/2):  # 1st midpt slopes
   k3 := f(t+h/2,x+h*k2/2,y+h*l2/2):
   l3 := g(t+h/2,x+h*k2/2,y+h*l2/2):  # 2nd midpt slopes
   k4 := f(t+h,x+h*k3,y+h*l3):
   l4 := g(t+h,x+h*k3,y+h*l3):
   k := (k1+2*k2+2*k3+k4)/6:
   l := (l1+2*l2+2*l3+l4)/6:
   x := x + h*k:
   y := y + h*l:
   t := t + h:
   if trunc(i/m) =i/m then  printf(fmt,180*t,x,y) fi; od:
Error, (in f) invalid input: diff received 0, which is not valid for its 2nd argument
 

What do you suggest for graphics that are very close to each other in one figure? 

I am asking for graphics in articles to be sent to a scientific journal.

 

a simple example

restart:
with(plots):
f1:=x->0.95*x;
f2:=x->0.99*x;
f3:=x->0.991*x;
p1:=plot(f1(x),x=0..2,color=red);
p2:=plot(f2(x),x=0..2,color=blue);
p3:=plot(f3(x),x=0..2,color=green);
display(p1,p2,p3);

 

 

 

Is there anyone able to solve this integral for me?

Recently I came back on the general problem of drawing the syntactic graph of a mathematical expression.
Probably some of you have already done this as students for it is a classic when you learn recursive procedures, chained lists or graphs.

I wasn't interested in doing this with Maple, because Maple had already done  a part of the job thanks to the procedure ToInert.
More of this, the package GraphTheory seemed to possess all the required features to obtain quickly this syntactic graph.
Nevertheless it took me a lot of time to fix (almost all) the problems.
The issues are mainly of two orders:

  1. ToInert is very verbose: a necessary feature when you want to have a non ambiguous syntax of an expression, but partly useless for simple visualization.
    Here is an example
    ToInert(f(x))
    _Inert_FUNCTION(_Inert_NAME("f"), _Inert_EXPSEQ(_Inert_NAME("x")))

     

  2. GraphTheory 
    Once the inert form of the expression is known, it is necessary to put it in a form that can be manipulated by the procedures of the GraphTheory package.
    More precisely one needs to transform this inert form into a set of lists [a, b], where a and b are two neighboring vertices of the syntactic graph and [a, b] the directed arc from a to b.
    As the syntactic graph is a tree, this implies using edges {a, b} instead of arcs [a, b].
    The problem is that some operators are commutative while others are not: for the latter this means that the edges and vertices on the syntactic graph must appear in an order that respects the non-commutativity.
    Here his a toy example where I manually buid the syntactic graphs of a/b and b/a: the two graphs are identical and this comes from the fact that edges in Graph( edges )  must be a set, thus an ordered structure whose order doesn't care about non-commutativity.

    restart:
    with(GraphTheory):
    # The first is aimed to represent the expression a/b
    # while the second is aimed to represent the expression b/a
    Gdiv := Graph({{"/", "a"}, {"/", "b"}}):
    g1 := DrawGraph(Gdiv, style=tree, root="/", title=a/b):
    
    Gdiv := Graph({{"/", "b"}, {"/", "a"}}):
    g2 :=DrawGraph(Gdiv, style=tree, root="/", title=b/a):
    
    plots:-display(<g1 | g2>)
    

    Download ab_ba.mw

     

After several attempts, I decided to discard the GraphTheory package, that is to deprive myself of all the interesting features one needs to manipulate a graph.

The result is given on the attached file (... and the content of the worksheet can't be loaded as usual).

Download Syntactic_Graph.mw

Here is an example


Twelve test cases are given, all the corresponding syntactic graphs are correct, but one of them (test case iexpr=1) seems incorrect because the right child of a parent P is located to the right of the left child of a parent P', even though P' is to the right of P.
This could be corrected by modifying the way the posiitons are computed in procedure Place.


PS : It doesn't seem that Maple has a built-in procedure to construct the syntactic graph of a mathematical expression.
But maybe I'm wrong?


 

 

Hi, 
I wonder what is I in MAPLE?
Obviously I is not an indeterminate

z := a+I*b:
indets(z);

# but

has(z, I)
                             {a, b}
                              true

What does this answer mean:

whattype(I);
                   complex(extended_numeric)

I would have thought that  I was some kind of protected symbol such as Pi, but it's not

attributes(Pi);
attributes(I);
                           protected

In fact, trying to assign 1 to I just returns an error saying this is not legal assignment

I:=1
Error, illegal use of an object as a name

So, what is I in Maple?

Thanks in advance

Dear all,

I have a long Maple code.

After running the code, suppose that we get an error in one of the lines.  I can't simply find the mouse cursor in the line which includes the error.

Question 1: How to find quickly which line has the error? What are your solution methods?

Question 2: Enlarging more or highlighting the cursor mark maybe works. Is it possible?

When i trying to solve the BVP the following error will found 

Error, (in fproc) unable to store 'HFloat(1.0141653815612295)+HFloat(0.0020355870386861838)*I' when datatype=float[8]
 

I have attached my worksheet.

Please anyone help me to get solution to this problem.

Thank you so much

Download Main.mw

 

Hello Maple friends,

I use Explore() often and noticed something today which seems like either a bug or an error on my usage.

I have a long worksheet where I use Explore at one point to show the behavior of an expression relative to one parameter assigned to a slider. Later in the sheet however, I re-assign some of the variables used in that expression and I call Explore again to see how the expression behaves with the different parameters.

The issue is that when I move the slider on the first explore, the result is incorrect because it seems to be using the values of the variables at the end of the worksheet, not the variables at the point the Explore statement exists.

I would expect Explore to make a copy of the stack at the point it gets called such that the result is correct in the context of its location in the worksheet.

Is this the correct behavior and is there a way to make this work as expected? The only workaround I have in mind is to rename the variable names just to make Explore work, which doesn't seem like a great solution.

Thanks.

blessing.mw please i really need your help on this, i have been trying to fix this error for a while now. 

First 336 337 338 339 340 341 342 Last Page 338 of 2097