MaplePrimes Questions

 

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

The following test program (Test.cpp) fails with.L + Test.cpp+, but not with plain .L, nor with gcc. It also does not tell me anything about why where it fails!

#include <string>
int Test(std::string x) {
cout << x << "\n";
 return 1;
};

Error in <ACLiC>: Executing 'C:\root_v6.28.06\bin\rootcling -v0 "--lib-list-prefix=C:\Users\snyde\BFROOT\ROOT\Test_cpp_ACLiC_map" -f "C:\Users\snyde\BFROOT\ROOT\Test_cpp_ACLiC_dict.cxx"  -rml Test_cpp -rmf "C:\Users\snyde\BFROOT\ROOT\Test_cpp.rootmap" -DR__ACLIC_ROOTMAP -I%ROOTSYS%\include -D__ACLIC__  "C:/Users/snyde/BFROOT/ROOT/Test.cpp" "C:\Users\snyde\BFROOT\ROOT\Test_cpp_ACLiC_linkdef.h"' failed!

Huh? Why?

I can't learn what's wrong using 'g++  -c Test.cpp' (outside ROOT)  as it compiles w/o complaint in that case.

Is there a way to get ROOT to tell us what it objects to?

Hi, I have a cable driven robot arm consist of three joint and four links driven by cables from three pulleys. Each joint conneted to each pulley by cables independently. When I use inverse kinematic steps in maple I get these messages :

MB := zModel:-GetMultibody('simplify' = true):
                     "Analyzing system..."

              "Performing constraint analysis..."

"The system has 6 degree(s) of freedom.  It is modeled using 6 

   generalized coordinate(s) coupled by 0 algebraic constraint(s\

  )."

the problem is that I have six Generalized coordinates (3 joints + 3 pulleys) , I can find the inverse kinamatic of joint angles according to end effector position , the question is:
how can I apply it to pulley's angle?

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.

How do I increase the Java Heapsize.

About once a year rarely, I get that maple writes too much output to the worksheet file and then cannot load it again.

In the past I had to hand edit the maple file in emacs to remove output to at least get my source code back.

This is really not practical.

Webwisdom states that the heapsize can be increased by

export JVM_ARGS="-Xms1024m -Xmx1024m"

Dont know why Maple do not have to option to just ignore the results during startup.

Maple22 runs here on a Linux 32-Core server with 256GB memmory.

Question 1) Anyone know how to increase heap size.

Exporting as above dd not work

Question 2) Anyone know how to load a worksheet with all output ignored.

It is the volumous output Maple saves in the file, which it cannot read again which causes the problem.

Files are not corrupt.

Else I have to hand edit the maple output out of the files again like I did before.

Thanks

This is not a critical situation. A solution was developed. However, I am interested in trying to understand and explain to a colleague why their function failed to plot. The colleague often works on problems involving large factorial values.

failed_plot.mw

I have tried to generate a phase-plot of a complex function with maple (phase is the argument).

For example f(z):=gamma(z) or f(z):=zeta(z).

I haven't found.

Another idea is to translate this Matlab-Code to Maple-Code to get this beautyfull coloured plots.

xmin = -0.5;
xmax = 0.5;
ymin = -0.5;
ymax = 0.5;
xres = 400;
yres = 400;
x = linspace(xmin, xmax, xres);
y = linspace(ymin, ymax, yres);
[x, y] = meshgrid(x, y);
z = i*y + x;
f = exp(1./z);
p = surf(real(z), imag(z), 0*f, angle(-f));
set(p, 'EdgeColor', 'none');
caxis([-pi, pi]), colormap*hsv(600)*view(0, 90), axis*equal, axis*off;

First 41 42 43 44 45 46 47 Last Page 43 of 2308