Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Good day to all the members who read this question.
I ask for your help to find the right way to solve this two differential equations (is attached the file). Used the common code "dsolve" but is not working on this problem. Doesn't matter if the solution is numeric or algebraic.
I will thaks a lot your kind help.
Best regards to all of you

DIFFERENTIAL_EQUATION.mw

restart

with(PDEtools)

First Part

The differential equation to solve:

(Delta*LinearAlgebra:-Transpose(D[1/2])*D__0-I*`μ__e`*D__0/(lambda+I*`μ__e`*r)-2*(`μ__e`^2*r^2+lambda^2))*R(r)

Definitions

D__n = `∂__r`+I*omega(a^2+r^2)/Delta+I*a*m/Delta+2*n*(r-M)/Delta

LinearAlgebra:-Transpose(D[n]) = `∂__r`-I*omega(a^2+r^2)/Delta-I*a*m/Delta+2*n*(r-M)/Delta

a := 1; M := 1; omega := 1; m := 1; `μ__e` := 1; lambda := 1

Delta := -2*M*r+a^2+r^2

I divided the differential equation in 3 parts (A, B, C).

A := (-I*omega(a^2+r^2)-I*a*m+r-M)*(diff(R(r), r)+I*omega(a^2+r^2)*R(r)/Delta+I*a*m*R(r)/Delta)+Delta*(diff(R(r), r, r))+I*omega(a^2+r^2)*(diff(R(r), r))+I*a*m*(diff(R(r), r))

B := -I*`μ__e`*(diff(R(r), r)+I*omega(a^2+r^2)*R(r)/Delta+I*a*m*R(r)/Delta)/(lambda+I*`μ__e`*r)

C := -(2*(`μ__e`^2*r^2+lambda^2))*R(r)

DE := A+B+C

E := dsolve(DE)

R(r) = DESol({diff(diff(_Y(r), r), r)-(1-r+I/(1+I*r))*(diff(_Y(r), r))/(r^2-2*r+1)-(-(2*I)*((-1-2*I)+r)/(r^2-2*r+1)-2/((1+I*r)*(r^2-2*r+1))+2*r^2+2)*_Y(r)/(r^2-2*r+1)}, {_Y(r)})

(1)

dsolve({DE, DE(0) = 1}, numeric, range = 0 .. 20)

Error, (in dsolve/numeric/type_check) insufficient initial/boundary value information for procedure defined problem

 

Second Part

The differential equation to solve:

[`#msub(mi("L",fontweight = "bold"),mfrac(mn("1",fontweight = "bold"),mn("2",fontweight = "bold"),linethickness = "1"))`*LinearAlgebra:-Transpose(L[1/2])+a*`μ__e`*sin(theta)*LinearAlgebra:-Transpose(L[1/2])/(lambda+a*`μ__e`*cos(theta))+2*(lambda^2+a^2*`μ__e`*cos(theta)^2)]*S(theta) = 0

Definitions:

L__n = a*omega*`sinθ`+m*`cosecθ`+n*`cotθ`+`∂__θ`

LinearAlgebra:-Transpose(L[n]) = -a*omega*`sinθ`-m*`cosecθ`+n*`cotθ`+`∂__θ`

Also I divided the differential equation in 3 parts (A, B, C).

F := (omega*a*sin(theta)+m/sin(theta)+1/(2*tan(theta)))(diff(S(theta), theta)-omega*a*sin(theta)*S(theta)-m*S(theta)/sin(theta)+S(theta)/(2*tan(theta)))+diff(S(theta), theta, theta)-omega*a*sin(theta)*(diff(S(theta), theta))-m*(diff(S(theta), theta))/sin(theta)+(diff(S(theta), theta))/(2*tan(theta))

G := a*`μ__e`*sin(theta)*(diff(S(theta), theta)-omega*a*sin(theta)*S(theta)-m*S(theta)/sin(theta)+S(theta)/(2*tan(theta)))/(lambda+a*`μ__e`*cos(theta))

H := (2*(lambda^2+a^2*`μ__e`*cos(theta)^2))*S(theta)

DF := F+G+H

dsolve(DF)

