Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I have a list of sample values and I want to remove just one maybe two of them. 

list:=[13,16,16,29,34,33,33,12,22,26,25,25,25,11]:

How could I remove just one 25 from the list? 

I have a two graphics in two distinct Maple worksheets. How can I graph them on one graphic?

 

For example, 

 graphics of y=x^2 in one Maple worksheet named document 1, 

and graphics of y=x in an other Maple worksheet named document 2.

I want to graphics of them in document 1 by recalling the graphics of y=x in document 2.

Because, The codes that I will use in future are very long and complex, I need to write code like that. (if there is possibility) 

Suppose we have some simple animations. Our goal - to build a more complex animation, combining the original animations in different ways.
We show how to do it on the example of the three animations. The technique is general and can be applied to any number of animations.

Here are the three simple animations:

restart;
with(plots):
A:=animate(plot, [sin(x), x=-Pi..a, color=red, thickness=3], a=-Pi..Pi):
B:=animate(plot, [x^2-1, x=-2..a, thickness=3, color=green], a=-2..2): 
C:=animate(plot, [[4*cos(t),4*sin(t), t=0..a], color=blue, thickness=3], a=0..2*Pi):

 

In Example 1 all three animation executed simultaneously:

display([A, B, C], view=[-4..4,-4..4]);

                                

 

In Example 2, the same animation performed sequentially. Note that the previous animation disappears completely when the next one begins to execute:

display([A, B, C], insequence);

                                 

 

Below we show how to save the last frame of every previous animation into subsequent animations:

display([A, display(op([1,-1,1],A),B), display(op([1,-1,1],A),op([1,-1,1],B),C)], insequence);

                                 

 

Using this technique, we can anyhow combine the original animations. For example, in the following example at firstly animations   and  B  are executed simultaneously, afterwards C is executed:

display([display(A, B), display(op([1,-1,1],A),op([1,-1,1],B),C)], insequence);

                                     

 

The last example in 3D I have taken from here:

restart;
with(plots):
A:=animate(plot3d,[[2*cos(phi),2*sin(phi),z], z =0..a, phi=0..2*Pi, style=surface, color=red], a=0..5):
B:=animate(plot3d,[[(2+6/5*(z-5))*cos(phi), (2+6/5*(z-5))*sin(phi),z], z=5..a, phi=0..2*Pi, style=surface, color=blue], a=5..10):
C:=animate(plot3d,[[8*cos(phi),8*sin(phi),z], z =10..a, phi=0..2*Pi, style=surface, color=green], a=10..20):
display([A, display(op([1,-1,1],A),B), display(op([1,-1,1],A),op([1,-1,1],B),C)], insequence, scaling=constrained, axes=normal);

                        


 

AA.mw

Hello guys,

I have some system of differential equations,

How can i find  eigenvalues of this system?

If i have solution

res := evalf(dsolve(sys union ics, convert(x, list), type = numeric, method = rkf45))

and

sol := evalf(dsolve(sys union ics, convert(x, list), method = laplace))

AnSolution.mw

Thanks!

I am maple newbie. Sometimes when I look at Maple code to try to understand the algorithm (which is hard, since I do not know Maple well), I see the code puts ` ` around some keywords. And sometimes it does not. For example, sometimes I see something like (these are random samples) from Maple code shown using showstat()

return `if`(assigned(r),r,{})
r := `union`(r,{solve(op(1,expr) = 1,vs)})
v2 := `intersect`(vs,indets(op(1,expr),'name'));

But sometimes, they do not put ` ` around functions name or keywords, like this:

if nops(v2) = 1 then
t1 := remove(a -> has(a,RootOf),t1);
for t in expr do

and so on.

Can some expert please give what is the rule thumb to use? Should user adopt this method also? When to put ` ` and when not to put ` `?   I understand that ` ` prevents one-time evaluation (or rather, holds off immediate evaluation) and ``  `` prevents two times evaluation and so on. But when to use ` ` is what is confusing me.

 

Hello,

I was wondering if it is possible to use units in Maple so I can always check if the result I have at the end of calculation is the meter.  For example:

