Maple 2024 Questions and Posts

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

I’ve spent considerable effort trying to understand how the solution was derived, particularly the approach involving the factoring of G′/G. Despite my attempts, the methodology remains elusive. It seems there’s an innovative idea at play here—something beyond the techniques we’ve applied in similar problems before. While I suspect it involves a novel perspective, I can’t quite pinpoint what it might be.

If anyone has insights into how this factoring is achieved or can shed light on the underlying idea, I’d greatly appreciate your help.


 

restart

with(PDEtools)

with(LinearAlgebra)

with(Physics)

with(SolveTools)

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

(1)

_local(gamma)

Warning, A new binding for the name `gamma` has been created. The global instance of this name is still accessible using the :- prefix, :-`gamma`.  See ?protect for details.

 

declare(Omega(x, t)); declare(U(xi)); declare(u(x, y, z, t)); declare(Q(xi)); declare(V(xi))

Omega(x, t)*`will now be displayed as`*Omega

 

U(xi)*`will now be displayed as`*U

 

u(x, y, z, t)*`will now be displayed as`*u

 

Q(xi)*`will now be displayed as`*Q

 

V(xi)*`will now be displayed as`*V

(2)

``

ode := (-V*a[2]+a[1])*(diff(diff(U(xi), xi), xi))+U(xi)*(((-gamma+sigma)*k+b)*U(xi)^2-a[1]*k^2+(w*a[2]-alpha)*k-w) = 0

(-V*a[2]+a[1])*(diff(diff(U(xi), xi), xi))+U(xi)*(((-gamma+sigma)*k+b)*U(xi)^2-a[1]*k^2+(w*a[2]-alpha)*k-w) = 0

(3)

F := sum(c[i]*(m+(diff(G(xi), xi))/G(xi))^i, i = -1 .. 1)

c[-1]/(m+(diff(G(xi), xi))/G(xi))+c[0]+c[1]*(m+(diff(G(xi), xi))/G(xi))

(4)

D1 := diff(F, xi)

-c[-1]*((diff(diff(G(xi), xi), xi))/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)/(m+(diff(G(xi), xi))/G(xi))^2+c[1]*((diff(diff(G(xi), xi), xi))/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)

(5)

S := diff(G(xi), `$`(xi, 2)) = -(2*m*mu+lambda)*(diff(G(xi), xi))-mu

diff(diff(G(xi), xi), xi) = -(2*m*mu+lambda)*(diff(G(xi), xi))-mu

(6)

E1 := subs(S, D1)