dsolve({DF, DF(0) = 1}, numeric, range = 0 .. 20)

Error, (in dsolve/numeric/type_check) insufficient initial/boundary value information for procedure defined problem

 

NULL

Download DIFFERENTIAL_EQUATION.mw

I have a very difficult time finding things in the documentation.

I would like to see documentation for `<,>` and `<|>`, as in `<,>`(1,2,3,4).

If I write ?<|> in Maple I get

If I do ?<,> I get

However, there is no mention of the usage of the backticks.

Finally, if I do ?`<,>` I get

No mention of the use of `<,>`. I only know about this from a previous reply to one of my questions and now I have forgotten the details so I am trying to look it up but it's hard to find.

Dear Power Users, I tried to make a model in Maple but after several hours of struggling I need some help. Can someone tell me what I did wrong or explain to me what is the meaning of the maplemint comment on procedure (optimalisatie)? Thank you in advance.

DiLeoCasper.mw 

Suppose I have a set of vectors, say S = {x+4, 3x-7}, a specific vector f = -5x + 10 and I would like to determine if f is an element of Span(S). By hand it's a rather simple process, check the consistency of the corresponding linear system. Is there a way to automate this in Maple? That is, define a vector space (using any finite vectors: polynomials, matrices, etc.) with some basis and check to see if a given element belongs to that space? Moreover, if it does belong, could we get the linear combination of the elements of the basis that produces the desired vector?

For the t output I need to show 1, 1.2, 1.4....2, my attempt is highlighted in green below

Can anyone assist please?

#Clear memory and load packages.
restart;
with(plots):
with(Statistics):

#Define vectors and variables.
actual:=<2,3.5136,5.8016,9.1136,13.7376,20>:
t:=<1,1.2,1.4,1.6,1.8,2>:
n:=6:
RMSE:=0:

#Perform a simple linear regression on the data.
P:=LinearFit([1,x],t,actual,x);

#Display the model errors.
printf("t    Actual P  Model P  Error\n");
for i from 1 to n do
   model:=subs(x=t[i],P):
   err:=actual[i]-model:
   RMSE:=RMSE+err^2:
   printf("%2d %7.4f% 10.4f% 9.4f\n",(i+(1/5)),actual[i],model,err);
end do:

#Display the root mean square error.
RMSE:=sqrt(RMSE/n);

#Plot the points and the model.
p1:=plot(t,actual,style=point,view=[0..7,8..26]):
p2:=plot(P,view=[0..7,8..26]):
display(p1,p2);

-HFloat(17.540266666666668)+HFloat(17.712)*x

 

t    Actual P  Model P  Error

 

Error, (in fprintf) integer expected for integer format

 

HFloat(0.7463867411787324)

 

 

NULL

Download Asst_4_Question_1f.mw

I have a lists within lists.  I needed to search for a specific element in the sub-list and need to extract each such sublist that has an element.

I am only familiar with the search tool. Could someone suggest a simple way to do this.

For example, I have the following.

s := [{f0(t, r) = 0, n(t) = n(t)}, {f0(t, r) = 0, n(t) = 0}, {f0(t, r) = 0, n(t) = 0}]

I need to extract the sublist that has n(t)=n(t) so only the first element of the list s.

 

Hello,
I recently discovered the "Physics" package wich provides tools for manipulating abstract vectors (non-component).
In the "Physics:-Vectors", an orthonormal basis (i,j,k) is available and my main concern is how to generate arbitrary other 3D orthonormal bases to be able to calculate results in "vectorial form" without manipulating vectors' components.

To better explain my needs I have setup a kind of minimal example in the attached file where some questions are asked.

Thanks in advance for any feedback.

orthonormal-triads.mw

NULL

restart

with(Physics)

with(Physics[Vectors])

Creation of 2 rotation matrices

dir1 := `<,>`(0, 0, 1)

dir2 := `<,>`(0, 1, 0)

seq(assign(cat(R, i), Student:-LinearAlgebra:-RotationMatrix(theta[i], eval(cat(dir, i)))), i = 1 .. 2)

print(R1, R2)

