Maple 2018 Questions and Posts

These are Posts and Questions associated with the product, Maple 2018

Yesterday, I accidentally discovered a nasty bug in a fairly simple example:

restart;
Expr:=a*sin(x)+b*cos(x);
maximize(Expr, x=0..2*Pi);
minimize(Expr, x=0..2*Pi);
                                    

I am sure the correct answers are  sqrt(a^2+b^2)  and  -sqrt(a^2+b^2)  for any real values  a  and  b .  It is easy to prove in many ways. The simplest method does not require any calculations and can be done in the mind. We will consider  Expr  as the scalar product (or the dot product) of two vectors  <a, b>  and  <sin(x), cos(x)>, one of which is a unit vector. Then it is obvious that the maximum of this scalar product is reached if the vectors are codirectional and equals to the length of the first vector, that is, sqrt(a^2+b^2).

Bugs in these commands were noted by users and earlier (see search by keywords bug, maximize, minimize) but unfortunately are still not fixed. 

How I can extract data about figure as matrix format.

I want to save data from figure as matrix for each curve in figure as i.e.,  x and y .

for example as this format.

fig10.mw

sol := Vector[column](4, [` 1001 x 4 `*Matrix, `Data Type: `*anything, `Storage: `*rectangular, `Order: `*Fortran_order])

 

Is it possible to export data from Maple to Excel where data are generated by Maple using Optimization:-LSSolve or DirectSearch:-SolveEquations function?

I have attached a file, where n is the primary variable. For n=1, 2, 3, .......... 20, I have got solution individually. But it is more time consuming event. Is it possible to use array or a vector for the variable n and solve equations at a time for all value of n and stored a excel file?
Any advice for me? @Preben Alsholm , @tomleslie or anybody
system_equations_(10.12.2008).mw
 

Hello,

I cannot find a solution for multiplying matrices containing vectors. I seems that matrix operations are not overloaded for accepting vectors. Here is a minimum example :

restart;
with(LinearAlgebra);
with(VectorCalculus);
A := Matrix([u, v]);
B := Transpose(A) . A;

# Entries of A are in fact vectors
u := `<,>`(u1, u2);
v := `<,>`(v1, v2);

# Here are the expected entries of matrix B

u . u;
v . v;
u . v;

# but entries cannot be calculated
simplify(B);

B := Transpose(A) . A;

Of course I can obtain the result if I construct the matrix A with the components of u and v but  my goal is to manipulate more concise expressions with vectors rather than components. May I find a solution in some other package ?

Would it be a complicated task to develop the missing operators or tell Maple to use the dot operator (for matrices and vector) when performing matrix multiplication ?

Thanks for your insights.

Hi, everytimes I enter anythings, it turn out with Typesetting:-mparsed( bla1bla2, bla1bla2;"_noterminate")

example:

Dear authors,
How to solve this ode problem.

Download link ode.mw

In this problem the boundary condition is

Note: F=g in our problem.

eta approaches N.

Thank you.

 

Hi, I'm investigating an equation of motion, and I'm attempting to plot t against different values of thetabn. I have acquired a list of my data points (in the real domain) of the form [thetabn1, t1], [thetabn2, t2] ... etc. But I am struggling to figure out how to plot it. Using dataplot gives me a graph but it is incorrect. I would like a scatterplot, ideally once I have refined my range of thetabn I would like to be able to join it up with a line to create a nice looking plot. Also any improvements to my method would be appreciated. v[i], thetavn and omegac are set variables and s[n] is my function which I am setting equal to zero, and solving for t.

 

with(RealDomain);
v[i] := 145000;
thetavn := (1/6)*Pi;
omegac := .1;
s[n] := v[i]*cos(thetavn)*(cos(2*thetabn)*tan(thetabn)+sin(2*thetabn)*sin(omegac*t)/omegac);
for thetabn from evalf((1/100)*Pi) by evalf((1/100)*Pi) to evalf(Pi) do assign('result', [op(result), [thetabn, solve(v[i]*cos(thetavn)*(cos(2*thetabn)*tan(thetabn)+sin(2*thetabn)*sin(omegac*t)/omegac) = 0, t)]]) end do;
dataplot(result);

 