-c[-1]*((-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)/(m+(diff(G(xi), xi))/G(xi))^2+c[1]*((-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)

(7)

D2 := diff(E1, xi)

2*c[-1]*((-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)*((diff(diff(G(xi), xi), xi))/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)/(m+(diff(G(xi), xi))/G(xi))^3-c[-1]*(-(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))/G(xi)-(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2-2*(diff(G(xi), xi))*(diff(diff(G(xi), xi), xi))/G(xi)^2+2*(diff(G(xi), xi))^3/G(xi)^3)/(m+(diff(G(xi), xi))/G(xi))^2+c[1]*(-(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))/G(xi)-(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2-2*(diff(G(xi), xi))*(diff(diff(G(xi), xi), xi))/G(xi)^2+2*(diff(G(xi), xi))^3/G(xi)^3)

(8)

E2 := subs(S, D2)

2*c[-1]*((-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)^2/(m+(diff(G(xi), xi))/G(xi))^3-c[-1]*(-(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+2*(diff(G(xi), xi))^3/G(xi)^3)/(m+(diff(G(xi), xi))/G(xi))^2+c[1]*(-(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+2*(diff(G(xi), xi))^3/G(xi)^3)

(9)

D3 := diff(E2, xi)

-6*c[-1]*((-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)^2*((diff(diff(G(xi), xi), xi))/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)/(m+(diff(G(xi), xi))/G(xi))^4+4*c[-1]*((-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)*(-(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))/G(xi)-(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2-2*(diff(G(xi), xi))*(diff(diff(G(xi), xi), xi))/G(xi)^2+2*(diff(G(xi), xi))^3/G(xi)^3)/(m+(diff(G(xi), xi))/G(xi))^3+2*c[-1]*(-(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+2*(diff(G(xi), xi))^3/G(xi)^3)*((diff(diff(G(xi), xi), xi))/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)/(m+(diff(G(xi), xi))/G(xi))^3-c[-1]*((2*m*mu+lambda)^2*(diff(diff(G(xi), xi), xi))/G(xi)+(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+3*(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))*(diff(G(xi), xi))/G(xi)^2+6*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))^2/G(xi)^3-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(diff(G(xi), xi), xi))/G(xi)^2+6*(diff(G(xi), xi))^2*(diff(diff(G(xi), xi), xi))/G(xi)^3-6*(diff(G(xi), xi))^4/G(xi)^4)/(m+(diff(G(xi), xi))/G(xi))^2+c[1]*((2*m*mu+lambda)^2*(diff(diff(G(xi), xi), xi))/G(xi)+(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+3*(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))*(diff(G(xi), xi))/G(xi)^2+6*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))^2/G(xi)^3-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(diff(G(xi), xi), xi))/G(xi)^2+6*(diff(G(xi), xi))^2*(diff(diff(G(xi), xi), xi))/G(xi)^3-6*(diff(G(xi), xi))^4/G(xi)^4)

(10)

E3 := subs(S, D3)

-6*c[-1]*((-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)^3/(m+(diff(G(xi), xi))/G(xi))^4+6*c[-1]*((-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)*(-(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+2*(diff(G(xi), xi))^3/G(xi)^3)/(m+(diff(G(xi), xi))/G(xi))^3-c[-1]*((2*m*mu+lambda)^2*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)+4*(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+12*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))^2/G(xi)^3-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2/G(xi)^2-6*(diff(G(xi), xi))^4/G(xi)^4)/(m+(diff(G(xi), xi))/G(xi))^2+c[1]*((2*m*mu+lambda)^2*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)+4*(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+12*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))^2/G(xi)^3-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2/G(xi)^2-6*(diff(G(xi), xi))^4/G(xi)^4)

(11)

``

NULL

K := U(xi) = F

K1 := diff(U(xi), xi) = E1

K2 := diff(U(xi), `$`(xi, 2)) = E2

K3 := diff(U(xi), `$`(xi, 3)) = E3

``

L := eval(ode, {K, K1, K2, K3})

(-V*a[2]+a[1])*(2*c[-1]*((-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-(diff(G(xi), xi))^2/G(xi)^2)^2/(m+(diff(G(xi), xi))/G(xi))^3-c[-1]*(-(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+2*(diff(G(xi), xi))^3/G(xi)^3)/(m+(diff(G(xi), xi))/G(xi))^2+c[1]*(-(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/G(xi)-3*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(G(xi), xi))/G(xi)^2+2*(diff(G(xi), xi))^3/G(xi)^3))+(c[-1]/(m+(diff(G(xi), xi))/G(xi))+c[0]+c[1]*(m+(diff(G(xi), xi))/G(xi)))*(((-gamma+sigma)*k+b)*(c[-1]/(m+(diff(G(xi), xi))/G(xi))+c[0]+c[1]*(m+(diff(G(xi), xi))/G(xi)))^2-a[1]*k^2+(w*a[2]-alpha)*k-w) = 0

(12)

NULL

# rewritting rule

RR := isolate(m+diff(G(xi), xi)/(G(xi))=Phi, diff(G(xi), xi)/G(xi));

(diff(G(xi), xi))/G(xi) = Phi-m

(13)

# Apply RR and collect wrt Phi

subs(RR, L):
normal(%):
PhiN := collect(numer(lhs(%)), phi):
PhiD := denom(lhs(%%));

Phi^3*G(xi)^4

(14)



with(LargeExpressions):

LLE := collect(PhiN, Phi, Veil[phi] ):
LLE / PhiD = 0;

(Phi^6*phi[1]+3*Phi^5*phi[2]-Phi^4*phi[3]-Phi^3*phi[4]-Phi^2*phi[5]+Phi*phi[6]-phi[7])/(Phi^3*G(xi)^4) = 0

(15)

# phi[i] coefficients


phis := [ seq( phi[i] = simplify(Unveil[phi](phi[i]), size), i=1..LastUsed[phi] ) ]:

print~( phis ):

phi[1] = c[1]^3*G(xi)^4*((-gamma+sigma)*k+b)

 

phi[2] = c[0]*G(xi)^4*c[1]^2*((-gamma+sigma)*k+b)

 

phi[3] = -3*G(xi)^4*c[1]*(-(1/3)*a[1]*k^2+(-c[-1]*(gamma-sigma)*c[1]+(-gamma+sigma)*c[0]^2+(1/3)*w*a[2]-(1/3)*alpha)*k+b*c[-1]*c[1]+b*c[0]^2-(1/3)*w)

 

phi[4] = G(xi)*(2*c[1]*(V*a[2]-a[1])*(diff(G(xi), xi))^3+3*c[1]*G(xi)*(2*m*mu+lambda)*(V*a[2]-a[1])*(diff(G(xi), xi))^2+((2*m*mu+lambda)^2*G(xi)+3*mu)*(V*a[2]-a[1])*G(xi)*c[1]*(diff(G(xi), xi))+G(xi)^2*(-c[0]*(6*c[-1]*((-gamma+sigma)*k+b)*c[1]-a[1]*k^2+k*w*a[2]+((-gamma+sigma)*k+b)*c[0]^2-k*alpha-w)*G(xi)+c[1]*mu*(2*m*mu+lambda)*(V*a[2]-a[1])))

 

phi[5] = -3*G(xi)^4*(-(1/3)*a[1]*k^2+(-c[-1]*(gamma-sigma)*c[1]+(-gamma+sigma)*c[0]^2+(1/3)*w*a[2]-(1/3)*alpha)*k+b*c[-1]*c[1]+b*c[0]^2-(1/3)*w)*c[-1]

 

phi[6] = 4*c[-1]*((1/2)*(V*a[2]-a[1])*(diff(G(xi), xi))^3+(3/2)*(m*mu+(1/2)*lambda)*(V*a[2]-a[1])*G(xi)*(diff(G(xi), xi))^2+(V*a[2]-a[1])*((m*mu+(1/2)*lambda)^2*G(xi)+(3/4)*mu)*G(xi)*(diff(G(xi), xi))+(1/2)*G(xi)^2*((3/2)*c[-1]*((-gamma+sigma)*k+b)*c[0]*G(xi)+(m*mu+(1/2)*lambda)*(V*a[2]-a[1])*mu))*G(xi)

 

phi[7] = 8*((1/4)*(V*a[2]-a[1])*(diff(G(xi), xi))^4+(V*a[2]-a[1])*G(xi)*(m*mu+(1/2)*lambda)*(diff(G(xi), xi))^3+(V*a[2]-a[1])*G(xi)*((m*mu+(1/2)*lambda)^2*G(xi)+(1/2)*mu)*(diff(G(xi), xi))^2+(V*a[2]-a[1])*G(xi)^2*(m*mu+(1/2)*lambda)*mu*(diff(G(xi), xi))+(1/4)*G(xi)^2*(-(1/2)*((-gamma+sigma)*k+b)*c[-1]^2*G(xi)^2+mu^2*(V*a[2]-a[1])))*c[-1]

(16)

# WATCHOUT: you have 9 coefficients and so its desirable to have the same number of unknowns

unknowns := indets(rhs~(phis), name);

COEFFS := solve(rhs~(phis), unknowns)

{V, alpha, b, gamma, k, lambda, m, mu, sigma, w, xi, a[1], a[2], c[-1], c[0], c[1]}

 

Error, (in solve) cannot solve expressions with diff(G(xi),xi) for xi

 

NULL

case1 := COEFFS[4]

{alpha = alpha, beta = gamma, delta = delta, gamma = gamma, k = k, lambda = 0, m = 2*n, mu = mu, n = n, sigma = 32*alpha*mu^2*n^4/a[-1]^2, w = -2*alpha*k^2*n-4*alpha*mu^2*n+delta^2, a[-1] = a[-1], a[0] = 0, a[1] = 0}

(17)

NULL

F1 := subs(case1, F)

a[-1]/(2*n+1/(diff(G(xi), xi)))

(18)

F2 := subs(case1, ode)

128*V(xi)^4*n^6*alpha*mu^2/a[-1]^2+(16*alpha*k^2*n^4-8*delta^2*n^3+8*n^3*(-2*alpha*k^2*n-4*alpha*mu^2*n+delta^2))*V(xi)^2-4*V(xi)*(diff(diff(V(xi), xi), xi))*alpha*n^2 = 0

(19)

W := V(xi) = F1

V(xi) = a[-1]/(2*n+1/(diff(G(xi), xi)))

(20)

NULL

E := diff(G(xi), xi) = -(-2*m*mu-lambda)*exp(-(2*m*mu+lambda)*xi)*c__1/(2*m*mu+lambda)-mu/(2*m*mu+lambda)

diff(G(xi), xi) = -(-2*m*mu-lambda)*exp(-(2*m*mu+lambda)*xi)*c__1/(2*m*mu+lambda)-mu/(2*m*mu+lambda)

(21)

W1 := subs(E, W)

V(xi) = a[-1]/(2*n+1/(-(-2*m*mu-lambda)*exp(-(2*m*mu+lambda)*xi)*c__1/(2*m*mu+lambda)-mu/(2*m*mu+lambda)))

(22)

W2 := subs(case1, W1)

V(xi) = a[-1]/(2*n+1/(exp(-4*mu*n*xi)*c__1-(1/4)/n))

(23)

W3 := rhs(V(xi) = a[-1]/(2*n+1/(exp(-4*mu*n*xi)*c__1-(1/4)/n)))

a[-1]/(2*n+1/(exp(-4*mu*n*xi)*c__1-(1/4)/n))

(24)

W4 := convert(W3, trig)

a[-1]/(2*n+1/((cosh(4*mu*n*xi)-sinh(4*mu*n*xi))*c__1-(1/4)/n))

(25)

W5 := W4

a[-1]/(2*n+1/((cosh(4*mu*n*xi)-sinh(4*mu*n*xi))*c__1-(1/4)/n))

(26)

odetest(W2, F2)

0

(27)
 

``

Download problem99.mw

In this activity, we are trying to simulate an outbreak of a new infectious disease that our population of 10^6people has not been exposed to before. This means that we are starting with a single case, everyone else is susceptible to the disease, and no one is yet immune or recovered. This can for example reflect a situation where an infected person introduces a new disease into a geographically isolated population, like on an island, or even when an infections "spill over" from other animals into a human population. In terms of the initial conditions for our model, we can define: "S=10^(6) -1=999999," I = 0and R = 0. NULL

Remember, the differential equations for the simple SIR model look like this:

dS/dt = `λS`*dI/dt and `λS`*dI/dt = `λS`-I*gamma, dR/dt = I*gamma

Initial number of people in each compartment
S = 10^6-1",I=0  "and R = 0.

NULL

Parameters:

gamma = .1*recovery*rate*beta and .1*recovery*rate*beta = .4*the*daily*infection*rate

restart; with(plots); _local(gamma)

sys := diff(s(t), t) = -lambda*s(t), diff(i(t), t) = lambda*s(t)-gamma*i(t), diff(r(t), t) = gamma*i(t)

diff(s(t), t) = -lambda*s(t), diff(i(t), t) = lambda*s(t)-gamma*i(t), diff(r(t), t) = gamma*i(t)

(1)

ic := s(0) = s__0, i(0) = i__0, r(0) = r__0

gamma := .1; beta := .4; n := 10^6

.1

 

.4

 

1000000

(2)

lambda := beta*i(t)/n

s__0, i__0, r__0 := 10^6-1, 1, 0

NULL

sols := dsolve({ic, sys}, numeric, output = listprocedure)

display([odeplot(sols, [t, s(t)], 0 .. 100, color = red), odeplot(sols, [t, i(t)], 0 .. 100, color = blue), odeplot(sols, [t, r(t)], 0 .. 100, color = green)], labels = ["Time [day]", "Population"], labeldirections = [horizontal, vertical], legend = ["Susceptible", "Infected", "Recovered"], legendstyle = [location = right])

 

Remember that in a simple homogenous SIR model, `R__eff  `is directly related to the proportion of the population that is susceptible:

R__eff = R__0*S/N

Reff := proc (t) options operator, arrow; beta*s(t)/(gamma*n) end proc

odeplot(sols, [[t, Reff(t)]], t = 0 .. 100, size = [500, 300], labels = ["Time [day]", "Reff"], labeldirections = [horizontal, vertical])

 

The effective reproduction number is highest when everyone is susceptible: at the beginning, `R__eff  ` = R__0. At this point in our example, every infected cases causes an average of 4 secondary infections. Over the course of the epidemic, `R__eff  ` declines in proportion to susceptibility.

The peak of the epidemic happens when `R__eff  ` goes down to 1 (in the example here, after 50 days). As `R__eff  `decreases further below 1, the epidemic prevalence goes into decline. This is exactly what you would expect, given your understanding of the meaning of `R__eff  ` once the epidemic reaches the point where every infected case cannot cause at least one more infected case (that is, when `R__eff  ` < 1), the epidemic cannot sustain itself and comes to an end.

susceptible := eval(s(t), sols); infected := eval(i(t), sols); recovered := eval(r(t), sols)

susceptible(51)

HFloat(219673.04834159758)

(3)

infected(51)

HFloat(401423.4112878752)

(4)

recovered(51)

HFloat(378903.54037052736)

(5)

Reffe := proc (t) options operator, arrow; beta*susceptible(t)/(gamma*n) end proc

proc (t) options operator, arrow; beta*susceptible(t)/(gamma*n) end proc

(6)

Reffe(51)

HFloat(0.8786921933663903)

(7)

Prevalence is simply the value of Iat a given point in time. Now we can see that the incidence is the number of new cases arriving in the I compartment in a given interval of time. The way we represent this mathematically is by taking the integral of new cases over a given duration.

For example, if we wanted to calculate the incidence from day 7 to 14,

int(`&lambda;S`(t), t = 7 .. 14)

lamda := proc (t) options operator, arrow; beta*infected(t)/n end proc

proc (t) options operator, arrow; beta*infected(t)/n end proc

(8)

inflow := proc (t) options operator, arrow; lamda(t)*susceptible(t) end proc

proc (t) options operator, arrow; lamda(t)*susceptible(t) end proc

(9)

int(inflow(t), t = 7 .. 14)

HFloat(78.01804723222038)

(10)

incidence_plot := plot(inflow(t), t = 0 .. 14, color = orange, labels = ["Time (days)", "Incidence Rate"], labeldirections = [horizontal, vertical], title = "Incidence Rate between t=7 and t=14")

 

s, i, r := eval(s(t), sols), eval(i(t), sols), eval(r(t), sols); T := 100; dataArr := Array(-1 .. T, 1 .. 4); dataArr[-1, () .. ()] := `<,>`("Day", "Susceptible", "Infected", "Recovered")


Assign all the subsequent rows

for t from 0 to T do dataArr[t, () .. ()] := `~`[round](`<,>`(t, s(t), i(t), r(t))) end do

 

Tabulate through the DocumentTools

DocumentTools:-Tabulate(dataArr, alignment = left, width = 50, fillcolor = (proc (A, n, m) options operator, arrow; ifelse(n = 1, "DeepSkyBlue", "LightBlue") end proc))

Download dynamics_of_novel_disease_outbreak.mw

I have a global matrix with a default value set in a module. I also need the inverse of the matrix. Can the module do this?  I don't really want to have to get routines to calculate the inverse every time they are called.

restart

``

TM := module () local invMetric; export foo, bar; global Metric;  Metric := Matrix(3, shape = symmetric, [[1, 0, 0], [0, 1, 0], [0, 0, 1]]); invMetric := LinearAlgebra:-MatrixInverse(rtable_eval(Metric, 'inplace')); foo := proc () print('Metric' = Metric) end proc; bar := proc () print('invMetric' = invMetric) end proc end module

_m2278573910560

(1)

TM:-foo()

Metric = Matrix(%id = 36893490426002737860)

(2)

TM:-bar()

invMetric = Matrix(%id = 36893490426002738460)

(3)

Metric := Matrix(3, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = -2})

Matrix(%id = 36893490426002715820)

(4)

TM:-foo()

Metric = Matrix(%id = 36893490426002715820)

(5)

TM:-bar()

invMetric = Matrix(%id = 36893490426002738460)

(6)

NULL

Download 2024-12-30_Q_Module_Global_and_Local.mw

I use this type ckect elsewhere inside a package and it works. I can't get it to work in a stand alone procedure.

This was originally provided by @acer (best answer) in this question Experimental format for projective vectors - MaplePrimes

restart

 

 

test:=proc(V::{And('Vector(1)',satisfies( v->type(v[1],'Vector[:-column](3)') ) ),
               And('Vector(1)',satisfies( v->type(v[1],'Vector[:-row](3)') ) )})
print("works",V);
end proc

proc (V::{And('Vector(1)', satisfies(proc (v) options operator, arrow; type(v[1], 'Vector[:-column](3)') end proc)), And('Vector(1)', satisfies(proc (v) options operator, arrow; type(v[1], 'Vector[:-row](3)') end proc))}) print("works", V) end proc

(1)

v1:=<[<1,3,2>]>;
v2:=<[<a|b|c>]>

Vector(1, {(1) = Vector(3, {(1) = 1, (2) = 3, (3) = 2})})

 

Vector[column](%id = 36893490573309309044)

(2)

test(v1)

Error, invalid input: test expects its 1st argument, V, to be of type {And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-column](3)'))), And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-row](3)')))}, but received Vector(1, [Vector(3, [1,3,2])])

 