>c:=3e8m/s
>Ec:=1J
>Ec*c

The answer is of course 3.10^8 m^3*kg/s^3

I try to do something with the units but I am unable to crreate something that will simplify the m/s ffactor to 1.

Any idea?

Thank you in advance for your help.

 

how to convert a nested for loop to iterative version with stack

I have recently been working on a problem using fractional calculus and have come across something in Maple's fracdiff  command that makes no sense to me.

fracdiff(1, x, 1/2) = 0

It should be:     1/(sqrt(x)*sqrt(Pi))

Thanks.

fracdiff.mw

I solved this (aq1) equation and got a set of answers, but when I want to solve another equation (aq) that is like (aq1)  it took a long time and I stopped progressing.

aq1 := -6.801867*10^(-32)*omega^16+(2.20054799*10^(-46)*I)*omega^23+(6.14329398*10^(-52)*I)*omega^25+(1.*10^(-11)*I)*omega^3+(2.*10^(-14)*I)*omega^5+(9.*10^(-10)*I)*omega+(2.*10^(-25)*I)*omega^11+5.95367451*10^(-12)*omega^8-2.10490578*10^(-16)*omega^10+3.6487095*10^(-21)*omega^12-3.4507372*10^(-26)*omega^14-4.53641375*10^(-54)*omega^26-1.844174702*10^(-48)*omega^24-.2318547310*omega^2+0.2767383695e-3*omega^4+15.23320543-2.607001427*10^(-43)*omega^22-1.252442537*10^(-38)*omega^20-1.58024603*10^(-34)*omega^18-(4.8*10^(-28)*I)*omega^13+(2.68604*10^(-29)*I)*omega^15+(1.4639509*10^(-32)*I)*omega^17+(1.21776770*10^(-36)*I)*omega^19+(2.77270182*10^(-41)*I)*omega^21-7.070170160*10^(-8)*omega^6

sd1 := solve(aq1)

aq := (2.626145*10^(-111)*I)*beta^41+(2.723460372*10^(-55)*I)*beta^25-1.125718*10^(-103)*beta^38-4.42696*10^(-96)*beta^36+(4.038976*10^(-119)*I)*beta^43+(1.897840*10^(-135)*I)*beta^47-1.4537*10^(-128)*beta^44-2.393897*10^(-75)*beta^30-5.345113*10^(-69)*beta^28-(8.88232*10^(-14)*I)*beta^7+(3.78162*10^(-127)*I)*beta^45+(1.87236321*10^(-39)*I)*beta^19-4.22943*10^(-111)*beta^40-5.98764*10^(-82)*beta^32+(1.73215*10^(-27)*I)*beta^13+(3.14576*10^(-144)*I)*beta^49+1.0000002*10^(-150)*beta^50+1.000483*10^(-142)*beta^48+(0.5707492e-4*I)*beta-1.860356732*10^(-56)*beta^26-1.202764308*10^(-50)*beta^24+0.1078870970e-3*beta^4-.1337634356*beta^2+(4.558807*10^(-82)*I)*beta^33+11.99907662+(1.552482870*10^(-49)*I)*beta^23+1.50289073*10^(-33)*beta^16+(4.738072*10^(-89)*I)*beta^35-2.560992731*10^(-45)*beta^22-1.821396189*10^(-40)*beta^20+1.*10^(-159)*beta^52-1.025045*10^(-118)*beta^42-2.708307310*10^(-27)*beta^14-2.880*10^(-137)*beta^46+3.616579272*10^(-22)*beta^12-2.775313578*10^(-17)*beta^10+(2.247453*10^(-75)*I)*beta^31+(4.317773*10^(-69)*I)*beta^29-(8.4742656*10^(-63)*I)*beta^27+(1.086756*10^(-103)*I)*beta^39+(2.875650*10^(-96)*I)*beta^37+(2.927689932*10^(-44)*I)*beta^21+(5.19084*10^(-18)*I)*beta^9+(3.3203077*10^(-35)*I)*beta^17-1.867365177*10^(-8)*beta^6+1.091287414*10^(-12)*beta^8-3.549248092*10^(-36)*beta^18-6.89128*10^(-89)*beta^34-(1.32011*10^(-22)*I)*beta^11+(8.67973*10^(-32)*I)*beta^15+(5.131768*10^(-10)*I)*beta^5-(6.362604*10^(-7)*I)*beta^3-(5.75387*10^(-153)*I)*beta^51

