mmcdara

6740 Reputation

18 Badges

8 years, 191 days

MaplePrimes Activity


These are questions asked by mmcdara


Using plot3d(..., style=surfacecontour, ...) or contourplot3d(...) displays wrong level curves when some axis are switched to a log mode.

Example:

restart:

interface(version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

X := (0.4000000000e-4*(-R+80.00))/(R*(0.4e-1+M__a)):

plot3d(X, R=0..10, M__a=10^0..10^4, style=surfacecontour, color=gold)

 

plot3d(X, R=0..10, M__a=10^0..10^4, axis[2]=[mode=log], axis[3]=[mode=log], style=surfacecontour, color=gold)

 

plots:-display(
  plots:-contourplot3d(X, R=0..10, M__a=10^0..10^4, axis[2]=[mode=log], axis[3]=[mode=log], color=red),
  plot3d(X, R=0..10, M__a=10^0..10^4, style=surface, color=gold)
)

 

 

Download WrongLevelCurves.mw

 

The problem is not dramatic because there is a workaround.
 

restart:

interface(version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

X := (0.4000000000e-4*(-R+80.00))/(R*(0.4e-1+M__a)):

fig := plot3d(X, R=0..10, M__a=10^0..10^4, style=surfacecontour, color=gold):
Tr  := plottools:-transform((x, y, z) -> [x, log[10](y), log[10](z)]):
plots:-display(Tr(fig), axis[2]=[tickmarks=[seq(i=10^i, i=0..4)]], axis[3]=[tickmarks=[seq(i=nprintf("%1.0e", 10.^i), i=-7..-1)]])

 

 

Download WrongLevelCurves_Workaround.mw

 

Even though this question is related to this one 
https://www.mapleprimes.com/questions/234781-How-Can-I-Get-The-Desired-Answer-From-solve
feel it is about a different issue. If any of you feel otherwise feel free to move it to the original one.

In this notional example  the name _Z1~ is created by RootOf: and here is an ad hoc way to catch it.

restart:

f := RootOf(cos(x)-z, x):
u := indets(f, name);
s := series(f, z):
v := remove(type, indets(s, name), constant);
w := v minus u

{z}

 

{_Z1, z}

 

{_Z1}

(1)

 

Download Example_1.mw

In this more complex example an assumption must be made on M to obtain ths desired solution g and the previous method no longer works.

restart

f := 10*cos((-1+t)/sqrt(1+M))-10*cos(t/sqrt(1+M)):
assume(M::nonnegative):
u := indets(f, name);
g := solve({diff(f, t), t>0 }, t, allsolutions)[1][1];
v := remove(type, indets(rhs(g), name), constant);
w := v minus u

{M, t}

 

t = Pi*_Z2*(1+M)^(1/2)-arctan((cos(1/(1+M)^(1/2))+1)/sin(1/(1+M)^(1/2)))*(1+M)^(1/2)

 

{M, _Z2}

 

{M, _Z2}

(1)

 

Download Example_2.mw

I have tried using select to "capture" the name _Z2~ but I can't know how to distinguish M~ from _Z2~ (is there a type which could be used?).

Can you helpm fix this?
TIA

I don't understand why the solution of sys_2 isn't those of sys_1 when M__p=1 and M__a=0 ?

Traces of the computation seem to indicate that dsolve proceeds exactly the same for sys_2 and sys_1 .

Please note that sol_1 contains a term of the form t*cos(t) that sol_2 doesn't, thus the question: "Is sol_2 correct?"

Could you help me to fix this?
TIA

restart

infolevel[dsolve] := 4;

4

(1)

sys_1 := {diff(x(t), t$2)=sin(t)-x(t), x(0)=0, D(x)(0)=0};
sol_1 := dsolve(sys_1)

{diff(diff(x(t), t), t) = sin(t)-x(t), x(0) = 0, (D(x))(0) = 0}

 

Methods for second order ODEs:
--- Trying classification methods ---
trying a quadrature
trying high order exact linear fully integrable
trying differential order: 2; linear nonhomogeneous with symmetry [0,1]
trying a double symmetry of the form [xi=0, eta=F(x)]
-> Try solving first the homogeneous part of the ODE
   checking if the LODE has constant coefficients
   <- constant coefficients successful
   -> Determining now a particular solution to the non-homogeneous ODE
      building a particular solution using variation of parameters
<- solving first the homogeneous part of the ODE successful

 

x(t) = (1/2)*sin(t)-(1/2)*cos(t)*t

(2)

sys_2 := {(M__p+M__a)*diff(x(t), t$2)=M__p*sin(t)-x(t), x(0)=0, D(x)(0)=0};
sol_2 := dsolve(sys_2)

{(M__p+M__a)*(diff(diff(x(t), t), t)) = M__p*sin(t)-x(t), x(0) = 0, (D(x))(0) = 0}

 

Methods for second order ODEs:
--- Trying classification methods ---
trying a quadrature
trying high order exact linear fully integrable
trying differential order: 2; linear nonhomogeneous with symmetry [0,1]
trying a double symmetry of the form [xi=0, eta=F(x)]
-> Try solving first the homogeneous part of the ODE
   checking if the LODE has constant coefficients
   <- constant coefficients successful
   -> Determining now a particular solution to the non-homogeneous ODE
      building a particular solution using variation of parameters
<- solving first the homogeneous part of the ODE successful

 

x(t) = sin(t/(M__p+M__a)^(1/2))*M__p*(M__p+M__a)^(1/2)/(M__p+M__a-1)-M__p*sin(t)/(M__p+M__a-1)

(3)

eval(sol_2, [M__p=1, M__a=0])

Error, numeric exception: division by zero

 

 

Download SomethingWrong.mw

PS: Already, in the following case, dsolve doesn't return the solution of sys_1.

sys_3 := {(A+B)*diff(x(t), t$2)=(A+B)*sin(t)-x(t), x(0)=0, D(x)(0)=0};
sol_3 := dsolve(sys_3)

If I do this

sys_4 := {(A+B)*diff(v(t), t)=(A+B)*sin(t)-x(t), diff(x(t), t)=v(t), x(0)=0, v(0)=0}:
sol_4 := dsolve(sys_4)

I get a very complex solution wich contains a piecewise function which separates the cases A+B=1 and A+B<>1.
Evaluating sol_4 for A+B=1 gives the same expression than sys_1:

simplify(eval(sol_4, A=1-B), trig)
       /       1                  1          1         \ 
      { v(t) = - sin(t) t, x(t) = - sin(t) - - cos(t) t }
       \       2                  2          2         / 

Here is a workaround to get the correct solution of sys_2:

sys_5 := {(M__P+M__A)*diff(v(t), t)=(M__P+C)*sin(t)-x(t), diff(x(t), t)=v(t), x(0)=0, v(0)=0}:
sol_5 := dsolve(sys_5):
simplify(eval(sol_5, [M__P=1, M__A=0, C=0]), trig)
       /       1                  1          1         \ 
      { v(t) = - sin(t) t, x(t) = - sin(t) - - cos(t) t }
       \       2                  2          2         / 

e

I compute the solution of this differential system

shock := piecewise(t <0, 0, t < 1, 10, 0):
sys   := {(M__p+M__a)*diff(x(t), t$2)=M__p*shock-x(t), x(0)=0, D(x)(0)=0}
sol   := unapply(rhs(dsolve(sys)), (M__p,M__a))

I'm interested in 3 quantities:

  • the first time tend > 0 such that sol(tend) = 0,
  • the time tmax in (0..tend) where sol(tmax) reaches its maximum value,
  • the value xmax = sol(tmax).

Since sol has a relatively simple expression, I first attempted to use solve for calculating tend, but that didn't work.
The conclusion is still the same for tmax and xmax.

The values of these 3 quantities that I expect solve to provide, are those obtained using fsolve.

Can you explain me the failures I faced and show me how to force solve to get these values?
TIA

ToyProblem.mw

Given this "pattern" to transfporm an expression into an arrow procedure

e := 1/b:
f := unapply(e, b):
f(3)
                               1
                               -
                               3

I would like now to use this same "pattern" to transform an expression e which depends on 2 indeterminates a and b into a "double layered arrow procedure" f.
Here is a notional example

e := a/b:
f := unapply(unapply(e, b), a);
                     a
           a -> b -> -
                     b

 f(A)(B)
                              a  
                              -
                              B  

How can I proceed in order that f(A)(B) gives A/B ?

TIA

First 10 11 12 13 14 15 16 Last Page 12 of 44