test(v2)

Error, invalid input: test expects its 1st argument, V, to be of type {And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-column](3)'))), And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-row](3)')))}, but received Vector(1, [Vector[row](3, [a,b,c])])

 

whattype(v1)

Vector[column]

(3)

whattype(v1[1])

Vector[column]

(4)

whattype(v2)

Vector[column]

(5)

whattype(v2[1])

Vector[row]

(6)
 

 

Download 2024-12-29_Q_Type_checking_not_working.mw

A street of finite length has many houses on one side, which are numbered in consecutive order with 1, 2, 3, 4, ... Determine all house numbers where the sum of all house numbers before this house number is equal to the sum of all house numbers after it.

That's enough for this year.
I wish everyone a happy new year 2025.

Given 4 hummingbirds, each located at the vertex of a unit tetrahedron.
The birds begin to fly in such a way that all birds fly at the same speed and:
(1) Bird #1 always flies directly toward bird #2
(2) Bird #2 always flies directly toward bird #3
(3) Bird #3 always flies directly toward bird #4
(4) Bird #4 always flies directly toward bird #1
As one can imagine, the flying birds eventually meet and collide. (Assume the birds are very small.)

What is needed is the distance to the collision point of the hummingbirds.

Recently, I read an old article about how to call external subroutines to speed up the evaluation tremendously. The core of that article is: 

