MaplePrimes Questions

I was experimenting on and found coeff and degrees  do not work with algebraic type powers. So I set aboud dismanteling  a example polynomial. I certainly went around the houses doing this. I wanted to put the powers and coefficinets of x in an array.

I sure there must be a simpler way.

restart

NULLNULL

r := proc (x) options operator, arrow; a[0]+a[1]*x-a[2]*x^2+a[8]*x^(8/5)-a[h]*x^h+k*x^(-b/a) end proc

proc (x) options operator, arrow; a[0]+a[1]*x-a[2]*x^2+a[8]*x^(8/5)-a[h]*x^h+k*x^(-b/a) end proc

mnmls := [op(r(x))]

[a[0], a[1]*x, -a[2]*x^2, a[8]*x^(8/5), -a[h]*x^h, k*x^(-b/a)]

A := Array(1 .. 2, 1 .. nops(mnmls))

Array(%id = 36893489621187187044)

mnmls, x0 := selectremove(has, mnmls, x)

[a[1]*x, -a[2]*x^2, a[8]*x^(8/5), -a[h]*x^h, k*x^(-b/a)], [a[0]]

NULL

A[2, 1] := op(x0)

a[0]

coeff(r(x), x, 2)

Error, unable to compute coeff

coeffs(r(x), x)

Error, invalid arguments to coeffs

degree(mnmls[1], x)

1

degree(mnmls[4], x)

FAIL

degree(mnmls[5], x)

FAIL

indets(r(x))

{a, b, h, k, x, a[0], a[1], a[2], a[8], a[h], x^h, x^(-b/a), x^(8/5)}

bits := [seq([op(mnmls[i])], i = 1 .. nops(mnmls))]

[[a[1], x], [-1, a[2], x^2], [a[8], x^(8/5)], [-1, a[h], x^h], [k, x^(-b/a)]]

deeperbits := [seq(op(op(bits)[i]), i = 1 .. nops(bits))]

[a[1], x, -1, a[2], x^2, a[8], x^(8/5), -1, a[h], x^h, k, x^(-b/a)]

varpwrs, cofsl := selectremove(has, deeperbits, x)

[x, x^2, x^(8/5), x^h, x^(-b/a)], [a[1], -1, a[2], a[8], -1, a[h], k]

is(nops(vars) = nops(cofsl))

false

cofs := convert(cofsl, Array)

Array(%id = 36893489621220545228)

for i to numelems(cofs)-1 do if cofs[i] = -1 then cofs[i] := 0; cofs[i+1] := -cofs[i+1]; i = i+2 end if end do; cofs; cofs := remove[flatten](has, cofs, 0)

Array(%id = 36893489621220530764)

cofs

Array(%id = 36893489621220530764)

is(nops(vars) = numelems(cofs))

false

NULL

pwrs := `assuming`([simplify(`~`[log[x]](varpwrs))], [x > 0, a::'real', b::'real', h::'real'])

[1, 2, 8/5, h, -b/a]

A

Array(%id = 36893489621187187044)

for i to nops(mnmls) do A[1, i+1] := pwrs[i]; A[2, i+1] := cofs[i] end do; A

Array(%id = 36893489621187187044)

 

NULL


Download Q_11-9-22_monomial_powers_and_coeffs.mw

restart;

pde := diff(u(x,t),t) + u(x,t)*diff(u(x,t),x) = 0;

diff(u(x, t), t)+u(x, t)*(diff(u(x, t), x)) = 0

These are all wrong:

pdsolve({pde,u(x,0)=f(x)});
pdsolve({pde,u(x,0)=sin(x)});
pdsolve({pde,u(x,0)=erf(x)});

u(x, t) = 0

u(x, t) = 0

u(x, t) = 0

But these ones are correct:

pdsolve({pde,u(x,0)=exp(x)});
pdsolve({pde,u(x,0)=x});

u(x, t) = LambertW(t*exp(x))/t

u(x, t) = x/(t+1)

Download mw.mw

in a worksheet, typing

r:=(x^2 - 2*x - 1)/4;

Maple returns

But when typing

r:=(x^2 - 2*x - 1)/(4*x);

Now it does not expand terms and gives what is expected

Is there a way to make the first example remain unexpanded? Same with Mathematica:

I know this only affects the display only. But it is annoying, as I want to see the numerator and denominator on the screen as I put them there and not have them change.

I tried changing the typesetting level, but this had no effect.

I used to like Maple becuase it does not change anything unless asked to, and everything is explicit, which is better.

Now I am starting to change my mind on this aspect of Maple.

Hello. Is there any way to plot 2+ oscillators as shown in the image below?

Thanks for any help.

Hi,

Newbie here....

I'm struggling to see with the default font size, I'm also struggling with readability of the text/charactors in the left hand paletetes/workbook pull down menus.  I can see that there are style choice options in format>styles but it seems that I need to set every single permutation separately to acheive readability nirvana which seems unlikely to be the best route.

Is there a global setting for font size?  Alternatively are there style files somewhere that the nearly blind can download?

I am really struggling with this.

Cheers

Please, how do I use surface or contour to plot discontinous function?