How can I solve (aq) ?

The writings in the variables palettes are overlapped. Is there any solution suggestion?

 

The first half of this work sheet deals with SHM of pendulum. In the second half of the work sheet I attempt to solve for the general case of a swinging pendulum. Maple introduces a place holder (correct me if I have used the incorrect termonology) " __a" which I do not understand. What variable(s) should I replace it with and is there an automatic way of doing so?
 

restart

NULL

``

``

Simple*Harmonic*Motion*of*a*Pendulum

NULL

Eq1 := diff(Theta(t), t, t) = -omega^2*Theta(t)

diff(diff(Theta(t), t), t) = -omega^2*Theta(t)

(1)

ics := Theta(0) = 0, (D(Theta))(0) = Vmax

Theta(0) = 0, (D(Theta))(0) = Vmax

(2)

SHM := dsolve({Eq1, ics})

Theta(t) = Vmax*sin(omega*t)/omega

(3)

diffSHM := diff(SHM, t)

diff(Theta(t), t) = Vmax*cos(omega*t)

(4)

convert(diffSHM, D)

(D(Theta))(t) = Vmax*cos(omega*t)

(5)

eval[recurse](%, {t = 0, (D(Theta))(0) = Vmax})

Vmax = Vmax

(6)

solve(%, {_C1})

{_C1 = _C1}

(7)

assign(%); _C1

_C1

(8)

``

SHM

Theta(t) = Vmax*sin(omega*t)/omega

(9)

``

(General*Equation*of*Motion*of)*a*Pendulum

restart

diff(Theta(t), t, t) = -omega^2*sin(Theta(t))

diff(diff(Theta(t), t), t) = -omega^2*sin(Theta(t))

(10)

ics := Theta(0) = 0, (D(Theta))(0) = Vmax

Theta(0) = 0, (D(Theta))(0) = Vmax

(11)

Sol := dsolve(diff(Theta(t), t, t) = -omega^2*sin(Theta(t)))

Intat(1/(2*omega^2*cos(_a)+_C1)^(1/2), _a = Theta(t))-t-_C2 = 0, Intat(-1/(2*omega^2*cos(_a)+_C1)^(1/2), _a = Theta(t))-t-_C2 = 0

(12)

Sol[1]

Intat(1/(2*omega^2*cos(_a)+_C1)^(1/2), _a = Theta(t))-t-_C2 = 0

(13)

_C2 := 0

0

(14)

Sol[1]

Intat(1/(2*omega^2*cos(_a)+_C1)^(1/2), _a = Theta(t))-t = 0

(15)

``

dffSol[1] := diff(Sol[1], t)

(diff(Theta(t), t))/(2*omega^2*cos(Theta(t))+_C1)^(1/2)-1 = 0

(16)

``convert(dffSol[1], D)

(D(Theta))(t)/(2*omega^2*cos(Theta(t))+_C1)^(1/2)-1 = 0

(17)

 

eval[recurse](%, {t = 0, Theta(0) = 0, (D(Theta))(0) = Vmax})

Vmax/(2*omega^2+_C1)^(1/2)-1 = 0

(18)

solve(%, {_C1})

{_C1 = Vmax^2-2*omega^2}

(19)

assign(%); 1; _C1

Vmax^2-2*omega^2

(20)

dffSol[1]

(diff(Theta(t), t))/(2*omega^2*cos(Theta(t))+Vmax^2-2*omega^2)^(1/2)-1 = 0

(21)

``

dsolve(dffSol[1]); 1; SOL1 := int((diff(Theta(t), t))/sqrt(2*omega^2*cos(Theta(t))+Vmax^2-2*omega^2)-1, t = 0 .. Theta(t)) = 0