hello everyone,

I am trying to optimize expressions symbolically. I need to find out the maximum value possible for an variable, so that the expressoin still have a valid solution.

For Example:

expr:=a-b/b-a^3;  # a=(0,10), b=(0,10)

In this eypression b=a^3 is the only case where undefined solution is possible, for a given interval of variables

This looks fine for simple expression. But in reality there are complex equations to solve with more than 2 varibles.

1) first thing is to find out all values of a variable resulting in undeifined output(or infinite)
2) assign a symbolic value(variable < or > some value) to the variable so that the undefined result can be eliminated.

 I need to optimize the given expression so that it does not have any undefined cases when solving. I understood that when optimizing, there always be a condition on variables(in this case variable max is the condition, maximum value the variable can take). output of an expression is always a real value

OptimizedExpr:=a-b[max]/b[max]-a^3 --> b[max]>a^3 or b[max]<a^3

(it is easy to to say b[max] is not equal to a^3 , also a^3 is the limiting value. In some case it is more resonable to just ignore other part of limiting value. Hence, I would like to optimize using greaterthan or lessthan of limiting value).

I would be very glad to know how I can find Optimized expressions. I tried using the solve function but observed that expressions are equalled to zero and solving. which is completely opposite to what I was looking. I really do not know is there any way to find out undefined cases in expressions and on what varibale at what values.

I tried to explain the situation at my best and I welcome for any suggested edits or furthur information required.

 

Thank you

how I can determied  this integral in figure below or compute area in figure which adressed in the following website?

https://en.m.wikipedia.org/wiki/Spherical_cap

how I can write taylor function for following example.

I want to gain an answer similar to the image result by using taylor function.

tylor.mw
 

P27 := f(x+fNx/`&Delta;x`, y+(`&Delta;y`-fNy)/`&Delta;y`, z+fNz/`&Delta;z`)

f(x+fNy/`&Delta;x`, y+(`&Delta;y`-fNy)/`&Delta;y`, z+fNz/`&Delta;z`)

(1)

with(MultiSeries)

taylor(P27, x = 0)

series(f(fNy/`&Delta;x`, -(-y*`&Delta;y`+fNy-`&Delta;y`)/`&Delta;y`, (z*`&Delta;z`+fNz)/`&Delta;z`)+(D[1](f))(fNy/`&Delta;x`, -(-y*`&Delta;y`+fNy-`&Delta;y`)/`&Delta;y`, (z*`&Delta;z`+fNz)/`&Delta;z`)*x+((1/2)*(D[1, 1](f))(fNy/`&Delta;x`, -(-y*`&Delta;y`+fNy-`&Delta;y`)/`&Delta;y`, (z*`&Delta;z`+fNz)/`&Delta;z`))*x^2+((1/6)*(D[1, 1, 1](f))(fNy/`&Delta;x`, -(-y*`&Delta;y`+fNy-`&Delta;y`)/`&Delta;y`, (z*`&Delta;z`+fNz)/`&Delta;z`))*x^3+((1/24)*(D[1, 1, 1, 1](f))(fNy/`&Delta;x`, -(-y*`&Delta;y`+fNy-`&Delta;y`)/`&Delta;y`, (z*`&Delta;z`+fNz)/`&Delta;z`))*x^4+((1/120)*(D[1, 1, 1, 1, 1](f))(fNy/`&Delta;x`, -(-y*`&Delta;y`+fNy-`&Delta;y`)/`&Delta;y`, (z*`&Delta;z`+fNz)/`&Delta;z`))*x^5+O(x^6),x,6)

(2)

``


Download tylor.mw

 

Hello,

I am trying the following command:

restart; with(IntegrationTools):
simplify(int(f(x), x = 0 .. L*Ts)-Split(int(f(x), x = 0 .. L*Ts), [i*Ts, i = 0 .. L]))