Matrix(%id = 36893490614987576012), Matrix(%id = 36893490614987577572)

(1)

whattype(R1)

Creation of  orthogonal unit "Physics:-Vectors" from previous matrices

x1_ := _i*R1[1, 1]+_j*R1[2, 1]+_k*R1[3, 1]``

y1_ := _i*R1[1, 2]+_j*R1[2, 2]+_k*R1[3, 2]

z1_ := _i*R1[1, 3]+_j*R1[2, 3]+_k*R1[3, 3]NULL

NULL

x2_ := _i*R2[1, 1]+_j*R2[2, 1]+_k*R2[3, 1]NULL

y2_ := _i*R2[1, 2]+_j*R2[2, 2]+_k*R2[3, 2]

z2_ := _i*R2[1, 3]+_j*R2[2, 3]+_k*R2[3, 3]

Q1: Is there a more elegant way of creating "Physics:-Vectors" from matrices ?

Now, suppose that we want to compute `&x`(`#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("y2"),mo("&rarr;"))`) : since `#mover(mi("y2"),mo("&rarr;"))` = `#mover(mi("j"),mo("&and;"))` we have `&x`(`#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("y2"),mo("&rarr;"))`) = sin(`#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("j"),mo("&and;"))`)*`#mover(mi("z1"),mo("&rarr;"))` and sin(`#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("j"),mo("&and;"))`)*`#mover(mi("z1"),mo("&rarr;"))` = sin((1/2)*Pi-`&theta;__1`)*`#mover(mi("z1"),mo("&rarr;"))` and sin((1/2)*Pi-`&theta;__1`)*`#mover(mi("z1"),mo("&rarr;"))` = cos(theta[1])*`#mover(mi("z1"),mo("&rarr;"))`

The cross product operator  `&x`(x1_, y2_) yields

cos(theta[1])*_k

(2)

(which is a correct answer) instead of cos(theta[1])*`#mover(mi("z1"),mo("&rarr;"))` because vector `#mover(mi("z1"),mo("&rarr;"))` has is not known as a unit basis vector.

Similarly, `&x`(z1_, x1_) yields -sin(theta[1])*`#mover(mi("i"),mo("&and;"))`+cos(theta[1])*`#mover(mi("j"),mo("&and;"))` instead of  `#mover(mi("y1"),mo("&rarr;"))` as it would be the case when computing `&x`(_k, _i) ?

Q2: Is there a way to declare new triads of "Physics:-Vectors" with properties similar to the provided triad _i, _j, _k ?

Q3: Is the code defining the canonical basis i, _j, _kavailable for inspection and inspiration to setup orthonormal triads ?

Q4: Is it possible to get a (column) matrix of the vector components ? The function Physics:-Vectors:-Component(y1_, n) can only get 1 component at a time and only in the canonical basis i, _j, _k.

NULL

restart

with(Physics)

with(Physics[Vectors])NULL

After a proper definition of 2 new vector bases `#mover(mi("x1"),mo("&rarr;"))`, `#mover(mi("y1"),mo("&rarr;"))`, `#mover(mi("z1"),mo("&rarr;"))` and `#mover(mi("x2"),mo("&rarr;"))`, `#mover(mi("y2"),mo("&rarr;"))`, `#mover(mi("z2"),mo("&rarr;"))`, the position vector OM_ := l__1*x1_+l__2*x2_NULLNULL

l__1*x1_+l__2*x2_

(3)

NULL

projected on `#mover(mi("x2"),mo("&rarr;"))` would yield directly Typesetting[delayDotProduct](l__1, `#mover(mi("x2"),mo("&rarr;"))`.`#mover(mi("x1"),mo("&rarr;"))`, true)+l__2 instead of expand(OM_.x2_)

l__1*Physics:-Vectors:-`.`(x1_, x2_)+l__2*Physics:-Vectors:-Norm(x2_)^2

(4)

because of the unit vectors.

Download orthonormal-triads.mw

This used to work in Maple 2022.  Something is broken in 2023. 

 

restart;

kernelopts(version);

