MaplePrimes Questions

How can I get the evaluation of integration inside if-statement?

Thanks for your help in advance,

restart;

#L:=1:sigma:=0.01:beta:=0.2:k0:=-100:

#For Free particle
Projectile := proc({L:=1,sigma:=0.01,beta:=0.2,k0:=-100},n_max) local x0,g,c:
 x0:= beta*L;
 g := unapply(exp(-(x-x0)^2/2/sigma^2),x);
 #c := int(g(x)^2,x=-L/2..L/2,numeric=true);
 ub := (L/2-x0)/sqrt(2)/sigma;
 lb := (-L/2-x0)/sqrt(2)/sigma;
 a := Pi*sqrt(2)*sigma/L;
 b := sqrt(2)*k0*sigma;
 c := Pi*x/L;
 d := k0*x0;
 eq1 := [cos(a*n*z)*cos(b*z)/e^(z^2),cos(a*n*z)*sin(b*z)/e^(z^2),sin(a*n*z)*cos(b*z)/e^(z^2),sin(a*n*z)*sin(b*z)/e^(z^2)];
 eq1 := map(f->unapply(f,n,z),eq1);
 eq2 := [cos(n*c)*cos(d),cos(n*c)*sin(d),sin(n*c)*cos(d),sin(n*c)*sin(d)];
 eq2 := map(f->unapply(f,n,z),eq2);

 for j from 1 to n_max do:
   if (is(j,odd)) then eq11 := int(eq1[1](j,z),z=lb..ub,numeric=true);
   else 0;
   end if;
 end do:

end proc:

 

Warning, (in Projectile) `ub` is implicitly declared local

 

Warning, (in Projectile) `lb` is implicitly declared local

 

Warning, (in Projectile) `a` is implicitly declared local

 

Warning, (in Projectile) `b` is implicitly declared local

 

Warning, (in Projectile) `d` is implicitly declared local

 

Warning, (in Projectile) `eq1` is implicitly declared local

 

Warning, (in Projectile) `eq2` is implicitly declared local

 

Warning, (in Projectile) `j` is implicitly declared local

 

Warning, (in Projectile) `eq11` is implicitly declared local

 

Projectile(1);

int(cos(0.4442882938e-1*z)*cos(1.414213562*z)/e^(z^2), z = -49.49747467 .. 21.21320343)

(1)

 


Download SolnforProjectile_v3_3.mw

restart;
with(geometry);
with(plots);
_EnvHorizontalName := 'x';
_EnvVerticalName := 'y';
cb := color = blue;
t3 := thickness = 3;
l3 := linestyle = 3;
xA := 3;
yA := 0;
xB := -3;
yB := 0;
c := 6;
point(A, xA, yA);
point(B, xB, yB);
R := 5;
alpha := arctan(3/4);
evalf(%*180/Pi);
                          36.86989765

xH := (xA + xB)/2;
yH := (yA + yB)/2;
point(H, xH, yH);
xO1 := 0;
yO1 := 4;
point(O1, xO1, yO1);
xO2 := 0;
yO2 := -4;
point(O2, xO2, yO2);
segment(sAB, A, B);
segment(sHO, H, O1);
segment(sAO, A, O1);
segment(sBO, B, O1);
                              sAB

alpha1 := arctan((yO1 - yA)/(xO1 - xA));
beta := Pi + arctan((yO1 - yB)/(xO1 - xB));
AR1 := plottools[arc]([xO1, yO1], R, alpha1 .. beta, l3);
AR2 := plottools[arc]([xO2, yO2], R, -beta .. -alpha1, l3);
N := 80;
dt := (beta - alpha1)/(N - 1);
dr := draw({O1, O2, sAB, sHO, sAO(cb), sBO(cb)});
tex := textplot([[xA, yA - 0.5, "A"], [xB, yB - 0.5, "B"], [xO1, yO1 + 0.5, "O1"], [xO2, yO2 - 0.5, "O2"], [xH, yH - 0.5, "H"]]);
M1 := seq(plottools[disk]([R*cos(dt*t + alpha1) + xO1, R*sin(dt*t + alpha1) + yO1], 0.2, color = orange), t = 0 .. N);
M2 := seq(plottools[disk]([R*cos(dt*t + Pi + alpha1) + xO2, R*sin(dt*t + Pi + alpha1) + yO2], 0.2, color = orange), t = 0 .. N);
P1 := seq(plottools[polygon]([[R*cos(dt*t + alpha1) + xO1, R*sin(dt*t + alpha1) + yO1], [xA, yA], [xB, yB]], color = aquamarine, linestyle = dash), t = 0 .. N);
P2 := seq(plottools[polygon]([[R*cos(dt*t + Pi + alpha1) + xO1, R*sin(dt*t + Pi + alpha1) + yO1], [xA, yA], [xB, yB]], color = aquamarine, linestyle = dash), t = 0 .. N);
for t to N do
    E[t] := display(dr, tex, AR1, AR2, M1[t], P1[t]);
    F[t] := display(dr, tex, AR1, AR2, M2[t], P2[t]);