Clearly the output should be 0. However, maple is not able to output the correct result. Any ideas?

 

Executing the entire worksheet several times I obtain random results for Threads:-Seq

restart;

N:=10^3;
f:= (a,b) -> add(evalf(j), j=a..b);

1000

 

proc (a, b) options operator, arrow; add(evalf(j), j = a .. b) end proc

(1)

seq(f(k*N/4+1,(k+1)*N/4), k=0..3);

31375., 93875., 156375., 218875.

(2)

Threads:-Seq(f(k*N/4+1,(k+1)*N/4), k=0..3);

31218.+j, 93875., 156375., 218875.

(3)

Threads:-Seq(f(k*N/4+1,(k+1)*N/4), k=0..3);

31375., 93875., 156375., 218875.

(4)

Threads:-Seq(f(k*N/4+1,(k+1)*N/4), k=0..3);

31900., 94170., 156375., 218875.

(5)

 


Download threads!.mw

Hi,

I would like to ask you a question on the following program. Where does the error come from?

Thank you for your help in advance.

 

som:=0:

for b1 from 10 to 20 by 1 do
for b2 from 1 to 10 by 0.1 do
for alpha from 0.5 to 0.9 by 0.1 do
for beta from 0.1 to 0.4 by 0.1 do
for c from 1 to 1 by 1 do
for f from 1 to 10 by 1 do
for g from 8 to 470 by 1 do
for lambdai from 0.2 to 0.2 by 0.1 do
for lambdaj from 0.2 to 0.2 by 0.1 do
for gammai from 0.4 to 0.4 by 0.1 do
for gammaj from 0.4 to 0.4 by 0.1 do

aiSQ:=(alpha*b1)/(alpha*b2+beta*b2+c);
ajSQ:=(beta*b1)/(alpha*b2+beta*b2+c);
UiSQ:=(1/2)*alpha*b1^2*(alpha^2*b2+2*alpha*beta*b2+c*alpha+beta^2*b2+2*beta*c)/(alpha*b2+beta*b2+c)^2;
UjSQ:=(1/2)*beta*b1^2*(alpha^2*b2+2*alpha*beta*b2+2*c*alpha+beta^2*b2+beta*c)/(alpha*b2+beta*b2+c)^2;
USQ:=(1/2)*b1^2*(alpha+beta)*(alpha*b2+beta*b2+2*c)/(alpha*b2+beta*b2+c)^2;

ai:=(c*b1*alpha+c*p*f+p*f*beta*b2-alpha*b2*p*f)/(c*(alpha*b2+beta*b2+c));
aj:=(-p*f*beta*b2+alpha*b2*p*f+c*beta*b1+c*p*f)/(c*(alpha*b2+beta*b2+c));
aineg:=(-p*f*lambdai*b2*beta+c*b1-c*b1*lambdai+b2*p*f*lambdaj+b2*alpha*p*f*lambdaj-p*f*lambdai*b2+c*b1*alpha-c*p*f*lambdai)/(c*(b2*alpha-b2*lambdai+b2*beta-b2*lambdaj+c+2*b2));
ajneg:=-(b2*alpha*p*f*lambdaj-p*f*lambdai*b2-p*f*lambdai*b2*beta+b2*p*f*lambdaj+c*p*f*lambdaj-c*b1-c*beta*b1+c*lambdaj*b1)/(c*(b2*alpha-b2*lambdai+b2*beta-b2*lambdaj+c+2*b2));
ui:=alpha*(b1*(aineg+ajneg)-(b2/2)*(aineg+ajneg)^2)-(c/2)*aineg^2-p*f*(aineg-ai);
uj:=beta*(b1*(aineg+ajneg)-(b2/2)*(aineg+ajneg)^2)-(c/2)*ajneg^2-p*f*(ajneg-aj);
u:=(b1*(aineg+ajneg)-(b2/2)*(aineg+ajneg)^2)+p*f*(aineg-ai)+p*f*(ajneg-aj);
eqti:=gammai*(u-tj-USQ)-((1-gammai)/(1-lambdai))*(ui-UiSQ);
eqtj:=gammaj*(u-ti-USQ)-((1-gammaj)/(1-lambdaj))*(uj-UjSQ);
solt:=solve({eqti, eqtj}, {ti, tj});
ti:=subs(solt,ti);
tj:=subs(solt,tj);
dai:=diff(ai,p);
daj:=diff(aj,p);
daineg:=diff(aineg,p);
dajneg:=diff(ajneg,p);
dti:=diff(ti,p);
dtj:=diff(tj,p);
eqp:=(b1-b2*(ai+aj))*(dai+daj)-dti-dtj+f*(aineg-ai)+p*f(daineg-dai)+f*(ajneg-aj)+p*f(dajneg-daj)-g*p=0;
p:=solve(eqp,p);