int((diff(Theta(t), t))/(2*omega^2*cos(Theta(t))+Vmax^2-2*omega^2)^(1/2)-1, t = 0 .. Theta(t)) = 0

(22)

Sol[1]

Intat(1/(2*omega^2*cos(_a)+Vmax^2-2*omega^2)^(1/2), _a = Theta(t))-t = 0

(23)

"Using  ( 1-cos(theta))/(2)=sin(theta/(2))^(2)and substituting by hand"

NotsoSHM := Intat(1/(Vmax*sqrt(1-2*omega^2*sin((1/2)*_a)^2/Vmax^2)), _a = (1/2)*Theta(t))-t = 0

Intat(1/(Vmax*(1-2*omega^2*sin((1/2)*_a)^2/Vmax^2)^(1/2)), _a = (1/2)*Theta(t))-t = 0

(24)

``

``


 

Download SHM_and_not_so_SHM.mw

Hi All,

I have problem how to formulate optimization problem with additional parameters.
For example let objective function is as follow:

ObjF:=proc(x,Delta)
    return sin(x) + cos(x) + Delta;
end proc;

In Matlab we can formulate the following optimization problem:

Delta = 10;
f=@(x)ObjF(x,Delta);
options = optimset('Algorithm','interior-point');
x = fmincon(f,0.1,[1;2],[],[],[],[],[],[],options);

where:

function y = ObjF(x,Delta)
    y = sin(x) + cos(x) + Delta;
end

In above example I can pass additional parameters (Delta) to objective function an then I can start optimization
to find solution. How to define above problem in Maple ? How to pass additional  parameters  befor we starat the optymalization?


Best,

Rariusz

#my testing for wildcard to one
#after testing, it loop a very long time and not stop
ppp := [[0,0,0,x],[0,0,1,0],[0,1,0,0],[1,0,0,0]]:
check1 := [seq(0,ii=1..nops(ppp))];
ttt1 := [[0,0,0,1],[0,0,1,0],[0,1,0,0],[1,0,0,0]]:
mmmeaght1 := [seq(0,ii=1..nops(ppp[1]))]:
bbb1 := [seq(0,ii=1..nops(ppp[1]))]:
emap := [(xx) -> if [xx < 0 assuming x > 0] then 0 else 1 end if, (xx) -> evalf(1/(1+exp(xx)))]:
#trace(perceptronrule1);
MM(ppp, ttt1, mmmeaght1, bbb1, check1, emap);
 

when test wildcard variable for input, would like to assume x > 0 then

i try assuming x > 0 , got error

 

I am practicing with some diff equations. I am having problem solving for one of the constants. I am having a pproblem assigning a value to derivatives or 2nd derivatives. What is a good general technique is this type of situation?
 

restart

NULL

``

omega^2 = g/l

omega^2 = g/l

(1)

Eq1 := diff(Theta(t), t, t) = -omega^2*Theta(t)

diff(diff(Theta(t), t), t) = -omega^2*Theta(t)

(2)

ics := Theta(0) = 0, (diff(Theta(t), t))(0) = Vmax, (diff(Theta(t), t, t))(0) = 0

Theta(0) = 0, (diff(Theta(t), t))(0) = Vmax, (diff(diff(Theta(t), t), t))(0) = 0

(3)

SHM := dsolve({Eq1, ics})

(4)

SHM := dsolve({Eq1})

{Theta(t) = _C1*sin(omega*t)+_C2*cos(omega*t)}

(5)

SHM := dsolve({Eq1, Theta(0) = 0})

Theta(t) = _C1*sin(omega*t)

(6)

``

diffSHM := diff(SHM, t)

diff(Theta(t), t) = _C1*omega*cos(omega*t)

(7)

``

(Theta(t))(0) = 0, (diff(Theta(t), t))(0) = V

(Theta(t))(0) = 0, (diff(Theta(t), t))(0) = V

(8)

``

``

``

``

``

NULL

NULL


 

Download SHM.mw

First 993 994 995 996 997 998 999 Last Page 995 of 2215