Maple 2022 Questions and Posts

These are Posts and Questions associated with the product, Maple 2022

 The following code:

for i to np do
    pl_pp[i] := point([h_p[i], m_p[i]], color = red);
    pl_np[i] := point([h_n[i], m_n[i]], color = blue);
    pl_pn[i] := point([-h_n[i], -m_n[i]], color = red);
    pl_nn[i] := point([-h_p[i], -m_p[i]], color = blue);
end do

Gives following error:

Error, (in plottools:-point) incorrect arguments for creating points structure, try providing the dimension option
 

Dear Maple community,

I am trying to define an operator in Maple that multiplies to an expression and substitutes the indices.

The issue is that I don't want to add the expression as input of the operator/function, sth like:

p := proc(i, j, z) option operator; subs({i = j, j = i}, z); end proc

I want it to act on expression, like:

P(i,j)*X(i,j,k)=X(j,i,k)

and X can be any tensor or matrix.

Thanks in advance.

The shortcut key Ctrl+Delete is used to clear a math region or delete a cell within a group, so I can delete some output manually. However, I find that there exists some long-standing functions like PrintTemporary and Monitor in Mathematica, which can be used to print intermediate values of variables temporarily (and dynamically, if possible). The term "temporarily" means that the printed output disappears at the end of a computation / when a computation is complete / when the evaluation finishes / before returning the result of an evaluation. For instance: 

(Note that certain operations require a front end.)

Is it possible to implement such functionalities in Maple? 

IndependencePolynomial returns the independence polynomial for the graph G in the variable x.

For the following example, its calculation took over 20 minutes and still hasn't produced a result, and what's fatal is that it  has consumed 4G  memory.

with(GraphTheory):
G:=ConvertGraph("W|tNHEpCKoh`@@Po_WHB@CKC?WGO{G?KKCB`?OMG?_y_?Sn");
G1:=LineGraph(G);
IndependencePolynomial(G1, x) # be careful

I use  codes in  the link https://github.com/pernici/hobj.

It produced results quickly (It takes approximately 5 seconds.). So I think the built-in function " IndependencePolynomial " should be able to be improved. (Of course we are usually very concerned about their coefficients) 

Their coefficients of the independent polynomial of G1 are as follows.

[340649, 12329124, 68797662, 140606548, 139481127, 77027880, 25546428, 5303544, 700911, 58580, 2982, 84, 1]

It tells me the total number of independence sets with size 12 is 340649. 

I have been unable to add a directed light source to my plot3d drawings.  Perhaps I am misreading the documentation.  In the following experiment, I attempt to shine a red light from the direction (phi,theta) but changing the values of phi and theta don't seem to change the scene's lighting.  Can you change the lighting in your Maple?

restart;
with(plottools):
with(plots):
Explore(display(sphere(), style=surface, color=yellow, light=[phi,theta,1,0,0]),
	phi=0..Pi, theta=0..Pi);

Why there is an error? Is any part missing in the if statement?

restart

rel := w+(1/2)*sqrt(960*c^6*gamma^2*k^2-336*c^4*gamma^2*k^4+64*c^2*gamma^2*k^6-4*gamma^2*k^8+576*alpha*c^6*gamma*k-288*alpha*c^4*gamma*k^3-16*alpha*c^2*gamma*k^5+8*alpha*gamma*k^7-144*alpha^2*c^4*k^2-48*alpha^2*c^2*k^4-4*alpha^2*k^6+128*c^4*gamma*k^2-40*c^2*gamma*k^4+4*gamma*k^6+48*alpha*c^4*k-16*alpha*c^2*k^3-4*alpha*k^5+4*c^2*k^2-k^4)

w+(1/2)*(960*c^6*gamma^2*k^2-336*c^4*gamma^2*k^4+64*c^2*gamma^2*k^6-4*gamma^2*k^8+576*alpha*c^6*gamma*k-288*alpha*c^4*gamma*k^3-16*alpha*c^2*gamma*k^5+8*alpha*gamma*k^7-144*alpha^2*c^4*k^2-48*alpha^2*c^2*k^4-4*alpha^2*k^6+128*c^4*gamma*k^2-40*c^2*gamma*k^4+4*gamma*k^6+48*alpha*c^4*k-16*alpha*c^2*k^3-4*alpha*k^5+4*c^2*k^2-k^4)^(1/2)