Uip:=alpha*(b1*(ai+aj)-(b2/2)*(ai+aj)^2)-(c/2)*ai^2-p*f*(aineg-ai)+(1-lambdai)*ti;
Ujp:=beta*(b1*(ai+aj)-(b2/2)*(ai+aj)^2)-(c/2)*aj^2-p*f*(ajneg-aj)+(1-lambdaj)*tj;
Up:=(b1*(ai+aj)-(b2/2)*(ai+aj)^2)+p*f*(aineg-ai)+p*f*(ajneg-aj)-((g^2)/2)*p-ti-tj;

CSQ:=b1-b2*(aiSQ+ajSQ);
Cabat:=b1-b2*(ai+aj);
Cneg:=b1-b2*(aineg+ajneg);

if (CSQ>0 and Cabat>0  and Cneg>0 and beta<alpha and p>0 and p<1)
then
print(b1,b2,alpha,beta,c,f,g,lambdai,lambdaj,`aiSQ=`,aiSQ,`ajSQ=`,ajSQ,`UiSQ=`,UiSQ,`UjSQ=`,UjSQ,`USQ=`,USQ,`ai=`,ai,`aj=`,aj,`aineg=`,aineg,`ajneg=`,ajneg,`ti=`,ti,`tj=`,tj,`p=`,p,`Uip=`,Uip,`Ujp=`,Ujp,`Up=`,Up);
som:=som+1;
fi;
od;od;od;od;od;od;od;od;od;od;od;
som;

10, 1, 0.5, 0.1, 1, 1, 8, 0.2, 0.2, aiSQ=, 3.12500000000000, ajSQ=, 

  0.625000000000000, UiSQ=, 10.3515625000000, UjSQ=, 2.85156250000000, USQ=, 

  30.4687500000000, ai=, 3.14314584993738, aj=, 0.667340316520551, aineg=, 

  4.06068541500626, ajneg=, 2.80826596834794, ti=, 19.2559726892491, tj=, 

  7.44890809994178, p=, 0.0483889331663441, Uip=, 25.8431760998162, Ujp=, 

  8.71735374786572, Up=, 2.73962847065372
Error, (in solve) a constant is invalid as a variable, 7.44890809994178, 19.2559726892491
                                      1

is possible to solve this pde via maple?

m1.mwm1.mw
 

restart

sys := [-(-r^2+1)*(diff(theta(r, z), z))+(diff(theta(r, z), r)+r*(diff(theta(r, z), r, r)))/r+diff(theta(r, z), z, z)+(diff(theta(r, z), r))*(diff(sigma(r, z), r))+(diff(sigma(r, z), z))*(diff(theta(r, z), z))+(diff(theta(r, z), r))^2+(diff(theta(r, z), z))^2 = 0, -(-r^2+1)*(diff(sigma(r, z), z))+(diff(sigma(r, z), r)+r*(diff(sigma(r, z), r, r)))/r+diff(sigma(r, z), z, z)+(diff(theta(r, z), r)+r*(diff(theta(r, z), r, r)))/r+diff(theta(r, z), z, z) = 0]; IBCs := {sigma(1, z) = 1, sigma(r, 0) = 1, theta(1, z) = 1, theta(r, 0) = 1, (D[1](sigma))(0, z) = 0, (D[1](theta))(0, z) = 0, (D[2](sigma))(r, 1) = 0, (D[2](theta))(r, 1) = 0}