z = f(x,y) := x-.8193318913*sin(x)*cos(x)/(cos(x)^2+sinh(y)^2)-(0.2931044702e-2*(0.7500000000e-3*x^2-0.7500000000e-3*y^2+0.1622336517e-1))*sin(x)*cos(x)/(((0.7500000000e-3*x^2-0.7500000000e-3*y^2+0.1622336517e-1)^2+0.2250000000e-5*x^2*y^2)*(cos(x)^2+sinh(y)^2))-0.4396567053e-5*x*y*sinh(y)*cosh(y)/(((0.7500000000e-3*x^2-0.7500000000e-3*y^2+0.1622336517e-1)^2+0.2250000000e-5*x^2*y^2)*(cos(x)^2+sinh(y)^2)):

How should I handle the limit in the integration answe?. I don't see why it is necessary.

restart

_local(gamma)

p := `assuming`([proc (alpha) options operator, arrow; alpha^m end proc], [m]); LinearAlgebra:-Transpose(integer)

integer

q := `assuming`([proc (alpha) options operator, arrow; alpha^n end proc], [n]); LinearAlgebra:-Transpose(integer)

integer

Sa := eval((1/2)*(int(simplify(p(alpha)*(D(q))(alpha)), alpha = 0 .. 1)))

-(1/2)*(limit(alpha^(m+n), alpha = 0, right)-1)*n/(m+n)

s1 := eval((1/2)*(int(simplify(p(alpha)*(D(q))(alpha)), alpha)))

(1/2)*alpha^(m+n)*n/(m+n)

eval(s1, alpha = 1)-(eval(s1, alpha = 0))

(1/2)*n/(m+n)

NULL

Download Q_9-9-22_limit_in_integral.mw

What is the best and accurate way to export a large symbolic matrix (200*300) from Maple to Matlab? The Marix have a lot of variables, symbols and operators such as diiff, int, ....

Here is a simple example:

NULL

restart

NULL

A := Matrix(2, 6, {(1, 1) = x*y*z, (1, 2) = (1/2)*tau[2], (1, 3) = sin(x*y*z), (1, 4) = ln(x*y*z), (1, 5) = tau[1]*exp(x*y*z), (1, 6) = sin(x+y)+cos(x+y), (2, 1) = x^2+1, (2, 2) = x^2+1/sin(x*y*z), (2, 3) = 2*exp(y), (2, 4) = tau[1], (2, 5) = diff(f(x, y, z), x), (2, 6) = int(f(x, y, z), x)})

A := 1/sin(protected)

(1)

``

CodeGeneration[Matlab](codegen[makeproc](A, [x, y, tau[1], tau[2]]))

Error, (in codegen/makeproc) optional arguments must be equations [x, y, tau[1], tau[2]]

 

``

``

``

``

``

``

Download export.mw

I would appreciate any recommendation on these games and puzzles with maple implementation. The purpose is to inspire the math interest of children (say 16-) . Benefits from the assistance of Maple:

1. Learn and build the habit of math modelling: eg by playing with this n-queen problem - https://www.maplesoft.com/Applications/Detail.aspx?id=154482

Children can realize that, for many problems, modelling is doable for them - question formation in math/programming and finding all the constraints - while solution method is simply a small step if done by computer. This is already a big step forward for them and they may enjoy the modelling process. For more math-eager kids, they may start to explore the documentation behind the solution methods.

2. Learn the art of automatic proof by witnessing the efficiency gain by themselves - I don't think I have to explain such to the community here. I note Doron Zeilberger has collected many in such a spirit on his website.

I have read some in the Application Center (eg under the tag game) and by searching here by the "puzzle". Is there some more systematic collection/books? The applications I have seen is mostly on logical/combinatorial problems. Love to see the games/puzzles under a broader range of math fields good for children.

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

Is there an assumption or some other way I can tell Maple to avoid such errors when using odetest, as I get many of them.

I think the solution Maple gives is correct. But odetest generates these strange innternal error that it does not know the sign of a complex number.

restart;
ode:=x^2*diff(y(x), x$2) + (cos(x)-1)*diff(y(x), x) + exp(x)*y(x) = 0;
sol:=dsolve(ode,y(x),series):
odetest(sol,ode,series,point=0);

Error, (in odetest/series) need to determine the sign of I*3^(1/2)

I've seen such error many times before and it is still not fixed in release after release.

I am using Maple 2022.1 on windows 10.

To make the "Simple External Code Function" example of the tutorial work, an external complier is required.

in MapleSim:-CreateDataRecord) invalid input: dsolve/numeric/ToExternal:-AddTempFile expects its 1st argument, f, to be of type string, but received [[["f1", 1864151924736]]] (3.597s)

Update:

help(Setup, Compiler) in Maple 2022 provides a link to supported compilers, which are Visual Studio 2017 and 2019.

In the list of available downloads there is no mention of "Express Edition". Which of the packages can be installed alternatively?

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

Hi, 

Please how I do plot: theta := -(65.7014900075861*(cos(-4.536529763+45365.29764*z)+.1749541674))*exp(-1.603200636*t) for z=0..d.

I tried this: 

display(plot([seq(subs(t = i, theta), i = [seq(0.1*ii, ii = 1 .. 7)])], z = 0 .. d));

But I want this sequence: [seq(subs(t = i, theta), i = [seq(0.1*ii, ii = 1 .. 7)])] to include Pi/2 such that t_0 = Pi/2 in the plot. I.e., I want the Pi/2 to be the initial value in the sequence.

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

First 62 63 64 65 66 67 68 Last Page 64 of 2211