(1)

crit_points := solve(diff(rel, k) = 0, k); rel_at_crit := subs(k = crit_points, rel)

"#` determine the maxima and minima by checking the sign of the second derivative at the critical points`  for i from 1 to nops(crit_points) do    if (eval(diff(diff(rel, k), k), k = crit_points[i]) > 0) then      print("Minimum at k = ", crit_points[i], " with value ", rel_at_crit[i]);    else if (eval(diff(diff(rel, k), k), k = crit_points[i]) < 0) then      print("Maximum at k = ", crit_points[i], " with value ", rel_at_crit[i]);    else      print("Saddle point at k = ", crit_points[i], " with value ", rel_at_crit[i]);    end if;  end do; "

Error, invalid if statement termination

"#` determine the maxima and minima by checking the sign of the second derivative at the critical points`  for i from 1 to nops(crit_points) do    if (eval(diff(diff(rel, k), k), k = crit_points[i]) > 0) then   print("Minimum at k = ", crit_points[i], " with value ", rel_at_crit[i]);    else if (eval(diff(diff(rel, k), k), k = crit_points[i]) < 0) then   print("Maximum at k = ", crit_points[i], " with value ", rel_at_crit[i]);    else   print("Saddle point at k = ", crit_points[i], " with value ", rel_at_crit[i]);    end if;  end do; "

 

NULL

Download maxnmin.mw

I input this codes:

latex((4*n-1)/9-7/16*n)

\frac{n}{144}-\frac{1}{9}

This is not the output I expected.  I would like to obtain an expression similar to the one below.

\frac{4 n-1}{9}-\frac{7}{16}n

How can I achieve this, as Maple seems to have processed it internally.

Does maple over-understand the expression.

Hi, I would appreciate some help in solving the following system of partial differential equations. The particularity of the system is that only the individual variables (i.e. a, c, and l) depend on two arguments (t: current time period and v: date of birth). The other variables are either rates or aggregates. The aggregate variables (i.e. K, L, and Y) depend only on time, t, because they are the integrals of the individual variables over v. Thanks for your help.

NULL

NULL

restart; with(PDEtools)

alpha := .3306341; delta := solve(1+0.4877489e-1 = exp(delta_a)); T := 1

l0 := 42.375*(33.16667/(52*(24-9.95)*7)); L0 := l0*T

x0 := 0

IOR := .2093723865

KOR := IOR/delta

r0 := alpha/KOR-delta; rho := r0; fsolve({K0 = Y0*KOR, w0 = (1-alpha)*Y0/L0, alpha*exp(x0)*K0^(alpha-1)*L0^(1-alpha) = r0+delta}); assign(%)

0.2758153402e-1

 

{K0 = 2.510740299, Y0 = .5710794198, w0 = 1.390997088}

(1)

C0 := -K0*delta+Y0; c0 := C0/T

.4515111588

 

.4515111588

(2)

sigma := w0*(1-l0)/c0

2.234133040

(3)

eq1 := diff(c(t, v), t) = (r(t)-rho)*c(t, v)

eq2 := sigma*c(t, v) = w(t)*(1-l(t, v))

eq3 := r(t)*a(t, v)+w(t)*l(t, v) = c(t, v)+diff(a(t, v), t)

eq4 := Y(t) = exp(x(t))*K(t)^alpha*L(t)^(1-alpha)

eq5 := r(t)-delta = alpha*Y(t)/K(t)

eq6 := w(t) = (1-alpha)*Y(t)/L(t)

eq7 := K(t) = int(a(t, v), v = t-T .. t)

eq8 := L(t) = int(l(t, v), v = t-T .. t)

eq9 := x(t) = piecewise(t = 0, 0, t > 0, 0.1e-1)

eq := {eq1, eq2, eq3, eq4, eq5, eq6, eq7, eq8, eq9}

SV := {K(0) = K0, L(0) = L0, Y(0) = Y0, a(t, 0) = 0, c(0, 0) = c0, l(0, 0) = l0, r(0) = r0, w(0) = w0}

