MaplePrimes Questions

I am using some custom procedures which return error messages if something doesn´t work as planned and would need to make a distinction (when using try..catch) between these errors and all the other potential error messages Maple can return. Is there a way to do this efficiently - without having to list all of the error messages from my own procedures after catch?

Hello Everyone;

Hope you are fine. My problem is convert into nonlinear system of ODE's and further i need make the code of apply rk-4 for the formulated ODE's. Kindly guide me. The file is attached. I am waiting for your kind response.

Thanks

Question3.mw

 


 

restart

``

var111 := [C[1, 1](t), C[1, 2](t), C[1, 3](t), C[2, 1](t), C[2, 2](t), C[2, 3](t), C[3, 1](t), C[3, 2](t), C[3, 3](t), ZETA[1](t), ZETA[2](t), ZETA[3](t)]:

sysM := [diff(C[1, 1](t), t) = -(3/16)*Pi*(C[2, 1](t)+4*C[1, 1](t)), diff(C[1, 2](t), t) = -5*Pi*(C[2, 2](t)+4*C[1, 2](t)), diff(C[1, 3](t), t) = -(945/4)*Pi*(C[2, 3](t)+4*C[1, 3](t)), diff(C[2, 1](t), t) = -(1/8)*Pi*(C[3, 1](t)+6*C[2, 1](t)+6*C[1, 1](t)), diff(C[2, 2](t), t) = -10.4719755119659774615421446110*C[3, 2](t)-62.8318530717958647692528676658*C[2, 2](t)-62.8318530717958647692528676658*C[1, 2](t)-2.38361014507273884349657421134*10^15*ZETA[1](t)*C[1, 1](t), diff(C[2, 3](t), t) = -494.800842940392435057866332869*C[3, 3](t)-2968.80505764235461034719799721*C[2, 3](t)-2968.80505764235461034719799721*C[1, 3](t)-1.35954060126371030332767566128*10^16*ZETA[1](t)*C[1, 2](t)-1.35954060126371030332767566128*10^16*ZETA[2](t)*C[1, 1](t), diff(C[3, 1](t), t) = -(3/8)*Pi*(2*C[3, 1](t)+3*C[2, 1](t)), diff(C[3, 2](t), t) = -62.8318530717958647692528676658*C[3, 2](t)-94.2477796076937971538793014986*C[2, 2](t)-1.12625579354686910355213131486*10^17*ZETA[1](t)*C[2, 1](t), diff(C[3, 3](t), t) = -2968.80505764235461034719799721*C[3, 3](t)-4453.20758646353191552079699581*C[2, 3](t)-6.42382934097103118322326749959*10^17*ZETA[1](t)*C[2, 2](t)-6.42382934097103118322326749959*10^17*ZETA[2](t)*C[2, 1](t), diff(ZETA[1](t), t) = -(1/3)*C[2, 1](t), diff(ZETA[2](t), t) = -(1/3)*C[2, 2](t), diff(ZETA[3](t), t) = -(1/3)*C[2, 3](t)]:

ICS := [C[1, 1] = 0.998238989835086492681507032141e-1, C[1, 2] = -0.137051161872492529218951625903e-1, C[1, 3] = -0.629146365720807620696267926206e-2, C[2, 1] = 0.923300332435106257640735267282e-1, C[2, 2] = -0.126762613568515069966837491839e-1, C[2, 3] = -0.581915808273854734025727975244e-2, C[3, 1] = -0.190143920352772604950256237747e-1, C[3, 2] = 0.261054171122321128306306984717e-2, C[3, 3] = 0.119839394846335068333097530793e-2, ZETA[1] = .464598743230343884242076682299, ZETA[2] = .429720916976380440572769663279, ZETA[3] = -0.884964696113332752036741498040e-1]:

``


 

Download Question3.mw

The worksheet here shows a couple of failed attempts at coaxing Maple to calculate the general solution of a pretty simple second order ODE.  I have also included the expected solution which I  have calculated by hand.  Perhaps I am missing a key trick.  Any ideas?

The ODE that I am actually interested in is significantly more complex. The one in the worksheet is a much simplified "bare bones" specimen that exhibits the issue that I am facing.

Attempt to solve with Heaviside

restart;

de := diff(u(x),x$2) = Heaviside(x - a)*u(x);

diff(diff(u(x), x), x) = Heaviside(x-a)*u(x)

dsolve fails:

dsolve(de);

u(x) = DESol({diff(diff(_Y(x), x), x)-Heaviside(x-a)*_Y(x)}, {_Y(x)})

Attempt to solve with piecewise

restart;

de := diff(u(x),x$2) = piecewise(x < a, 0, 1)*u(x);