`Maple 2023.1, X86 64 LINUX, Jul 07 2023, Build ID 1723669`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1561 and is the same as the version installed in this computer, created 2023, October 20, 22:58 hours Pacific Time.`

U := Int(exp(-1/4*t - 1/4*x)*piecewise(x < -2, 1, x < -1, -x - 1, 0), x = -t .. 0);

Int(exp(-(1/4)*t-(1/4)*x)*piecewise(x < -2, 1, x < -1, -x-1, 0), x = -t .. 0)

Uval := simplify(value(U));

Uval := `simplify/piecewise/unfactor`(4*piecewise(t < 1, 0, t < 2, t-5+4*exp(`&ndash;`((1/4)*t)+1/4), 2 <= t, 1+4*exp(`&ndash;`((1/4)*t)+1/4)-4*exp(`&ndash;`((1/4)*t)+1/2)))

eval(Uval, {x=5, t=6});

`simplify/piecewise/unfactor`(4+16*exp(-5/4)-16*exp(-1))

 
 

Download simplify-piecewise-bug.mw

 

I just spent 5h trying to figure out why when I return a table from a procedure defined in an .mpl file, and then execute that procedure in a worksheet, I can't access the table entries by using regular ol' bracket notation.

I can see the keys and values by using indices and entries and passing in the return value of the procedure, but that's it.

I have tried using eval, and I have even tried reproducing my use case in a simpler worksheet to try to isolate the issue but the issue doesn't appear. I am working in an .mpl file within a larger Maple project. I have read about last name evaluation, and have tried using eval with a numeric second parameter. Nothing works.

The file is very small and contains one single procedure, and it doesn't import any other file.

When I get the return value from my procedure and print it out all I see is the name of the original table defined in the procedure and the subscript I am trying to access, but not the data.

Maddening. 

 Could Maple confirm below Mathematica result (desirably without using the trick of adding 10^-20 to the values of "n") ?
.
 W[n_] := 1/(3 n Sqrt[Pi] Gamma[2 - n] Gamma[2 + n])*2^(-7 - 4 n) (3 256^
  n Gamma[2 - n] Gamma[-(1/2) + 
    n] (8 n (-3 + 5 n + 2 n^2) Hypergeometric2F1[1 - n, 
      2 - n, -2 n, 3/
      4] - (-1 + 
       n) (4 (-4 + 7 n + 2 n^2) Hypergeometric2F1[2 - n, 2 - n, 
         1 - 2 n, 3/4] - (-10 + 3 n + n^2) Hypergeometric2F1[
         2 - n, 3 - n, 2 - 2 n, 3/4])) - 
 9^n Gamma[-(1/2) - n] Gamma[
   2 + n] (8 n (5 + 11 n + 2 n^2) Hypergeometric2F1[1 + n, 2 + n, 
      2 n, 3/4] - 
    3 (1 + n) (4 (4 + 9 n + 2 n^2) Hypergeometric2F1[2 + n, 2 + n,
          1 + 2 n, 3/4] - 
       3 (6 + 5 n + n^2) Hypergeometric2F1[2 + n, 3 + n, 
         2 (1 + n), 3/4])));
 Table[N[W[n + 10^-20], 20], {n, 1, 15}] // Rationalize

 (*{2, 14, 106, 838, 6802, 56190, 470010, 3968310, 33747490, 288654574, \
 2480593546, 21400729382, 185239360178, 1607913963614, 13991107041306}*)

Maple thinks the inverse Laplace transform of 1/(s+a) is exp(a*t).  It should be exp(−a*t).

This used to work correctly in Maple 2022.  Something got messed up in 2023.

restart;

kernelopts(version);

`Maple 2023.1, X86 64 LINUX, Jul 07 2023, Build ID 1723669`

with(inttrans):

exp(-a*t);

exp(-a*t)

laplace(%, t, s);

1/(s+a)

invlaplace(%, s, t);

exp(a*t)

 

Download laplace-transform-bug.mw

I currently do extensive modeling that involves Monte Carlo simulations. This kind of analysis seems idially suited to parallel computing. To begin the process I have been following the teachings of chapter 15 of the Programming Guide 2023. As a first excersize I copyied the code on pages 583-584 and attempted to run it on my system. My Maple program is a 2019  Student Version running on anHP laptop using Windows11. The code yields an error code "Error, invalid input: add_range uses a 1st argument, lo, which is missing"

This is an exact copy of the ccode in the guide. Is there posibly a probem with my installation? I am willing to update and upgrade as may be needed. Any suuggestions how to procced?

Thanks

Ray

Dear Maple experts

I face an issue in using ‘implicit plot’ or ‘inequal’ commands in the attached file.

I use three Maple procedures to make some simple calculations and draw an output. It is Firm Profit versus ‘alpha’. This graph is correct and makes perfect sense.

Then, I use ‘inequal’ command to compare the same outputs when ‘alpha’ and ‘delta’ change. There is a conflict between these plots and the above diagram. For example, P2 plot says

restartNULL

with(plots); with(RealDomain)

NULL

c := 1; cr := 0.3e-1*c; u := 1; sExp := 0.6e-1*c; s := .65*c; v := 3*cNULL

``

FirmModelPP := proc (alpha, beta, delta) local p0, xi0, q0, Firmpf0, G01, Recpf0, Unsold0, Environ0; xi0 := 1; p0 := min(s+sqrt((v-s)*(c-s)), delta*v+sExp); q0 := u*(v-p0)/(v-s); f(N) := 1/u; F(N) := N/u; G01 := int(F(N), N = 0 .. q0); Firmpf0 := (p0-c)*q0-(p0-s)*G01; Recpf0 := (sExp-cr)*xi0*q0; Unsold0 := G01; Environ0 := q0+Unsold0; return p0, q0, Firmpf0, Recpf0, Environ0, Unsold0 end proc

NULL

NULLNULLNULL

FirmModelFC := proc (alpha, beta, delta) local p00, xi00, q00, Firmpf00, G001, G002, Recpf00, Unsold00, Environ00, pr00; option remember; xi00 := 1; p00 := s+sqrt((v-s)*(c-s)); q00 := alpha*u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G001 := int(F(N), N = 0 .. q00/alpha); G002 := int(F(N), N = 0 .. beta*xi00*q00/(1-alpha)); pr00 := p00-delta*v; Firmpf00 := (p00-c)*q00-alpha*(p00-s)*G001; Recpf00 := xi00*q00*(sExp-cr)+(pr00-sExp)*(beta*xi00*q00-(1-alpha)*G002); Unsold00 := alpha*G001; Environ00 := q00+Unsold00; return p00, q00, Firmpf00, Recpf00, Environ00, Unsold00 end proc

NULLNULL``

NULLNULL

NULL

FirmModelHmax := proc (alpha, beta, delta) local q, p, pr, FirmpfSiS, F1, G1, G2, G3, RecpfSiS, sol, UnsoldSiS, EnvironSiS, p0, OldSoldPrim, xi, h, ps, qs, prs, prof1m, prof2m; option remember; xi := 1; prs := ps-delta*v; prof1m := (ps-c)*qs+((1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))-(1/2)*(1+beta*xi)^2*qs^2/u)*(ps-s)+(prs-sExp)*(beta*xi*qs-(1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))); prof2m := (ps-c)*qs-(1/2)*(ps-s)*qs^2/(alpha*u)+(prs-sExp)*(beta*xi*qs-(1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))); if alpha <= 1/(1+beta*xi) then p, q := (eval([ps, qs], solve({diff(prof1m, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps, qs < 2*u*(1-alpha)/(beta*xi)}, [ps, qs])[1]))[]; `h&Assign;`*(p-delta*v-sExp)/(p-delta*v); FirmpfSiS := eval(prof1m, [ps = p, qs = q, prs = p-delta*v]); RecpfSiS := (sExp-cr)*xi*q; UnsoldSiS := (1/2)*(1+beta*xi)^2*q^2/u-(1/2)*beta^2*xi^2*q^2/(u*(1-alpha)); EnvironSiS := q+UnsoldSiS else p, q := (eval([ps, qs], solve({diff(prof2m, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps, qs < 2*u*(1-alpha)/(beta*xi)}, [ps, qs])[1]))[]; h := (p-delta*v-sExp)/(p-delta*v); FirmpfSiS := eval(prof2m, [ps = p, qs = q, prs = p-delta*v]); RecpfSiS := (sExp-cr)*xi*q; UnsoldSiS := (1/2)*q^2/(alpha*u); EnvironSiS := q+UnsoldSiS end if; return p, q, FirmpfSiS, RecpfSiS, EnvironSiS, UnsoldSiS, h, OldSoldPrim, xi end proc

``

``

NULL

NULL

``

NULLNULL

NULLNULL

pltPP3A := plot('FirmModelPP(alpha, .35, .40)[3]', alpha = 0. .. 1.0, color = red, legend = "", style = pointline, labels = [alpha, "Firm Profit"], labeldirections = ["horizontal", "vertical"], symbolsize = 10, axes = boxed, symbol = box, numpoints = 10, adaptive = false, thickness = 1.0, view = [0 .. 1, 0 .. .18])

NULL

pltPP3B := plot([[0., eval('FirmModelPP(0., .35, .40)[3]', alpha = 0.)]], color = red, legend = ["PP"], style = point, symbol = box, symbolsize = 10, axes = boxed, view = [0 .. 1, 0 .. .18])

NULL

pltFC3A := plot('FirmModelFC(alpha, .35, .40)[3]', alpha = 0. .. 1, linestyle = [solid], color = black, legend = "FC", labels = [alpha, "Firm Profit"], labeldirections = ["horizontal", "vertical"], axes = boxed, adaptive = false, thickness = .7, view = [0 .. 1.0, 0 .. .18])

NULL

NULLNULLNULLNULLNULL

pltHmax3A := plot('FirmModelHmax(alpha, .35, .40)[3]', alpha = 0. .. 1.0, linestyle = [dashdot], color = brown, legend = [SiS(h__max)], labels = [alpha, "Firm Profit"], labeldirections = ["horizontal", "vertical"], symbolsize = 10, numpoints = 50, adaptive = false, thickness = 1.0, axes = boxed, view = [0 .. 1, 0 .. .19])

``

NULLNULLNULL

display([pltPP3A, pltPP3B, pltFC3A, pltHmax3A])

 

NULL

``

NULL

NULL

NULL

``

NULL

``

NULL

NULL

diffr2 := proc (alpha, delta) if not [alpha, delta]::(list(numeric)) then return ('procname')(args) end if; FirmModelFC(alpha, .35, delta)[3]-FirmModelHmax(alpha, .35, delta)[3] end proc

NULL

P2 := plots:-inequal(diffr2(alpha, delta) <= 0, alpha = 0 .. 1, delta = 0 .. 1, optionsfeasible = [[color = "Spring 1"]])

 

``

NULL

diffr3 := proc (alpha, delta) if not [alpha, delta]::(list(numeric)) then return ('procname')(args) end if; FirmModelHmax(alpha, .35, delta)[3]-FirmModelPP(alpha, .35, delta)[3] end proc

NULL

P3 := plots:-inequal(diffr3(alpha, delta) <= 0, alpha = 0 .. 1, delta = 0 .. 1, colour = "Orange")

 

``

Download ConflcitInequal.mw

SiS is superior to FC in small ‘alpha’s. But in the initial diagram, it is obvious that it should be the opposite!

Perhaps I am making a mistake in using commands. Would you please help me?

I was wondering whether it is possible to execute Python code into Maple. As an example, I give a fairly simple code:

Concentration_calculation(C_0, Q, V_r, m_b, rho, R, Gamma_i, delta_t=1):
t = np.arange(0, 360*60, delta_t)
C_i = [C_0]
for i in range(len(t)-1):
dC = -(Q/V_r)*(1-math.exp(-3*m_b*math.sqrt(Gamma_i/(rho*t[i+1]))/(math.sqrt(math.pi)*Q*R)))*C_i[i]
C_i.append(C_i[i] + dC*delta_t)
return t, C_i

Any help in tis respect would be highly appreciated.

First 40 41 42 43 44 45 46 Last Page 42 of 2097