end do;
display([seq(E[t], t = 1 .. N), seq(F[t], t = 1 .. N)], insequence = true, axes = none, scaling = constrained, view = [-10 .. 10, -10 .. 10]);

NULL;
angle that does not turn on the lower arc. Thank you.

How to verify eq by using (2), (3) and (4)? Since lambda's, A's, B's and a are constant, but they appear as variables i.e., D[2](A1)..., (D[2] -> d/dt (derivative w.r.t 't')). Also q(n+1,t)- q(n,t) = a (const). Therefore, d/dt(q(n+1),t) - d/dt,(q(n,t))=0

verif_May24.mw

OS Linux

I have Maple 2022 open with a worksheet on a specific workspace.

I then move to a different workspace and want to start a new instance of maple for a new problem.

In command line I exacute

$]xmaple22 –standalone  filename.mw

Unfortunately when the new instance is started, the open maple instance on the first workspace is moved automatically to the second workspace together with the new instance opened, completely messing up the organization.

This is not expected behavior.

How can I make Maple execute absolutely independent instances of xmaple22 without indiscressionately and automatically moving existing open maple instances to the current workspace.

Severely annoying. Maple 9.5 e.g. does not have this behavior at all so Maple 2022 is a step backwards in this regard.

Thanks

How do I programmatically control the zoom of a 3d plot ?
SEE THE ATTACHED MAPLESHEET. In the attached code, the 'zoom out' on the blue cylinder is not conserved when I saved the maplesheet but it doesn't change the essential question which is how does one control the zoom programmatically. If you yourself adjust the zoom of the blue cylinder and the run tabulate(), you will see how it resets the plots settings to some default set of values.
How_do_I_programmatically_control_the_zoom_in_a_3d_plot.mw

restart

with(plots)

with(plottools)

with(DocumentTools)

``

Plot two cylinders with plottools and plot3d. Zoom out on the blue cylinder a little.

c1 := display(cylinder([1, 1, 1], 1, 3), orientation = [45, 70], scaling = constrained, color = red, size = [300, 300])

 

c2 := display(cylinder([1, 1, 1], 1, 3), orientation = [45, 70], scaling = constrained, color = blue, size = [300, 300])

 

Use tablate to embed the 3d plots in a visual array, for reasons not discussed here.

NULL

DocumentTools:-Tabulate([c1, c2], exterior = none, interior = none)

"Tabulate4"

(1)

Notice how the use of tabulate( ), changes the zoom of the individual plots to some default. There are two questions: 1. How do I programmatically control the zoom of a 3d plot with display( )? I don't want to have to click buttons with the mouse to arrive at my ideal zoom level. 2. How do I programmatically control the zoom of a 3d plot when using Tabulate( ) which envokes the default plot settings?  

Below is a screenshot of the zoom buttons I want to control programmatically.
NULL

NULL


Download How_do_I_programmatically_control_the_zoom_in_a_3d_plot.mw
1. Plot two cylinders with plottools and plot3d. Zoom out on the blue cylinder a little.
2. Use tablate to embed the 3d plots in a visual array, for reasons not discussed here.

3. Notice how the use of tabulate( ), changes the zoom of the individual plots to some default. There are two questions: 1. How do I programmatically control the zoom of a 3d plot with display( )? I don't want to have to click buttons with the mouse to arrive at my ideal zoom level. 2. How do I programmatically control the zoom of a 3d plot when using Tabulate( ) which envokes the default plot settings

Below is a screenshot of the zoom buttons I want to control programmatically.