de := diff(u(x), x, x) = piecewise(x < a, 0, 1)*u(x)

dsolve(de);

Error, (in dsolve) give the main variable as a second argument

dsolve(de, u(x));

Error, (in dsolve) give the main variable as a second argument

 

 

The solution is easy to calculate by hand

We just solve the (quite trivial) DE over the intervals x < a and x>a

separately, and patch the two solutions by requiring the continuity

of u(x) and diff(u(x), x) at x = a.  We get

sol := piecewise(x < a,
        x*c[1] + c[2],
        ((a*c[1] + c[1] + c[2])*exp(x))/(2*exp(a)) + ((a*c[1] - c[1] + c[2])*exp(-x))/(2*exp(-a)));

sol := piecewise(x < a, x*c[1]+c[2], (a*c[1]+c[1]+c[2])*exp(x)/(2*exp(a))+(a*c[1]-c[1]+c[2])*exp(-x)/(2*exp(-a)))

Download solving-an-ode.mw

Hello,

I am fairly new to Maple. Suppose I have two Matrices

A := <<true, false, true> | <true, false, true> | <false, false, false>>

B := <<1, 2, 6> | <3, 4, 7> | <22, 33, 44>>

and apply select(A, B)

Why do I receive [[[(),3,22],[(),(),()],[(),7,44]]] instead of [[[1,(),6],[3,(),7],[(),(),()]]] as a result? I just want to select every element of B where A is true.

I appreciate any insight.

This is a simple algebraic, but I would like to know how to officially solve the problem,

I tried factor(6*a+12*b+18*c); it simply outputs what I input.

I tried primpart(6*a+12*b+18*c) ; the output is: a+2b+3c

I tried content(6*a+12*b+18*c), the output is 6

What I'm looking for an output is, 6*(a+2*b+3*c), this is the answer my Algebra book is looking for, I also get this answer by

using my HP Graphing Calculator, but I'm unable to get the answer from Maples. Can anyone help?

Could you Please Help me,the Maple code for Plot this equations in any Numerical Method

restart

with(PDETools, declare):

with(LinearAlgebra):

with(PolynomialIdeals):

with(plots):

declare(f(x));

f(x)*`will now be displayed as`*f

(1)

eq1 := diff(f(x), x, x, x)+(1/2)*(1-phi)^2.5*(1-phi+phi*rho[s]/rho[fl])*(eta*`cos&omega;`+f(x)*`sin&omega;`)*(diff(f(x), x, x))+(1-phi)^2.5*M*sin^2*alpha*(1-(diff(f(x), x)))+(1-phi)^2.5*(1-phi+phi*`&rho;&beta;`[s]/`&rho;&beta;`[fl])*lambda[T]*theta = 0;

diff(diff(diff(f(x), x), x), x)+(1/2)*(1-phi)^2.5*(1-phi+phi*rho[s]/rho[fl])*(eta*`cos&omega;`+f(x)*`sin&omega;`)*(diff(diff(f(x), x), x))+(1-phi)^2.5*M*sin^2*alpha*(1-(diff(f(x), x)))+(1-phi)^2.5*(1-phi+phi*`&rho;&beta;`[s]/`&rho;&beta;`[fl])*lambda[T]*theta = 0

(2)

eq2 := K[nf]*(diff(theta(x), x, x))/K[f]+(1/2)*Pr*(eta*`cos&omega;`+f*`sin&omega;`)*(diff(theta(x), x)) = 0;

K[nf]*(diff(diff(theta(x), x), x))/K[f]+(1/2)*Pr*(eta*`cos&omega;`+f*`sin&omega;`)*(diff(theta(x), x)) = 0

(3)

bcs := F(0) = 0, F(1) = 0, F(10) = 1, Theta(0) = 1, Theta(10) = 0;

F(0) = 0, F(1) = 0, F(10) = 1, Theta(0) = 1, Theta(10) = 0

(4)

a1 := [M = 1, alpha = 0, phi = 0.5e-1, `cos&omega;` = 1, `sin&omega;` = 1, sin(alpha) = 0, lambda[T] = 0, Pr = 6.2, rho[s] = 5200, rho[fl] = 997.1, `&rho;&beta;`[fl] = 20939.1, K[nf] = .6842, eta = 0];

[M = 1, alpha = 0, phi = 0.5e-1, `cos&omega;` = 1, `sin&omega;` = 1, sin(alpha) = 0, lambda[T] = 0, Pr = 6.2, rho[s] = 5200, rho[fl] = 997.1, `&rho;&beta;`[fl] = 20939.1, K[nf] = .6842, eta = 0]

 

