Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

For the NonlinearFit function in the Statistics package, how can I determine initial values that will allow it to solve and not diverge in this case: NonlinearFit((p1*x^2 + p2*x + p3)/(q1*x + x^2 + q2), Ycg, Sx, x) returns with:

"Warning, limiting number of iterations reached" and displays the coefficient values when it gave up. Clearly they were diverging and it was never going to find a solution. Here are values it stopped with:

[p1=583621.008503822, p2 = 59223.7407763244, p3 = 92888.8332296935, q1 =6192.35371505405, q2 = 230.127618843129]

If I give it good guesses, it finds the solution:

iv := [p1 = 494.8, p2 = -156, p3 = 12.45, q1 = -0.2884, q2 = 0.02548];
NonlinearFit((p1*x^2 + p2*x + p3)/(q1*x + x^2 + q2), Ycg, Sx, x, initialvalues = iv);

[p1=494.772354721411,p2=-155.993031307792, p3 = 12.4504112058999, q1 = -0.288444965762112, q2 = 0.0254838840984013]

The problem is, I got the initial values from the MATLAB Curve Fitting Toolbox. I would like be to use Maple alone and not need MATLAB for cure fitting. How can I compute initial values that will allow Maple to find a solution?

I defined a 2×2 matrix V with entries involving operator-valued fields u(x,t), ω(x,t), and scalar function β(t). On macOS with Maple 2024.0, when I try to compute the derivative with respect to x using 

Vx := (diff, V, x);

Maple does not return a result. It just shows “Evaluating”

restart

kernelopts(version)

`Maple 2024.0, APPLE UNIVERSAL OSX, Mar 01 2024, Build ID 1794891`

(1)

with(LinearAlgebra)

with(Physics)

with(PDEtools); undeclare(prime)

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

(2)

interface(showassumed = 0)

Setup(mathematicalnotation = true)

[mathematicalnotation = true]

(3)

quantumOperators := {omega, u}

{omega, u}

(4)

Setup(quantumoperators = quantumOperators)

[quantumoperators = {omega, u}]

(5)

assume(x::real); assume(t::real)

declare(u(x, t), omega(x, t), B(x, t), alpha(t), beta(t), v1(x, t))

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

 

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

 

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

 

alpha(t)*`will now be displayed as`*alpha

 

beta(t)*`will now be displayed as`*beta

 

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

(6)

V := -(1/2)*Matrix([[beta(t)*(diff(omega(x, t), t)), -(diff(u(x, t), t))], [-(diff(u(x, t), t)), -beta(t)*(diff(omega(x, t), t))]])/lambda

Matrix(%id = 36893488152030778900)

(7)

Vx := diff(V, x)

Download derivativve.mw

I created an image by a matrix 8x8:

M:=1/255*RandomMatrix(8,generator=0..255):
G:=convert(M,image):
Embed(G)

but the image dispayed is very small, of course. Is there a way to visualize the 8x8 pixel image larger, so I can see the pixels?

While solving for i1 encounter too many terms. How can I simplify it so that only " Pn,Pr and w" remain, with all other variables grouped into constants, so that the equation for the optimal i1​ becomes small and manageable?
 

restart

kernelopts(version)

`Maple 2019.1, X86 64 WINDOWS, May 21 2019, Build ID 1399874`

(1)