pdsolve(eq, SV, numeric, 'time' = t, 'range' = 0 .. T)

Error, (in pdsolve/numeric/process_PDEs) variable(s) {v} are in the PDE system but are not dependent or independent variables

 

sol := pdsolve(eq, SV, 'time' = t, 'range' = 0 .. T)

(4)

NULL

Download OLG.mw

Hi,

I have been bothered lately by the number format for axis labels in Maple. My problem existed before, but it apparently didn't bother me before. I have spent many hours trying to find an answer in the program help, in MaplePrimes, and in general online searches. I am not having any luck at all (good luck, that is).

I want to change the format of the axis numbering. Maple seems to default to 2 decimal places in my graph, and I really need more. Oddly, when I export the graph to PDF, I get another decimal place (even though I didn't explicitly ask for one). 

How do I change the axis-label format? Any idea what I might get when I export the graph?

Thanks for your help,

Jno.

 

How can I change the order of variables in a polynomial as I want? For example, I want to assign a polynomial G of 3 variables a,b,c. Then I want to compute G(a,b,c) (exchange the variable a to b, exchange variable b to a)?

I've probably asked about this long time ago but I do not remember now. But it is still a problem any way in 2022.2

Compare these two results

code is

 

restart;

alias(seq(c[k] = _C||k, k = 0..10));
c[1]*h(x);
Int(c[1]*h(x),x);


restart;
c[1]*h(x);
Int(c[1]*h(x),x);

I tried with typesetting level as extended and standard and same result.

Is this a know issue? It is not a big deal as it only affects display but it will be nice to find why it happens when using alias.

 

This a more a math question than  a maple programming question. But interesting.

I have a point P=[x,y] on a line y= 2+3x. The point maps to Pn=[f(x, y), g(x, y)]. That represents a conic.

I want to find the equation of the conic. I did it by calculating 5 points and that works fine but only because I know I'm looking for a conic. 

Can the problem by solved without having to get the five points?
I copied and pasted the equations for the lines because they were generated by commands in a pagkage I have.

restart

NULL

NULL

P := [X, Y]

[X, Y]

``

NULL

Pn := [(5*X+12*Y)*(-384+48*X+55*Y)/(225*X^2+225*Y^2-1800*X-602*Y), (2*(12*X-5*Y))*(-384+48*X+55*Y)/(225*X^2+225*Y^2-1800*X-602*Y)]

[(5*X+12*Y)*(-384+48*X+55*Y)/(225*X^2+225*Y^2-1800*X-602*Y), 2*(12*X-5*Y)*(-384+48*X+55*Y)/(225*X^2+225*Y^2-1800*X-602*Y)]

NULL

``

Y := 2+3*Xn

2+3*X

``

for i to 5 do P || i := eval(Pn, X = i) end do

[181139/51416, -19775/25708]

NULL

l12 := 153621*x*(1/68840)+169429*y*(1/27536)-15067/17210

(153621/68840)*x+(169429/27536)*y-15067/17210

NULL

l34 := -5733*x*(1/473062)+258973*y*(1/946124)+244205/946124

-(5733/473062)*x+(258973/946124)*y+244205/946124

c1 := l12*l34

((153621/68840)*x+(169429/27536)*y-15067/17210)*(-(5733/473062)*x+(258973/946124)*y+244205/946124)

NULL

l13 := 5499*x*(1/2360)+6539*y*(1/944)-793/472

(5499/2360)*x+(6539/944)*y-793/472

l24 := 596115*x*(1/6899489)+7228091*y*(1/6899489)+195364/363131

(596115/6899489)*x+(7228091/6899489)*y+195364/363131

plots:-implicitplot([l12, l34, l13, l24])

c2 := l13*l24

((5499/2360)*x+(6539/944)*y-793/472)*((596115/6899489)*x+(7228091/6899489)*y+195364/363131)

c := simplify(c2*lambda+c1)

(655607277/3256558808)*(x+(2515/846)*y-305/423)*(x+(556007/45855)*y+285532/45855)*lambda-(880709193/32565588080)*(x-(19921/882)*y-18785/882)*(x+(65165/23634)*y-4636/11817)

lambda := solve(eval(c, [x = P5[1], y = P5[2]]), lambda)

-1/4

simplify(c)

-(5039454771/65131176160)*x^2+(1/130262352320)*(-29130506847*y+40315638168)*x-(423368829/3256558808)*y^2+(111619143207/130262352320)*y

plt1 := plot(Y, X = -10 .. 10)

NULL

NULL

plt2 := plots:-implicitplot([c])

plots:-display(plt1, plt2, colour = ["Red", "Green"])

NULL

for i in [-7, 13/3, 42*(1/7)] do x := eval(Pn[1], X = i); y := eval(Pn[2], X = i); simplify(c) end do

0

NULL

Download Q_23-03-04_how_to_find_conic_from_mapping.mw

Maple continuously shows 'Evaluating' and there is no output. How to fix it?

restart

with(LinearAlgebra)

assume(x::real); assume(t::real); assume(`&alpha;__1`::real); assume(`&alpha;__2`::real); assume(nu::real)

A2s := Matrix([[H__11*exp(I*v__11)/(`&lambda;__1`-conjugate(`&lambda;__1`))+H__13*exp(I*v__21)/(`&lambda;__1`-conjugate(`&lambda;__2`))+1, H__12*exp(-I*v__11)/(`&lambda;__1`-conjugate(`&lambda;__1`))+H__14*exp(-I*v__21)/(`&lambda;__1`-conjugate(`&lambda;__2`)), H__11*exp(I*v__12)/(`&lambda;__2`-conjugate(`&lambda;__1`))+H__13*exp(I*v__22)/(`&lambda;__2`-conjugate(`&lambda;__2`)), H__12*exp(-I*v__12)/(`&lambda;__2`-conjugate(`&lambda;__1`))+H__14*exp(-I*v__22)/(`&lambda;__2`-conjugate(`&lambda;__2`))], [H__12*exp(I*v__11)/(`&lambda;__1`-conjugate(`&lambda;__1`))+H__14*exp(I*v__21)/(`&lambda;__1`-conjugate(`&lambda;__2`)), 1+H__11*exp(-I*v__11)/(`&lambda;__1`-conjugate(`&lambda;__1`))+H__13*exp(-I*v__21)/(`&lambda;__1`-conjugate(`&lambda;__2`)), H__12*exp(I*v__12)/(`&lambda;__2`-conjugate(`&lambda;__1`))+H__14*exp(I*v__22)/(`&lambda;__2`-conjugate(`&lambda;__2`)), H__11*exp(-I*v__12)/(`&lambda;__2`-conjugate(`&lambda;__1`))+H__13*exp(-I*v__22)/(`&lambda;__2`-conjugate(`&lambda;__2`))], [H__13*exp(I*v__11)/(`&lambda;__1`-conjugate(`&lambda;__1`))+H__33*exp(I*v__21)/(`&lambda;__1`-conjugate(`&lambda;__2`)), H__14*exp(-I*v__11)/(`&lambda;__1`-conjugate(`&lambda;__1`))+H__34*exp(-I*v__21)/(`&lambda;__1`-conjugate(`&lambda;__2`)), 1+H__13*exp(I*v__12)/(`&lambda;__2`-conjugate(`&lambda;__1`))+H__33*exp(I*v__22)/(`&lambda;__2`-conjugate(`&lambda;__2`)), H__14*exp(-I*v__12)/(`&lambda;__2`-conjugate(`&lambda;__1`))+H__34*exp(-I*v__22)/(`&lambda;__2`-conjugate(`&lambda;__2`))], [H__14*exp(I*v__11)/(`&lambda;__1`-conjugate(`&lambda;__1`))+H__34*exp(I*v__21)/(`&lambda;__1`-conjugate(`&lambda;__2`)), H__13*exp(-I*v__11)/(`&lambda;__1`-conjugate(`&lambda;__1`))+H__33*exp(-I*v__21)/(`&lambda;__1`-conjugate(`&lambda;__2`)), H__14*exp(I*v__12)/(`&lambda;__2`-conjugate(`&lambda;__1`))+H__34*exp(I*v__22)/(`&lambda;__2`-conjugate(`&lambda;__2`)), H__13*exp(-I*v__12)/(`&lambda;__2`-conjugate(`&lambda;__1`))+H__33*exp(-I*v__22)/(`&lambda;__2`-conjugate(`&lambda;__2`))+1]])

Matrix(%id = 36893490803012390908)

(1)

vvalue := {v__11 = (conjugate(`&lambda;__1`)-`#msub(mi("&lambda;",fontstyle = "normal"),mn("1"))`)*x+(4*`&alpha;__1`*(conjugate(`&lambda;__1`)^3-`&lambda;__1`^3)+2*`&alpha;__2`*(conjugate(`&lambda;__1`)^2-`&lambda;__1`^2)-8*nu*(conjugate(`&lambda;__1`)^4-`&lambda;__1`^4))*t, v__12 = (conjugate(`&lambda;__1`)-`#msub(mi("&lambda;",fontstyle = "normal"),mn("2"))`)*x+(4*`&alpha;__1`*(conjugate(`&lambda;__1`)^3-`&lambda;__2`^3)+2*`&alpha;__2`*(conjugate(`&lambda;__1`)^2-`&lambda;__2`^2)-8*nu*(conjugate(`&lambda;__1`)^4-`&lambda;__2`^4))*t, v__21 = (conjugate(`&lambda;__2`)-`#msub(mi("&lambda;",fontstyle = "normal"),mn("1"))`)*x+(4*`&alpha;__1`*(conjugate(`&lambda;__2`)^3-`&lambda;__1`^3)+2*`&alpha;__2`*(conjugate(`&lambda;__2`)^2-`&lambda;__1`^2)-8*nu*(conjugate(`&lambda;__2`)^4-`&lambda;__1`^4))*t, v__22 = (conjugate(`&lambda;__2`)-`#msub(mi("&lambda;",fontstyle = "normal"),mn("2"))`)*x+(4*`&alpha;__1`*(conjugate(`&lambda;__2`)^3-`&lambda;__2`^3)+2*`&alpha;__2`*(conjugate(`&lambda;__2`)^2-`&lambda;__2`^2)-8*nu*(conjugate(`&lambda;__2`)^4-`&lambda;__2`^4))*t}

{v__11 = (conjugate(lambda__1)-`#msub(mi("&lambda;",fontstyle = "normal"),mn("1"))`)*x+(4*alpha__1*(conjugate(lambda__1)^3-lambda__1^3)+2*alpha__2*(conjugate(lambda__1)^2-lambda__1^2)-8*nu*(conjugate(lambda__1)^4-lambda__1^4))*t, v__12 = (conjugate(lambda__1)-`#msub(mi("&lambda;",fontstyle = "normal"),mn("2"))`)*x+(4*alpha__1*(conjugate(lambda__1)^3-lambda__2^3)+2*alpha__2*(conjugate(lambda__1)^2-lambda__2^2)-8*nu*(conjugate(lambda__1)^4-lambda__2^4))*t, v__21 = (conjugate(lambda__2)-`#msub(mi("&lambda;",fontstyle = "normal"),mn("1"))`)*x+(4*alpha__1*(conjugate(lambda__2)^3-lambda__1^3)+2*alpha__2*(conjugate(lambda__2)^2-lambda__1^2)-8*nu*(conjugate(lambda__2)^4-lambda__1^4))*t, v__22 = (conjugate(lambda__2)-`#msub(mi("&lambda;",fontstyle = "normal"),mn("2"))`)*x+(4*alpha__1*(conjugate(lambda__2)^3-lambda__2^3)+2*alpha__2*(conjugate(lambda__2)^2-lambda__2^2)-8*nu*(conjugate(lambda__2)^4-lambda__2^4))*t}

(2)

NULL

A2s2 := Determinant(A2s); dets22 := simplify(A2s2, size); length(%)

8949

(3)

dets22f := simplify(subs(vvalue, dets22))

NULL

Download sol1det.mw

Hi,

I am trying to automatically combine plots that I created with an index: ex. IP[i] := plot(...

I can combine them manually, but the maximum value of i can be almost any number greater than 1, and I don’t want to edit things all the time. i can also be very big. I have tried several random ways of embedding the index, but I’ve had no success.

Any ideas? Thanks.

Jno.

First 19 20 21 22 23 24 25 Last Page 21 of 43