[Pr = 6.2, M = 1, phi = 0.5e-1, `cos&omega;` = 1, `sin&omega;` = 1, sin(alpha) = 0, lambda[T] = 0, `&rho;&beta;`[fl] = 20939.1, K[nf] = .6842, K[f] = .613, eta = 0]

(5)

b1 := subs(a1, eq1);

diff(diff(diff(f(x), x), x), x)+.5325197465*f(x)*(diff(diff(f(x), x), x)) = 0

(6)

c1 := subs(a2, eq2);

1.116150082*(diff(diff(theta(x), x), x))+3.100000000*f*(diff(theta(x), x)) = 0

(7)

d1 := dsolve({b1, bcs}, {bcs, c1}, numeric); d1(0)

Error, (in dsolve/numeric/process_input) invalid argument: {1.116150082*(diff(diff(theta(x), x), x))+3.100000000*f*(diff(theta(x), x)) = 0, F(0) = 0, F(1) = 0, F(10) = 1, Theta(0) = 1, Theta(10) = 0}

 

d1(0)

(8)

``

Download  Numerical Method.mw

Inverse kinematics can be done in several ways (this webinar gives a very good overview https://www.youtube.com/watch?v=X0OZ9EM6dns). A effective and simple method is to run a model in reverse direction. This can’t be done with causal modeling tools, where information flow is fixed by design (https://de.maplesoft.com/support/help/MapleSim/view.aspx?path=MapleSimUserGuide/Chapter01).

Inverse kinematics, which is possible with acausal modeling tools, is only an example for running a model in the reverse (i.e., inverted) direction.

Without success, I tried to find a reference who first came up with that elegant approach.

Anyone knows more?

Hi

I have a problem with calculating complex numbers in Maple.

I type forexample 8(cos(Pi/2)+I*sin(Pi/2)) and I get 8, I should get 8I

Should I re-install Maple or edit my settings?

best regards

Hi everybody,how can I solve these equations in Maple and plot the answers? tnx...

eq1 := diff(x(t), t) = 35*(y-x)

eq2 := diff(y(t), t) = -x*z-7*x+28*y

eq3 := diff(z(t), t) = x*y-3*z

Hi Dear All,

 

I need to extract the coordinates from spacecurve commend. For example;

 

h3:=spacecurve([-x,-y,z],omega=ws..0,color=green,thickness=5):
h4:=spacecurve([-x,y,z],omega=ws..0,color=blue,thickness=5):

Where, omega is a parameter difinening x, y, z.

Hello Everyone;

Hope you are fine. I have set of following ODE's;

Every variable has two ODE's. I need to take one ODE for each variable. Is that any way?
I am waiting for your kind response.

Thanks

Question2.mw

The solution from LPSolve shown in the worksheet below is displayed very weirdly:

  1. The first element is rounded to 3 significant digits.
  2. The variable indices have decimal points.
  3. Zeros are displayed as just decimal points with no digit 0.

Closer inspection (with, say, lprint) will reveal that the weirdness is only with the prettyprinting; the actual entries are as expected.
 

restart:

<(kernelopts,interface)(version), interface~([prettyprint, typesetting])[]>;

Vector(4, {(1) = `Maple 2022.1, X86 64 WINDOWS, May 26 2022, Build ID 1619613`, (2) = `Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`, (3) = 2, (4) = extended})

(a,b,c):= (2,4,5):

X:= Matrix((a,b), symbol= x):
Y:= Matrix((b,c), symbol= y):
Z:= Matrix((a,c), symbol= z):

RegionC:= <5, 15, 8, 10, 15>:

RegionA:= <90, 75>:

RegionB:= <35, 20, 30, 15>:

Cost1:= <
    2, 1, 3/2,   3;
  5/2, 2, 7/2, 3/2
>:

Cost2:= <
    3/2, 4/5, 1/2, 3/2,   3;
      1, 1/2, 1/2,   1, 1/2;
      1, 3/2,   2,   2, 1/2;
    5/2, 3/2, 3/5, 3/2, 1/2
>:

Cost3:= <
    11/4, 7/2, 5/2, 3,   5/2;
       3, 7/2, 7/2, 5/2, 2
>:

Cost__Total:= (add@(add@`*`~)~)([Cost||(1..3)], [X,Y,Z]):

CapB:= add(X[i], i= 1..a) <=~ RegionB:

CapA:= add(<X|Z>[..,j], j= 1..b+c) <=~ RegionA:

ReqC:= add(<Y,Z>[i], i= 1..a+b) >=~ RegionC:

InEqOutB:= add(<X, -Y^%T>[i], i= 1..a+c) =~ 0:

Cons:= seq~({CapA, CapB, ReqC, InEqOutB}):

Sol:= Optimization:-LPSolve(Cost__Total, Cons, assume= nonnegative);

[103.800000000310, [x[1, 1] = HFloat(0.0), x[1, 2] = HFloat(20.000000000344205), x[1, 3] = HFloat(7.999999999311598), x[1, 4] = HFloat(0.0), x[2, 1] = HFloat(0.0), x[2, 2] = HFloat(0.0), x[2, 3] = HFloat(0.0), x[2, 4] = HFloat(15.000000000688408), y[1, 1] = HFloat(0.0), y[1, 2] = HFloat(0.0), y[1, 3] = HFloat(-1.7763568394002505e-15), y[1, 4] = HFloat(0.0), y[1, 5] = HFloat(0.0), y[2, 1] = HFloat(0.0), y[2, 2] = HFloat(15.0), y[2, 3] = HFloat(5.000000000344206), y[2, 4] = HFloat(0.0), y[2, 5] = HFloat(0.0), y[3, 1] = HFloat(5.000000000000002), y[3, 2] = HFloat(0.0), y[3, 3] = HFloat(0.0), y[3, 4] = HFloat(0.0), y[3, 5] = HFloat(2.9999999993115956), y[4, 1] = HFloat(0.0), y[4, 2] = HFloat(0.0), y[4, 3] = HFloat(2.9999999996557944), y[4, 4] = HFloat(0.0), y[4, 5] = HFloat(12.000000000688413), z[1, 1] = HFloat(0.0), z[1, 2] = HFloat(0.0), z[1, 3] = HFloat(0.0), z[1, 4] = HFloat(0.0), z[1, 5] = HFloat(0.0), z[2, 1] = HFloat(0.0), z[2, 2] = HFloat(0.0), z[2, 3] = HFloat(0.0), z[2, 4] = HFloat(10.0), z[2, 5] = HFloat(0.0)]]

 

 

Download BadLPSolveDisp.mw

I am reading some expressions from file.

In the file, it is written as GAMMA(-1,x). When read into Maple using the read file command, it shows as  1/x*Ei(2,x)

I know these are the same mathematically. But I am translating these expressions to sagemath. in sagemath, Ei only accepts one argument.

Now the translator sees Ei in the input, then it keeps it as Ei as it does not know it was the GAMMA with two arguments,  which gives an error when used by sagemath since sagemath only has the one argument version of Ei.

If Maple would keep GAMMA(-1,x) as is, then the translator will just translate it to gamma(-1,x) which works in sage.

To keep things simple, I was wondering if there an option to tell Maple to keep the input as GAMMA(-1,x) and not rewrite to Ei?

Otherwise I would have to now parse each Ei to see if it is the two argument version or the one argument version, and use gamma  for the 2 argument version to keep sage happy which will complicate things for me. 

expr:=GAMMA(-1,x)

               Ei(2, x)/x

Maple 2022.1

restart;
with(plots);
with(plottools);
Vdot := proc (U, V)local i: add(U[i]*V[i], i = 1 .. 2) end proc:
dist := proc (M, N) sqrt(Vdot(expand(M-N), expand(M-N))) end proc:
ngon := n -> local i; [seq([cos(2*Pi*i/n), sin(2*Pi*i/n)], i = 1 .. n)]:
theta := (2*Pi)/5;
poly := [seq([cos(k*theta), sin(k*theta)], k = 1 .. 5), datatype = float];
Ii := [0, 1/2]:
H := [-1/4, 0]:
r := dist(Ii, H):
theta := (2*Pi)/5:
p1 := pointplot([seq([cos(k*theta), sin(k*theta)], k = 0 .. 5)], symbol = solidcircle, color = red, symbolsize = 10):
p2 := textplot([seq([cos(k*theta), sin(k*theta), cat("M", k)], k = 0 .. 4)], align = ["above", "right"]):
cir1 := circle([0, 0], 1/2, color = green,dashdot:):
cir2 := circle([-1/4, 0], r, color = black):
cir3:=circle([0,0],1,color=red):
display([p1, p2, cir1, cir2, cir3,polygonplot(poly, thickness = 5, color = blue, transparency = 0.95)], axes = normal);
Why this error , Thank you.

I am trying to rotate a region about the y-axis. However, entering axis=vertical rotates it about the z-axis. I have also tried interchanging the x and y values. However, it produces the same output. The left image is what I'd like to rotate about the y-axis. The code below is for the right image. How would I revolve this region about the y-axis? Please help.

VolumeOfRevolution(2*x^2 + 1, x = 0 .. 1, labels = [x, y, z], output = plot, axis = vertical, orientation = [270, 0, 90])

First 179 180 181 182 183 184 185 Last Page 181 of 2308