Evidently, the Typesetting:-mrow(Typesetting:-mi( is equivalent to  when b>0, and the `∸`(a, b) is equivalent to . 
The 𝙲 code in that article was composed separately. However, now that it is possible to generate external functions, compile and access them using a single Compiler:-Compile command, it is better to complete the entire process on the fly (in order to reduce oversights and typographical errors while coding). (Besides, the original 𝙼𝚊𝚙𝚕𝚎 implementation appears verbose and less elegant.) So I write: 

JonesM1 := Compiler:-Compile((n::posint) -> add(max(1 - max(add(ifelse(j = 0, max(j - 1, 0)!**2, irem(max(j - 1, 0)!**2, j)), j = 0 .. i) - n, 0), 0), i = 0 .. n**2), 'O' = 2): # literal translation of the above formula 

But unfortunately, I then get: 

JonesM1(1);
                               2

JonesM1(2);
                               3

JonesM1(3);
                               5

JonesM1(4);
Error, (in JonesM1) integer overflow detected in compiled code

How do I get rid of this error message? 

Note. Of course there exist a ready-to-use built-in function , but the chief aim is not to find the n-th prime number as quickly as possible; I want to see if 𝙼𝚊𝚙𝚕𝚎 can directly create a compiled version of the one-liner that implements the so-called Jones' algorithm instead of writing separate 𝙲 code like that article. (Don't confound the means with the ends.) 

I do not remember if I reported this before or not. Can't find it. Just in case, I am posting this.

If someone find it is duplicate, feel free to delete this. But this is in latest Maple 2024.2. May be this can be fixed in time by Maple 2025 version.

restart;

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1840 and is the same as the version installed in this computer, created 2024, December 2, 10:11 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

ode := diff(y(x),x)/y(x)-(3*(4*x^2+y(x)^2+1))/(2*x*(4*x^2+y(x)^2-2-2*x))=0;

(diff(y(x), x))/y(x)-(3/2)*(4*x^2+y(x)^2+1)/(x*(4*x^2+y(x)^2-2-2*x)) = 0

DEtools:-odeadvisor(ode);

[_rational]

dsolve(ode,y(x));

Error, (in dsolve) invalid subscript selector

restart;

infolevel[dsolve]:=5;

5

ode := diff(y(x),x)/y(x)-(3*(4*x^2+y(x)^2+1))/(2*x*(4*x^2+y(x)^2-2-2*x))=0:

dsolve(ode,y(x));

Methods for first order ODEs:

--- Trying classification methods ---

trying a quadrature

trying 1st order linear

trying Bernoulli

trying separable

trying inverse linear

trying homogeneous types:

trying Chini

differential order: 1; looking for linear symmetries

trying exact

Looking for potential symmetries

trying inverse_Riccati

trying an equivalence to an Abel ODE

equivalence obtained to this Abel ODE: diff(y(x),x) = 3/2*(4*x^2+1)/x/(2*x^2-x-1)*y(x)-(x^2+2*x+3)/x/(2*x^2-x-1)^2*y(x)^2+3/8*(2*x+3)/(2*x^2-x-1)^3/x*y(x)^3

trying to solve the Abel ODE ...

The relative invariant s3 is: -1/432*(8*x^4+40*x^3+45*x^2-270*x+135)/x^3/(x-1)^6/(2*x+1)^4

The first absolute invariant s5^3/s3^5 is: 729/16*(128*x^8+1152*x^7+3696*x^6+1744*x^5+8148*x^4-31500*x^3+6615*x^2-5670*x+8505)^3/(2*x+1)^4/(8*x^4+40*x^3+45*x^2-270*x+135)^5

The second absolute invariant s3*s7/s5^2 is: 1/3*(8*x^4+40*x^3+45*x^2-270*x+135)*(10240*x^12+133120*x^11+697600*x^10+1710080*x^9+3358592*x^8-1701568*x^7+6692592*x^6-18182448*x^5+2088072*x^4-7938000*x^3+2525985*x^2+1786050*x+2679075)/(128*x^8+1152*x^7+3696*x^6+1744*x^5+8148*x^4-31500*x^3+6615*x^2-5670*x+8505)^2

...checking Abel class AIL (45)

...checking Abel class AIL (310)

...checking Abel class AIR (36)

...checking Abel class AIL (301)

...checking Abel class AIL (1000)

...checking Abel class AIL (42)

...checking Abel class AIL (185)

...checking Abel class AIA (by Halphen)

...checking Abel class AIL (205)

...checking Abel class AIA (147)

...checking Abel class AIL (581)

...checking Abel class AIL (200)

...checking Abel class AIL (257)

...checking Abel class AIL (400)

...checking Abel class AIA (515)

...checking Abel class AIR (1001)

...checking Abel class AIA (201)

...checking Abel class AIA (815)

Looking for potential symmetries

... changing x -> 1/x, trying again

Looking for potential symmetries

The third absolute invariant s5*s7/s3^4 is: 243/16*(10240*x^12+133120*x^11+697600*x^10+1710080*x^9+3358592*x^8-1701568*x^7+6692592*x^6-18182448*x^5+2088072*x^4-7938000*x^3+2525985*x^2+1786050*x+2679075)/(2*x+1)^4*(128*x^8+1152*x^7+3696*x^6+1744*x^5+8148*x^4-31500*x^3+6615*x^2-5670*x+8505)/(8*x^4+40*x^3+45*x^2-270*x+135)^4

 ->         ======================================

 ->             ...checking Abel class D (by Appell)

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {4/27} ***

 -> Step 3: looking for a solution F depending on x

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class B (by Liouville)

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {1, 4, 1/4} ***

 -> Step 3: looking for a solution F depending on x

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class A (by Abel)

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {0, -1/4} ***

 -> Step 3: looking for a solution F depending on x

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class C (by Abel)

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {2, -11676447873119/75975070592769, 9/5, 15632211369872/75439744512117, 46273613050865/52325357771027, 75312059745574/25138886548531} ***

 -> Step 3: looking for a solution F depending on x

_____________________________

C = 9/5 leads to a useless solution (F does not depend on x)

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class AIL 1.6

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {-4, 16} ***

 -> Step 3: looking for a solution F depending on x

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class AIL 1.8

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {0, -116457391291688/45108305127449, -96869842492381/35485755507516, -36964550865207/94238117721032, -32286830321303/11596568583712, 32286830321303/11596568583712, 36964550865207/94238117721032, 96869842492381/35485755507516, 116457391291688/45108305127449} ***

 -> Step 3: looking for a solution F depending on x

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class AIL 1.9

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {-2/9, -1/9} ***

 -> Step 3: looking for a solution F depending on x

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class AIA 1.51

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {0, -94917840318055/84247876515289, -85939756880989/51399391393709, -82210125508529/36853933366676, -74381886667083/82545981233858, -41168492684238/33804146399567, -15658703496425/19275443365317, -9175348901453/101481647952193, 3/4, 15/4, 5568553686203/113599855351490, 12774469621703/63437040534358, 17836021821409/102823494563886, 39657708622139/74009717243016, 82495450887526/27663991325651, 86656182727564/45157560524183, 90074893410229/54954593917906, 100200889070747/32282555481919, 113612565327585/103754255779069} ***

 -> Step 3: looking for a solution F depending on x

_____________________________

C = 15/4 leads to a useless solution (F does not depend on x)

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class AIA 1.5

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {-1, 1, -113553630998996/78694251194667, -112790344818825/35834119404842, -104905620984375/18860524785743, -95409943222181/78810323073434, -77648002983645/31218435062578, -67259194033608/9576982470445, -46892223838816/86694928762723, -45901561561111/29768419326991, -34674701564566/6522678435631, 26154715634141/21099761863911, 42841215778132/81925179545457, 52638927823233/15127919203723, 54069389554571/5444364811188, 54445812264368/10328928623117, 56815569067370/40738034746481, 75614540760757/62881656939350, 76459718737483/64786816765621, 85896394925571/88677987470966, 90623073438172/24246571690325, 103628692054633/17857341616628, 117754725919014/60191028908095} ***

 -> Step 3: looking for a solution F depending on x

_____________________________

C = -1 leads to a useless solution (F does not depend on x)

_____________________________

C = -113553630998996/78694251194667 leads to a useless solution (F does not depend on x)

_____________________________

C = -112790344818825/35834119404842 leads to a useless solution (F does not depend on x)

_____________________________

C = -104905620984375/18860524785743 leads to a useless solution (F does not depend on x)

_____________________________

C = -95409943222181/78810323073434 leads to a useless solution (F does not depend on x)

_____________________________

C = -77648002983645/31218435062578 leads to a useless solution (F does not depend on x)

_____________________________

C = -67259194033608/9576982470445 leads to a useless solution (F does not depend on x)

_____________________________

C = -46892223838816/86694928762723 leads to a useless solution (F does not depend on x)

_____________________________

C = -45901561561111/29768419326991 leads to a useless solution (F does not depend on x)

_____________________________

C = -34674701564566/6522678435631 leads to a useless solution (F does not depend on x)

_____________________________

C = 26154715634141/21099761863911 leads to a useless solution (F does not depend on x)

_____________________________

C = 42841215778132/81925179545457 leads to a useless solution (F does not depend on x)

_____________________________

C = 52638927823233/15127919203723 leads to a useless solution (F does not depend on x)

_____________________________

C = 54069389554571/5444364811188 leads to a useless solution (F does not depend on x)

_____________________________

C = 54445812264368/10328928623117 leads to a useless solution (F does not depend on x)

_____________________________

C = 56815569067370/40738034746481 leads to a useless solution (F does not depend on x)

_____________________________

C = 75614540760757/62881656939350 leads to a useless solution (F does not depend on x)

_____________________________

C = 76459718737483/64786816765621 leads to a useless solution (F does not depend on x)

_____________________________

C = 85896394925571/88677987470966 leads to a useless solution (F does not depend on x)

_____________________________

C = 90623073438172/24246571690325 leads to a useless solution (F does not depend on x)

_____________________________

C = 103628692054633/17857341616628 leads to a useless solution (F does not depend on x)

_____________________________

C = 117754725919014/60191028908095 leads to a useless solution (F does not depend on x)

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class AIA 1.52

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {-5, -4, -3, 0, 1, 2, -3/2} ***

 -> Step 3: looking for a solution F depending on x

*** No solution F of x was found ***

 ->         ======================================

 ->             ...checking Abel class AIA 1.53

 -> Step 1: checking for a disqualifying factor on F after evaluating x at a number

Trying x = 2

*** No disqualifying factor on F was found ***

 -> Step 2: calculating resultants to eliminate F and get candidates for C

*** Candidates for C are {-3, -1, 1, 2, -3/2, -2/3, -1/2} ***

 -> Step 3: looking for a solution F depending on x

_____________________________

C = -3 leads to a useless solution (F does not depend on x)

_____________________________

C = -3/2 leads to a useless solution (F does not depend on x)

*** No solution F of x was found ***

trying to map the Abel into a solvable 2nd order ODE

...checking Abel class AIA 2-parameter, reducible to Riccati

Error, (in dsolve) invalid subscript selector

restart;

ode := diff(y(x),x)/y(x)-(3*(4*x^2+y(x)^2+1))/(2*x*(4*x^2+y(x)^2-2-2*x))=0:

dsolve(ode,y(x));

Error, (in dsolve) invalid subscript selector

tracelast;

Error, (in dsolve) invalid subscript selector

 

 

Download dsolve_invalid_subscript_dec_27_2024.mw

I am working on visualizing the results of an SIR model in Maple. I’ve created multiple plots for different parameter values using dsolve and odeplot, and I’d like to arrange them in a grid (e.g., 2 rows x 3 columns) for easier comparison. Here’s what I’ve tried:

restart; with(plots); n := 10^6; s__0 := n-1; i__0 := 1; r__0 := 0; simulate_SIR := proc (beta, gamma) local lambda, sys, ic, sols, single_plot; lambda := beta*i(t)/n; sys := diff(s(t), t) = -lambda*s(t), diff(i(t), t) = lambda*s(t)-gamma*i(t), diff(r(t), t) = gamma*i(t); ic := s(0) = s__0, i(0) = i__0, r(0) = r__0; sols := dsolve({sys, ic}, numeric, output = listprocedure); single_plot := display([odeplot(sols, [t, s(t)], 0 .. 60, color = red), odeplot(sols, [t, i(t)], 0 .. 60, color = blue), odeplot(sols, [t, r(t)], 0 .. 60, color = green)], labels = ["Time [day]", "Population"], labeldirections = [horizontal, vertical], legend = ["Susceptible", "Infected", "Recovered"], legendstyle = [location = right]); return single_plot end proc; plot1 := simulate_SIR(.1, .1); plot2 := simulate_SIR(.2, .1); plot3 := simulate_SIR(.7, .1); plot4 := simulate_SIR(1.5, .1); plot5 := simulate_SIR(1, 0.25e-1); plot6 := simulate_SIR(1, .2); plot7 := simulate_SIR(1, .5); plot8 := simulate_SIR(1, 1); combined_plot := display([plot1, plot2, plot3, plot4, plot5, plot6, plot7, plot8], insequence = true, view = [0 .. 60, 0 .. n], grid = [2, 4]); combined_plot

 
 

NULL

Download grid.mw

Unfortunately, the insequence=true and gird=[2, 4] options didn’t work as I expected. Instead of arranging the plots in a grid, they appear like an animation

How can I correctly arrange multiple plots into a grid layout in Maple? Are there specific options or steps I’m missing? I would appreciate any guidance or examples.

I did a lot  of time but this time i don't know why not run any one have idea?

restart

with(PDEtools)

with(LinearAlgebra)

with(Physics)

with(SolveTools)

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

(1)

declare(u(x, t)); declare(U(xi)); declare(G(xi))

u(x, t)*`will now be displayed as`*u

 

U(xi)*`will now be displayed as`*U

 

G(xi)*`will now be displayed as`*G

(2)

T := xi = -V*t+x; T1 := u(x, t) = U(-V*t+x)*exp(I*(-k*x+t*w+theta))

xi = -V*t+x

 

u(x, t) = U(-V*t+x)*exp(I*(-k*x+t*w+theta))

(3)

P3 := diff(u(x, t), x, t)

``

(4)

P33 := diff(u(x, t), x)

diff(u(x, t), x)

(5)

P333 := diff(P33, t)

NULL

Download why.mw

I already get the same results, but there's something about the factoring process that I encountered for the first time in this ODE. In the paper, it says that G′ satisfies a certain condition, but I’m not sure exactly what that means. Did the author use it for substitution, or did they change (m+F) into another variable and then solve? I’m not exactly sure what approach was taken. Does anyone have any idea or insight into this?

restart

with(PDEtools)

with(LinearAlgebra)

NULL

with(SolveTools)

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

(1)

declare(Omega(x, t)); declare(U(xi)); declare(u(x, y, z, t)); declare(Q(xi))

Omega(x, t)*`will now be displayed as`*Omega

 

U(xi)*`will now be displayed as`*U

 

u(x, y, z, t)*`will now be displayed as`*u

 

Q(xi)*`will now be displayed as`*Q

(2)

tr := {t = tau, x = (-ZETA*c[3]-tau*c[4]-`&Upsilon;`*c[2]+xi)/c[1], y = `&Upsilon;`, z = ZETA, u(x, y, z, t) = U(xi)}

{t = tau, x = (-Zeta*c[3]-tau*c[4]-`&Upsilon;`*c[2]+xi)/c[1], y = `&Upsilon;`, z = Zeta, u(x, y, z, t) = U(xi)}

(3)

pde1 := diff(u(x, y, z, t), `$`(x, 3), z)-4*(diff(u(x, y, z, t), x, t))+4*(diff(u(x, y, z, t), x))*(diff(u(x, y, z, t), x, z))+2*(diff(u(x, y, z, t), `$`(x, 2)))*(diff(u(x, y, z, t), z))+3*(diff(u(x, y, z, t), `$`(y, 2))) = 0

diff(diff(diff(diff(u(x, y, z, t), x), x), x), z)-4*(diff(diff(u(x, y, z, t), t), x))+4*(diff(u(x, y, z, t), x))*(diff(diff(u(x, y, z, t), x), z))+2*(diff(diff(u(x, y, z, t), x), x))*(diff(u(x, y, z, t), z))+3*(diff(diff(u(x, y, z, t), y), y)) = 0

(4)

``

L1 := PDEtools:-dchange(tr, pde1, [xi, `&Upsilon;`, ZETA, tau, U])

(diff(diff(diff(diff(U(xi), xi), xi), xi), xi))*c[1]^3*c[3]-4*(diff(diff(U(xi), xi), xi))*c[4]*c[1]+6*(diff(U(xi), xi))*c[1]^2*(diff(diff(U(xi), xi), xi))*c[3]+3*(diff(diff(U(xi), xi), xi))*c[2]^2 = 0

(5)

map(int, (diff(diff(diff(diff(U(xi), xi), xi), xi), xi))*c[1]^3*c[3]-4*(diff(diff(U(xi), xi), xi))*c[4]*c[1]+6*(diff(U(xi), xi))*c[1]^2*(diff(diff(U(xi), xi), xi))*c[3]+3*(diff(diff(U(xi), xi), xi))*c[2]^2 = 0, xi)

c[1]^3*c[3]*(diff(diff(diff(U(xi), xi), xi), xi))+3*c[2]^2*(diff(U(xi), xi))-4*c[4]*c[1]*(diff(U(xi), xi))+3*c[1]^2*c[3]*(diff(U(xi), xi))^2 = 0

(6)

ode := %

c[1]^3*c[3]*(diff(diff(diff(U(xi), xi), xi), xi))+3*c[2]^2*(diff(U(xi), xi))-4*c[4]*c[1]*(diff(U(xi), xi))+3*c[1]^2*c[3]*(diff(U(xi), xi))^2 = 0

(7)

F := sum(a[i]*(m+1/(diff(G(xi), xi)))^i, i = -1 .. 1)

a[-1]/(m+1/(diff(G(xi), xi)))+a[0]+a[1]*(m+1/(diff(G(xi), xi)))

(8)

D1 := diff(F, xi)

a[-1]*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-a[1]*(diff(diff(G(xi), xi), xi))/(diff(G(xi), xi))^2

(9)

S := diff(G(xi), `$`(xi, 2)) = -(2*m*mu+lambda)*(diff(G(xi), xi))-mu

diff(diff(G(xi), xi), xi) = -(2*m*mu+lambda)*(diff(G(xi), xi))-mu

(10)

E1 := subs(S, D1)

a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2

(11)

D2 := diff(E1, xi)

2*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^4)-2*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^3)-a[-1]*(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)+2*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(diff(diff(G(xi), xi), xi))/(diff(G(xi), xi))^3+a[1]*(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))/(diff(G(xi), xi))^2