I learnt that MapleFlow (MF) was a product similar (and better) than MathCad (MC). I have a old copy of MC, v.11 (with Maple symbolic engine) and I compared it with MF from my engineering dep. 

Can one kindly explain why Sum of a simple Matrix does not work, if the index is placed as exponent? Here what I did:

 

Dear all,

I have the following partial differential equation. I want all terms with 'diff' to be moved to the left side of the equation and all source terms to be moved to the right side of the equation.

diff(u(x, t), t, t) + 3 + 2*diff(u(x, t), t) + 4*t + x^2 + x^3/3 + diff(u(x, t), t, x, x) + diff(u(x, t), x, x, x, x) = x*t^2;

Is there a comprehensive solution for such purposes?

The desired result:

diff(u(x, t), t, t) + 2*diff(u(x, t), t) +  diff(u(x, t), t, x, x) + diff(u(x, t), x, x, x, x) = x*t^2-x^3/3 -x^2-4*t -3;

Can anyone guide me?

Best wishes,

Why Maple gives this error on solving first order linear ode using ODESteps? 

26004

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1744 and is the same as the version installed in this computer, created 2024, April 17, 19:33 hours Pacific Time.`

ode:=diff(y(x),x)+x*y(x)=1;
ic:=y(0)=0;
dsolve([ode,ic]);

diff(y(x), x)+x*y(x) = 1

y(0) = 0

y(x) = -((1/2)*I)*exp(-(1/2)*x^2)*Pi^(1/2)*2^(1/2)*erf(((1/2)*I)*2^(1/2)*x)

Student:-ODEs:-ODESteps([ode,ic])

Error, (in Student:-ODEs:-OdeSolveOrder1) invalid input: too many and/or wrong type of arguments passed to solve; first unused argument is _C1

 

 

Download odesteps_fail_may_10_2024.mw

ps. also reported to Maplesoft customer support.

Under piecewise in ?updates,Maple2024,AdvancedMath I find

{simplify,combine}(piecewise(x <= 0, 2*ln(1 - x), 0 < x, ln((x - 1)^2))) assuming (x, real);
                         /  /       2\\ 
                        { ln\(x - 1) / }
                         \            / 

Same result without simplify

{combine}(piecewise(x <= 0, 2*ln(1 - x), 0 < x, ln((x - 1)^2))) assuming (x, real);
                         /  /       2\\ 
                        { ln\(x - 1) / }
                         \            / 

What I do not understand is the grouping of simplify and combine in a set. This looks like a function composition which is normally done with the composition operator

(simplify@combine)(expr)

Asking differently: What is

{simplify,combine}(expr)

supposed to do in the examples?


Why sorting these 4 vectors wrt L(+oo) norm returns a correct result bur sorting them wrt L2 norm doesn't (unless if I evaluate the norms as floats)?
 

restart:

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)

V := [seq(LinearAlgebra:-RandomVector(2, generator=1..10), k=1..4)];

N2   := evalf(norm~(V, 2));
Ninf := norm~(V, +infinity);

V := [Vector(2, {(1) = 3, (2) = 5}), Vector(2, {(1) = 8, (2) = 7}), Vector(2, {(1) = 4, (2) = 5}), Vector(2, {(1) = 6, (2) = 2})]

 

[5.830951895, 10.63014581, 6.403124237, 6.324555320]

 

[5, 8, 5, 6]

(2)

Sorting wrt L(+oo) norm

sort(V, key=(t -> norm(t, +infinity)));  # correct

[Vector(2, {(1) = 3, (2) = 5}), Vector(2, {(1) = 4, (2) = 5}), Vector(2, {(1) = 6, (2) = 2}), Vector(2, {(1) = 8, (2) = 7})]

(3)

Sorting wrt L(2) norm

sort(V, key=(t -> norm(t, 2))); # not correct
is(norm(V[4], 2) < norm(V[3], 2));

[Vector(2, {(1) = 3, (2) = 5}), Vector(2, {(1) = 4, (2) = 5}), Vector(2, {(1) = 8, (2) = 7}), Vector(2, {(1) = 6, (2) = 2})]

 

true

(4)

sort(V, key=(t -> evalf(norm(t, 2)))); # correct

[Vector(2, {(1) = 3, (2) = 5}), Vector(2, {(1) = 6, (2) = 2}), Vector(2, {(1) = 4, (2) = 5}), Vector(2, {(1) = 8, (2) = 7})]

(5)

 


 

Download SortingVectors.mw


TIA

trouverTripletsDecroissants := proc(tripletInitial) local m, n, a, b, c, triplets, dernierTriplet; triplets := []; dernierTriplet := tripletInitial; m := dernierTriplet[3]; do m := m - 1; for n to m - 1 do if igcd(m, n) = 1 and (m - n) mod 2 = 1 then a := m^2 - n^2; b := 2*m*n; c := m^2 + n^2; if a^2 + b^2 = c^2 and a < dernierTriplet[1] and b < dernierTriplet[2] and c < dernierTriplet[3] then dernierTriplet := [a, b, c]; triplets := [op(triplets), dernierTriplet]; break; end if; end if; end do; break; if 0 < nops(triplets); end do; return triplets; end proc;
tripletInitial := [275, 252, 373];
tripletsDecroissants := trouverTripletsDecroissants(tripletInitial);
print(tripletsDecroissants);
               tripletInitial := [275, 252, 373]

           tripletsDecroissants := [[273, 136, 305]]

                       [[273, 136, 305]]

;
trouverTripletsDecroissants(275, 252, 373);
Error, (in trouverTripletsDecroissants) final value in for loop must be numeric or character
How to correct this error. Thank you.

I want to rescale a projective vector. Have been using gcd on the numerators and denominators. This works in simple situations. It doesn;t work well here, admitadely the points have been just made up for the question.  Square roots seem to make it mal-preform. I run into a lot of squate roots in symbolic situations. What would be a better way? I have been wondering if frontend would help?

restart

Prntmsg::boolean:=true;
Normalise_Projective_Point:=1;
ReScl::boolean:=true;

true

 

1

 

true

(1)

 

ProjLP:=overload([

      proc(A::Vector[row],B::Vector[row],prnt::boolean:=Prntmsg)
      description "2 projective points to create a projective line vector";
      option overload;
      local Vp ,gcdn,gcdd,vp ;
      uses LinearAlgebra;
       
      Vp:=CrossProduct(A,B)^%T;#print("2nd ",Vp);
      if ReScl then
         gcdn := gcd(gcd(numer(Vp[1]),numer(Vp[2])), numer(Vp[3]));
         gcdd := gcd(gcd(denom(Vp[1]),denom(Vp[2])), denom(Vp[3]));
         Vp:=simplify(Vp*gcdd/gcdn);
      end if;
      if Prntmsg then
         print("Line vector from two projective points. " );
      end if;
      return Vp
      end proc,



      proc(A::Vector[column],B::Vector[column],prnt::boolean:=Prntmsg)
      description "2 lines to get intersection projective point";
      option overload;
      uses LinearAlgebra;
      local  Vp;
    
      Vp:=CrossProduct(A,B)^%T;
     
     
      if Vp[3]<>0 and Normalise_Projective_Point<>0 then
           Vp:=Vp/Vp[3];
      end if;
      if Prntmsg then
           print("Meet of two Lines ");
      end if;
      return Vp
   end proc
     
]);

 

proc () option overload; [proc (A::(Vector[row]), B::(Vector[row]), prnt::boolean := Prntmsg) local Vp, gcdn, gcdd, vp; option overload; description "2 projective points to create a projective line vector"; Vp := LinearAlgebra:-CrossProduct(A, B)^%T; if ReScl then gcdn := gcd(gcd(numer(Vp[1]), numer(Vp[2])), numer(Vp[3])); gcdd := gcd(gcd(denom(Vp[1]), denom(Vp[2])), denom(Vp[3])); Vp := simplify(Vp*gcdd/gcdn) end if; if Prntmsg then print("Line vector from two projective points. ") end if; return Vp end proc, proc (A::(Vector[column]), B::(Vector[column]), prnt::boolean := Prntmsg) local Vp; option overload; description "2 lines to get intersection projective point"; Vp := LinearAlgebra:-CrossProduct(A, B)^%T; if Vp[3] <> 0 and Normalise_Projective_Point <> 0 then Vp := Vp/Vp[3] end if; if Prntmsg then print("Meet of two Lines ") end if; return Vp end proc] end proc

(2)

#maplemint(ProjLP)

pt1:=<a|sqrt(b^2+c^2)|1>:
pt2:=<c|sqrt(b^2+a^2)|1>:
pt3:=<f^2/sqrt(a^2+b^2)|f^2/sqrt(c^2+b^2)+sqrt(a^2+b^2)|1>:
pt4:=<b^2/sqrt(a^2+b^2)|f^2/sqrt(c^2+b^2)-sqrt(a^2+b^2)|1>:

 

l1:=ProjLP(pt1,pt2)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491002736020)

(3)

l2:=ProjLP(pt3,pt4)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491002712420)

(4)

l3:=ProjLP(pt1,pt4)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491064062908)

(5)

l4:=ProjLP(pt2,pt4)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491064037372)

(6)

pl1l2:=simplify(ProjLP(l1,l2))

"Meet of two Lines "

 

Vector[row](%id = 36893490491002741932)

(7)

pl2l3:=simplify(ProjLP(l2,l3))

"Meet of two Lines "

 

Vector[row](%id = 36893490491113907252)

(8)

(ProjLP(pl1l2,pl2l3));
length(%)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491113907972)

 

6223

(9)

ReScl:=false

false

(10)

# doing nothing seems to work better here than rescaling

(ProjLP(pl1l2,pl2l3));
length(%)

"Line vector from two projective points. "

 

Vector[column](%id = 36893490491125667468)

 

2796

(11)

 


 

Download 2024-05-09_Q_Rescale_projective_vector.mw

Hi,

just a simple question: Is it possible to write procedures in Mapleflow, like (this is just a simple example, not what I would like to code!):

add4:=proc(a,b,c,d) a+b+c+d end proc

and, if so, how to do it? I've tried the above code but got the error

"expecting operator"

Hi everyone,

I'm having trouble in maple to do the following:
Plot the curve x^3-4xy+2y^3=0 , as x variesbetween -3 and 3 with the aid of the implicitplot command

find dy/dx at all points (x,y) on the curve for which x=1. and find the equations of the lines tangent to the curve at the points

plot the curve and tangent lines on the same set of axes

Any help would be appreciated , thank you.

I'm new to Mapple 2024, and probably miss something.
lie, e[i] i=1..4, and G are previously defined objects. Then whe I define:

cf:=(k,l,m,t,x,y,z)->seq(lie(p,e[k](t,x,y,z),e[l](t,x,y,z))*G(t,x,y,z)[p,m],p=1..4);
cf(2,4,2,t,x,y,z);

I get:

0, 0, 0, -6*(-6*z^3*(7*z - 4)*(z - 1)^2*(y^2 - 1)^3*(x^2 - 1)^2*x - 6*z^4*(1 - z)^3*(-x^2 + 1)^2*(-y^2 + 1)^3*x*(-3*z^2*(7*z - 4)*(z - 1)^2*(y^2 - 1)^3*(x^2 - 1)^3 - 7*z^3*(z - 1)^2*(y^2 - 1)^3*(x^2 - 1)^3 - 2*z^3*(7*z - 4)*(z - 1)*(y^2 - 1)^3*(x^2 - 1)^3) - (1 - z^3*(7*z - 4)*(z - 1)^2*(y^2 - 1)^3*(x^2 - 1)^3)*(-24*z^3*(1 - z)^3*(-x^2 + 1)^2*(-y^2 + 1)^3*x + 18*z^4*(1 - z)^2*(-x^2 + 1)^2*(-y^2 + 1)^3*x))*z^4*(1 - z)^3*(-x^2 + 1)^2*(-y^2 + 1)^3*x*(1 - z^3*(7*z - 4)*(z - 1)^2*(y^2 - 1)^3*(x^2 - 1)^3)

The 4th item eval as:
cf(2, 4, 2, t, x, y, z)[4] = -36*z^10*x^2*(x^2 - 1)^7*(7*z^2 - 8*z + 4)*(z - 1)^7*(y^2 - 1)^9*(-1 + z^3*(7*z - 4)*(z - 1)^2*(y^2 - 1)^3*(x^2 - 1)^3)

But when I define another function by just changing the seq operator with a sum operator:

cf2:=(k,l,m,t,x,y,z)->sum(lie(p,e[k](t,x,y,z),e[l](t,x,y,z))*G(t,x,y,z)[p,m],p=1..4);
cf2(2,4,2,t,x,y,z);

I get 0.

What do I miss ?

2 3 4 5 6 7 8 Last Page 4 of 2323