Pi1 := (w-i1)*(1/2+(i1-i2)/(2*tau))*(1-(Pn-Pr)/(1-delta))+(s-i1-Crr)*(1/2+(i1-i2)/(2*tau))*((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)+Ce*rho0*(((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)*eta+1-(Pn-Pr)/(1-delta))

(w-i1)*(1/2+(1/2)*(i1-i2)/tau)*(1-(Pn-Pr)/(1-delta))+(s-i1-Crr)*(1/2+(1/2)*(i1-i2)/tau)*((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)+Ce*rho0*(((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)*eta+1-(Pn-Pr)/(1-delta))

(2)

diff(Pi1, i1) = 0

-(1/2+(1/2)*(i1-i2)/tau)*(1-(Pn-Pr)/(1-delta))+(1/2)*(w-i1)*(1-(Pn-Pr)/(1-delta))/tau-(1/2+(1/2)*(i1-i2)/tau)*((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)+(1/2)*(s-i1-Crr)*((Pn-Pr)/(1-delta)-(-beta*i1*upsilon+Pr)/delta)/tau+(s-i1-Crr)*(1/2+(1/2)*(i1-i2)/tau)*beta*upsilon/delta+Ce*rho0*beta*upsilon*eta/delta = 0

(3)

solve(%, i1)

-(1/3)*(Crr*beta*delta*upsilon-beta*delta*i2*upsilon-beta*delta*s*upsilon+beta*delta*tau*upsilon-Crr*beta*upsilon+beta*i2*upsilon+beta*s*upsilon-beta*tau*upsilon-delta*Pr+delta^2-(6*Ce*beta^2*delta^2*eta*rho0*tau*upsilon^2-12*Ce*beta^2*delta*eta*rho0*tau*upsilon^2+6*Ce*beta^2*eta*rho0*tau*upsilon^2+Crr^2*beta^2*delta^2*upsilon^2+Crr*beta^2*delta^2*i2*upsilon^2-2*Crr*beta^2*delta^2*s*upsilon^2-Crr*beta^2*delta^2*tau*upsilon^2+beta^2*delta^2*i2^2*upsilon^2-beta^2*delta^2*i2*s*upsilon^2-2*beta^2*delta^2*i2*tau*upsilon^2+beta^2*delta^2*s^2*upsilon^2+beta^2*delta^2*s*tau*upsilon^2+beta^2*delta^2*tau^2*upsilon^2-2*Crr^2*beta^2*delta*upsilon^2-2*Crr*beta^2*delta*i2*upsilon^2+4*Crr*beta^2*delta*s*upsilon^2+2*Crr*beta^2*delta*tau*upsilon^2-2*beta^2*delta*i2^2*upsilon^2+2*beta^2*delta*i2*s*upsilon^2+4*beta^2*delta*i2*tau*upsilon^2-2*beta^2*delta*s^2*upsilon^2-2*beta^2*delta*s*tau*upsilon^2-2*beta^2*delta*tau^2*upsilon^2+Crr^2*beta^2*upsilon^2+3*Crr*Pn*beta*delta^2*upsilon-2*Crr*Pr*beta*delta^2*upsilon+Crr*beta^2*i2*upsilon^2-2*Crr*beta^2*s*upsilon^2-Crr*beta^2*tau*upsilon^2+2*Crr*beta*delta^3*upsilon-3*Pn*beta*delta^2*s*upsilon+3*Pn*beta*delta^2*upsilon*w-Pr*beta*delta^2*i2*upsilon+2*Pr*beta*delta^2*s*upsilon+Pr*beta*delta^2*tau*upsilon-3*Pr*beta*delta^2*upsilon*w+beta^2*i2^2*upsilon^2-beta^2*i2*s*upsilon^2-2*beta^2*i2*tau*upsilon^2+beta^2*s^2*upsilon^2+beta^2*s*tau*upsilon^2+beta^2*tau^2*upsilon^2+beta*delta^3*i2*upsilon-2*beta*delta^3*s*upsilon-beta*delta^3*tau*upsilon+3*beta*delta^3*upsilon*w-3*Crr*Pn*beta*delta*upsilon+Crr*Pr*beta*delta*upsilon-4*Crr*beta*delta^2*upsilon+3*Pn*beta*delta*s*upsilon-3*Pn*beta*delta*upsilon*w+2*Pr*beta*delta*i2*upsilon-Pr*beta*delta*s*upsilon-2*Pr*beta*delta*tau*upsilon+3*Pr*beta*delta*upsilon*w-2*beta*delta^2*i2*upsilon+4*beta*delta^2*s*upsilon+2*beta*delta^2*tau*upsilon-6*beta*delta^2*upsilon*w+Crr*Pr*beta*upsilon+2*Crr*beta*delta*upsilon+Pr^2*delta^2-Pr*beta*i2*upsilon-Pr*beta*s*upsilon+Pr*beta*tau*upsilon-2*Pr*delta^3+beta*delta*i2*upsilon-2*beta*delta*s*upsilon-beta*delta*tau*upsilon+3*beta*delta*upsilon*w+delta^4-2*Pr^2*delta+4*Pr*delta^2-2*delta^3+Pr^2-2*Pr*delta+delta^2)^(1/2)+Pr-delta)/(beta*upsilon*(-1+delta)), -(1/3)*(Crr*beta*delta*upsilon-beta*delta*i2*upsilon-beta*delta*s*upsilon+beta*delta*tau*upsilon-Crr*beta*upsilon+beta*i2*upsilon+beta*s*upsilon-beta*tau*upsilon-delta*Pr+delta^2+(6*Ce*beta^2*delta^2*eta*rho0*tau*upsilon^2-12*Ce*beta^2*delta*eta*rho0*tau*upsilon^2+6*Ce*beta^2*eta*rho0*tau*upsilon^2+Crr^2*beta^2*delta^2*upsilon^2+Crr*beta^2*delta^2*i2*upsilon^2-2*Crr*beta^2*delta^2*s*upsilon^2-Crr*beta^2*delta^2*tau*upsilon^2+beta^2*delta^2*i2^2*upsilon^2-beta^2*delta^2*i2*s*upsilon^2-2*beta^2*delta^2*i2*tau*upsilon^2+beta^2*delta^2*s^2*upsilon^2+beta^2*delta^2*s*tau*upsilon^2+beta^2*delta^2*tau^2*upsilon^2-2*Crr^2*beta^2*delta*upsilon^2-2*Crr*beta^2*delta*i2*upsilon^2+4*Crr*beta^2*delta*s*upsilon^2+2*Crr*beta^2*delta*tau*upsilon^2-2*beta^2*delta*i2^2*upsilon^2+2*beta^2*delta*i2*s*upsilon^2+4*beta^2*delta*i2*tau*upsilon^2-2*beta^2*delta*s^2*upsilon^2-2*beta^2*delta*s*tau*upsilon^2-2*beta^2*delta*tau^2*upsilon^2+Crr^2*beta^2*upsilon^2+3*Crr*Pn*beta*delta^2*upsilon-2*Crr*Pr*beta*delta^2*upsilon+Crr*beta^2*i2*upsilon^2-2*Crr*beta^2*s*upsilon^2-Crr*beta^2*tau*upsilon^2+2*Crr*beta*delta^3*upsilon-3*Pn*beta*delta^2*s*upsilon+3*Pn*beta*delta^2*upsilon*w-Pr*beta*delta^2*i2*upsilon+2*Pr*beta*delta^2*s*upsilon+Pr*beta*delta^2*tau*upsilon-3*Pr*beta*delta^2*upsilon*w+beta^2*i2^2*upsilon^2-beta^2*i2*s*upsilon^2-2*beta^2*i2*tau*upsilon^2+beta^2*s^2*upsilon^2+beta^2*s*tau*upsilon^2+beta^2*tau^2*upsilon^2+beta*delta^3*i2*upsilon-2*beta*delta^3*s*upsilon-beta*delta^3*tau*upsilon+3*beta*delta^3*upsilon*w-3*Crr*Pn*beta*delta*upsilon+Crr*Pr*beta*delta*upsilon-4*Crr*beta*delta^2*upsilon+3*Pn*beta*delta*s*upsilon-3*Pn*beta*delta*upsilon*w+2*Pr*beta*delta*i2*upsilon-Pr*beta*delta*s*upsilon-2*Pr*beta*delta*tau*upsilon+3*Pr*beta*delta*upsilon*w-2*beta*delta^2*i2*upsilon+4*beta*delta^2*s*upsilon+2*beta*delta^2*tau*upsilon-6*beta*delta^2*upsilon*w+Crr*Pr*beta*upsilon+2*Crr*beta*delta*upsilon+Pr^2*delta^2-Pr*beta*i2*upsilon-Pr*beta*s*upsilon+Pr*beta*tau*upsilon-2*Pr*delta^3+beta*delta*i2*upsilon-2*beta*delta*s*upsilon-beta*delta*tau*upsilon+3*beta*delta*upsilon*w+delta^4-2*Pr^2*delta+4*Pr*delta^2-2*delta^3+Pr^2-2*Pr*delta+delta^2)^(1/2)+Pr-delta)/(beta*upsilon*(-1+delta))

(4)

simplify(%)

Error, (in simplify/do) invalid simplification command

 
 

``

Download Q_Simplify.mw

any idea what match fail on this example? is somethinbg wrong I am doing?

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

restart;

A:=2*y(3)^4+5;
match(A=k1*y(k2)^k3+k4,y,'la')

2*y(3)^4+5

false

patmatch(A,k1::anything*y(k2::anything)^(k3::anything)+k4::anything,'la');
la

true

[k1 = 2, k2 = 3, k3 = 4, k4 = 5]

Download why_match_fail_sept_21_2025.mw

Update:
I think match can only do it if the main "variable"   is a variable and not a "function". In this example y(.) is function, so that is why it failed to match. For example this works:

A:=2*y^3+4;
match(A=k1*y^k2+k3,y,'la')

And gives true, since "y" here is not a "function".

But this makes match not very useful to use for parsing. patmatch seems a little more practical to use.

in this method i don't know in most of short equation i try to find the parameter but is just evaluating and nothing come up i don't know my way is wrong or write but i think i am right  but parameter not coming out, beside this in this equation give  me a warning regarding the parameters which say number of solution is more than 100 and dint show me that , how i can find the solution better than this?

f-p-.mw

Why is maple so useless? It can't even display a simple matrix equation without hours of user/forum intervention. I've never had this problem in the past. How does anyone get any work done? See example and compare with screenshot below.   why_is_maple_so_useless.mw

The left hand side contains the correct information but won't display it when evaluated. I even tried disabling matrix scrolling.

The default font size in the code edit region box of my worksheet is too small. I would like to change it without changing font sizes outside of the code edit region. I would be glad if I could do this within an individual worksheet, but it would be better if I could make this global in Maple 2025.

There doesn't seem to be any obvious way of doing this?

Hi,

I am looking for an idea to build a mixed and randomized series on unit conversions (volumes, surface, capacity, areas) in the form of two tables (2 columns & 8 rows). The first table would contain the questions, and the second one the solutions, so that students can use it for self-assessment. Do you have any ideas to suggest? Thanks!

I wanted to check that the input  has the pattern   symbol(symbol), which will match any of   y(x), or f(x) or A(B) and so on.

But using patmatch does not work. Using patmatch(h(z),y::symbol(x::symbol),'la');  or even patmatch(h(z),'y'::anything('x'::anything),'la'); all return false. I know I can do patmatch(h(z),func::function(name),'la'); and this returns true, but this matches h(z,r) and matches h(z,r,t) and matches h(z,r,t,u) and so on. 

I wanted to match only   SYMBOL(SYMBOL), i..e. one symbol followed by "(" followed by one symbol followed by closing ")"

For reference, this is what I am looking for 

I know I can use other ways in Maple to do this (may be typematch and and others). But wanted to see if patmatch works on this and why it is failing.

Can this be done using patmatch?

I need to isolate i1​ and move the remaining terms to the other side. However, I’m encountering an error while doing this.

Note: All parameters are non-negative (positive or equal to zero).

Attaching sheet: Question_Isolate_i1.mw

Maple 2025.1 unable to solve this ode. Sympy gives the following two solutions which Maples verifies are correct.

Any trick or option that can help dsolve find these solutions?
 

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

restart;

ode:=diff(y(x),x) = (1+cos(x)*sin(y(x)))*tan(y(x));

diff(y(x), x) = (1+cos(x)*sin(y(x)))*tan(y(x))

sol:=dsolve(ode);

sol_1:=y(x)=arcsin( 2*exp(x) / ( c__1 + sqrt(2)*exp(x) * sin(x+Pi/4) ) ) + Pi

y(x) = arcsin(2*exp(x)/(c__1+2^(1/2)*exp(x)*sin(x+(1/4)*Pi)))+Pi

odetest(sol_1,ode)

0

sol_2:=y(x)=arcsin( 2*exp(x) / ( c__1 - sqrt(2)*exp(x) * sin(x+Pi/4) ) ) ;

y(x) = arcsin(2*exp(x)/(c__1-2^(1/2)*exp(x)*sin(x+(1/4)*Pi)))

odetest(sol_2,ode)

0

 


 

Download How_to_find_solution_sept_20_2025.mw

update:

OK, found out how. Needed transformation u(x)=sin(y(x)). Maple probably did not have this in one of the things to try.

 

restart;

ode:=diff(y(x),x) = (1+cos(x)*sin(y(x)))*tan(y(x));
sol:=dsolve(ode);

diff(y(x), x) = (1+cos(x)*sin(y(x)))*tan(y(x))

tr:=y(x)=arcsin(u(x));
PDEtools:-dchange(tr,ode,[u(x)]):
dsolve(%);
sol:=y(x)=arcsin(rhs(%));
odetest(sol,ode)
 

y(x) = arcsin(u(x))

u(x) = -2/(-2*exp(-x)*c__1+sin(x)+cos(x))

y(x) = -arcsin(2/(-2*exp(-x)*c__1+sin(x)+cos(x)))

0


 

Download How_to_find_solution_sept_20_2025_V2.mw

 

 

int(lambda*exp(-lambda*t), t=0..infinity) 

will get the integration result of 1

if we replace lambda with real numerical value of 1e5

we will get the integration result of 1

if we replace lambda with real numerical value  of1e6

we will get 0

but if we set lambda with an integer

lambda:= 1000000

the integration would be correct and equal to 1

why is this ?

Why when given IC for this ode, where the IC do not really makes much sense, so was not used. But the question is on the format of the output of the Maple dsolve. It gives solution as [{y(t) = c__1}]  instead of y(t) = c__1
 

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

restart;

ode:=diff(y(t),t)=0;
IC:=y(0)=t;
sol:=dsolve(ode)

diff(y(t), t) = 0

y(0) = t

y(t) = c__1

sol:=dsolve([ode,IC])

[{y(t) = c__1}]


 

Related question. Since Maple did not use the IC, should there have been warning message generated that IC was ignored?

 

Download strange_format_of_solution_sept_19_2025.mw

 

 

This post presents a work I did to answer this recent question by @AHSAN.

I believe that the two procedures I developed could be of interest to Mapleprimes members. Here they are in their most recent forms. However, I think they can still be improved and completed, and I am open to your suggestions for developing them further in this direction.

BarGraph_2_Categories.mw
Illustration


BarGraph_3_Categories.mw
Illustration

 

1 2 3 4 5 6 7 Last Page 1 of 2221