(12)

E2 := subs(S, D2)

2*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^4)-2*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^3)-a[-1]*(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)+2*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2/(diff(G(xi), xi))^3+a[1]*(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2

(13)

D3 := diff(E2, xi)

6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^4*(diff(G(xi), xi))^6)-12*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^5)-6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^4)+6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^4)+6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^3)+a[-1]*(2*m*mu+lambda)^2*(diff(diff(G(xi), xi), xi))/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-6*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(diff(diff(G(xi), xi), xi))/(diff(G(xi), xi))^4-6*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)*(2*m*mu+lambda)*(diff(diff(G(xi), xi), xi))/(diff(G(xi), xi))^3-a[1]*(2*m*mu+lambda)^2*(diff(diff(G(xi), xi), xi))/(diff(G(xi), xi))^2

(14)

E3 := subs(S, D3)

6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/((m+1/(diff(G(xi), xi)))^4*(diff(G(xi), xi))^6)-12*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^5)-6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(2*m*mu+lambda)/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^4)+6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^4)+6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(2*m*mu+lambda)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^3)+a[-1]*(2*m*mu+lambda)^2*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-6*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/(diff(G(xi), xi))^4-6*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(2*m*mu+lambda)/(diff(G(xi), xi))^3-a[1]*(2*m*mu+lambda)^2*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2