[-(-r^2+1)*(diff(theta(r, z), z))+(diff(theta(r, z), r)+r*(diff(diff(theta(r, z), r), r)))/r+diff(diff(theta(r, z), z), z)+(diff(theta(r, z), r))*(diff(sigma(r, z), r))+(diff(sigma(r, z), z))*(diff(theta(r, z), z))+(diff(theta(r, z), r))^2+(diff(theta(r, z), z))^2 = 0, -(-r^2+1)*(diff(sigma(r, z), z))+(diff(sigma(r, z), r)+r*(diff(diff(sigma(r, z), r), r)))/r+diff(diff(sigma(r, z), z), z)+(diff(theta(r, z), r)+r*(diff(diff(theta(r, z), r), r)))/r+diff(diff(theta(r, z), z), z) = 0]

 

{sigma(1, z) = 1, sigma(r, 0) = 1, theta(1, z) = 1, theta(r, 0) = 1, (D[1](sigma))(0, z) = 0, (D[1](theta))(0, z) = 0, (D[2](sigma))(r, 1) = 0, (D[2](theta))(r, 1) = 0}

(1)

NULL


 

Download m1.mw

 

 

This is a Wave PDE inside disk. with fixed edge of disk,  and no theta dependency. initial position and velocity  given.

When using "c^2" for the  wave propagation speed, Maple only gives solution when also using assumptions to tell that c is positive.

restart; 
Physics:-Version()[2]; 
`2018, November 28, 1:35 hours, version in the MapleCloud: 224, version installed in this computer: 224`

And the PDE is 

pde := diff(u(r, t), t$2) = c^2*( diff(u(r,t), r$2)  + (1/r)* diff(u(r,t),r)  ) ; 
ic:=u(r,0)=1, eval( diff(u(r,t),t),t=0)=r/3; 
bc:=u(1,t)=0; 
sol:=pdsolve([pde, ic,bc], u(r, t)) assuming t>0;

sol:=()

Now adding assuming c>0, or "c::positive", or "c>=0", it solves it 

restart;
pde := diff(u(r, t), t$2) = c^2*( diff(u(r,t), r$2)  + (1/r)* diff(u(r,t),r)  ) ; 
ic:=u(r,0)=1, eval( diff(u(r,t),t),t=0)=r/3; 
bc:=u(1,t)=0; 
sol:=pdsolve([pde, ic,bc], u(r, t)) assuming t>0,c>=0;

Any idea why the assumption "c>0"  is needed when the speed is given as "c^2" ? I also tried assumption "c::real", but it still did not solve it.   It seems related to Maple using Laplace transform to solve it.

It seems to me the assumption c>0 should not needed here. But if it is, I'd like to learn why.

Maple 2018.2, windows 10

Update

Thanks to comment below

   " so u(r, 0)=1 (for all r), and u(1, t)=0 (for all t). So what is u(1,0)??? "

I should have added "r>0,r<1".  The reason I did not, is that I copied the code to solve this from Mathematica. In Mathematica, it did not need this assumption to solve it. It seems to depend on the method of solution used by Mathematica vs. Maple to cause this difference.

But now I see it helps to have it there. With the above assumption, now, there is no need to do any assumption on "c" at all and it gives solution. adding c>0 or t>0 or c>=0, makes no change now.

restart;
pde := diff(u(r, t), t$2) = c^2*( diff(u(r,t), r$2)  + (1/r)* diff(u(r,t),r)  ) ; 
ic:=u(r,0)=1, eval( diff(u(r,t),t),t=0)=r/3; 
bc:=u(1,t)=0; 
sol:=pdsolve([pde, ic,bc], u(r, t)) assuming t>0,r>0,r<1;

 

 

First 38 39 40 41 42 43 44 Last Page 40 of 62