(15)

NULL

NULL

K := U(xi) = F

U(xi) = a[-1]/(m+1/(diff(G(xi), xi)))+a[0]+a[1]*(m+1/(diff(G(xi), xi)))

(16)

K1 := diff(U(xi), xi) = E1

diff(U(xi), xi) = a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2

(17)

K2 := diff(U(xi), `$`(xi, 2)) = E2

diff(diff(U(xi), xi), xi) = 2*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^4)-2*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^3)-a[-1]*(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)+2*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2/(diff(G(xi), xi))^3+a[1]*(2*m*mu+lambda)*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2

(18)

K3 := diff(U(xi), `$`(xi, 3)) = E3

diff(diff(diff(U(xi), xi), xi), xi) = 6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/((m+1/(diff(G(xi), xi)))^4*(diff(G(xi), xi))^6)-12*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^5)-6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(2*m*mu+lambda)/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^4)+6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^4)+6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(2*m*mu+lambda)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^3)+a[-1]*(2*m*mu+lambda)^2*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-6*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/(diff(G(xi), xi))^4-6*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(2*m*mu+lambda)/(diff(G(xi), xi))^3-a[1]*(2*m*mu+lambda)^2*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2

(19)

NULL

L := eval(ode, {K, K1, K2, K3})

c[1]^3*c[3]*(6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/((m+1/(diff(G(xi), xi)))^4*(diff(G(xi), xi))^6)-12*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^5)-6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(2*m*mu+lambda)/((m+1/(diff(G(xi), xi)))^3*(diff(G(xi), xi))^4)+6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^4)+6*a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(2*m*mu+lambda)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^3)+a[-1]*(2*m*mu+lambda)^2*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-6*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^3/(diff(G(xi), xi))^4-6*a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)^2*(2*m*mu+lambda)/(diff(G(xi), xi))^3-a[1]*(2*m*mu+lambda)^2*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2)+3*c[2]^2*(a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2)-4*c[4]*c[1]*(a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2)+3*c[1]^2*c[3]*(a[-1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/((m+1/(diff(G(xi), xi)))^2*(diff(G(xi), xi))^2)-a[1]*(-(2*m*mu+lambda)*(diff(G(xi), xi))-mu)/(diff(G(xi), xi))^2)^2 = 0

(20)

"collect(L,(m+1/(diff(G(xi),xi))))^( )"

Error, (in collect) cannot collect m+1/diff(G(xi),xi)

 
 

NULL

Download factoring.mw

I am trying to see if I can get speed up by using dsolve inside thread.

I made very simple example of global list of two differential equations to start with.

Next, created two threads where each picks one ode from the global list to process. So they should in theory run in parallel. The list of ode's is a global list in the worksheet for now.

But I keep getting error when calling dsolve 

               Error, (in dsolve) type `System` does not exist

I tried also passing the actual ode to the thread, still, same error.

Next, I did not pass anything, but called dsolve directly from inside thread proc on same ode. The ode is local variable inside the proc. I still get same error.

                        Does this mean dsolve is not supported by threads? 

But when I searched this subject, AI says it works in threads:

 

Everything works OK when I run dsolve in worksheet outside thread (i.e. normally).

I will show below worksheet showing these cases. I must not be doing something right. But what? Can one not pass data from global worksheet to the thread this way? Or does one needs to load something in each thread to make this work?

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1840 and is the same as the version installed in this computer, created 2024, December 2, 10:11 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

Example 1. Passing index of list to thread

 

restart;

g_list:=[sin(t)*diff(x(t),t$2)+cos(t)*diff(x(t),t)+2*x(t)=0,
         diff(y(x),x)=lambda*sin(lambda*x)*y(x)^2+a*cos(lambda*x)^n*y(x)-a*cos(lambda*x)^(n-1)]:

work_func:=proc(i::posint)  
  :-dsolve(g_list[i]):
end proc:

Threads:-Wait(  seq( Threads:-Create( work_func(i)), i=1..2) );

Error, (in dsolve) type `System` does not exist

Example 2. Passing actual ode itself to thread

 

restart;

g_list:=[sin(t)*diff(x(t),t$2)+cos(t)*diff(x(t),t)+2*x(t)=0,
         diff(y(x),x)=lambda*sin(lambda*x)*y(x)^2+a*cos(lambda*x)^n*y(x)-a*cos(lambda*x)^(n-1)]:

work_func:=proc(ode::`=`)  
  :-dsolve(ode):
end proc:

Threads:-Wait(  seq( Threads:-Create( work_func(g_list[i])), i=1..2) );

Error, (in dsolve) type `System` does not exist

 

Example 3. Normal processing. No threads

 

restart;

g_list:=[sin(t)*diff(x(t),t$2)+cos(t)*diff(x(t),t)+2*x(t)=0,
         diff(y(x),x)=lambda*sin(lambda*x)*y(x)^2+a*cos(lambda*x)^n*y(x)-a*cos(lambda*x)^(n-1)]:

work_func:=proc(ode::`=`)  
  :-dsolve(ode):
end proc:

for item in g_list do
    work_func(item);
od:

#no error

 

Example 4. do not pass anything. Just call dsolve

 

restart;

work_func:=proc(i::posint)  
  local x,t;
  local ode:=sin(t)*diff(x(t),t$2)+cos(t)*diff(x(t),t)+2*x(t)=0;
  :-dsolve(ode):
end proc:

Threads:-Wait(  seq( Threads:-Create( work_func(i)), i=1..2) );

Error, (in dsolve) type `System` does not exist

 

 

 

Download error_dsolve_using_threads_dec_26_2024.mw

restart;

Here are the graphs of a parabola and a straight line:

plots:-display(
        plot(x^2, x=-1..1),
        plot((x+1)/2, x=-1..1),
color=["Red","Green"]);

 

Suppose I want to plot the part of the parabola that lies below

the straight line, and suppose, just to be nasty, I choose to do it

with implicitplot:

plots:-implicitplot(y=x^2, x=-1..1, y=0..(x+1)/2);

 

That is not a parabola at all.  [And where does the "ynew" label come from?]

 

This behavior was introduced in Maple 2022.

In Maple 2021 we get the expected result:

plots:-implicitplot(y=x^2, x=-1..1, y=0..(x+1)/2);


 

Download mw.mw

I am looking for a more eligent way to convert a Vector to a Diagonal Matrix.

restart

 

 

with(LinearAlgebra):

 

V:=Vector[column](3, [0.5863730366, 0.1171249270, 0.2965020364])

Vector(3, {(1) = .5863730366, (2) = .1171249270, (3) = .2965020364})

(1)

Vm:=Matrix(3,[[V[1],0,0],[0,V[2],0],[0,0,V[3]]])

Matrix(3, 3, {(1, 1) = .5863730366, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = .1171249270, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = .2965020364})

(2)

Vm1:=Matrix(3,3):

for i to 3 do
Vm1[i,i]:=V[i];
end do:

Vm1

Matrix(3, 3, {(1, 1) = .5863730366, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = .1171249270, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = .2965020364})

(3)
 

 

Download 2024-12-26_Q_Diagonal_Matrix_from_Vector.mw

Hello,

This is a simple dynamics example illustrating the behavior of a disc as a pendulum under ideal conditions. Source attached.

Simple_Disk_Pendulum.mw

First 10 11 12 13 14 15 16 Last Page 12 of 40