C_R

1960 Reputation

19 Badges

5 years, 318 days

MaplePrimes Activity


These are replies submitted by C_R

I think you meant: ...the term I * Int(f(x), x).

This one works:

I*Int(f(x), x) = something - 2*I*Int(f(x), x);
isolate(%,Int(f(x), x))

 

@Rouben Rostamian  

I understand that there is no such solution. I am looking more for Maple techniques that provide “elegant” solutions. What I could achieve did not match my expectations (especially my failed substitution attempts). In this respect you have given a good example for the first integration step: Exclusive use of equations and high-level commands.

I had the hope that there could be a forward integration step (using only de and bc) coming to the same result as with your solution (maybe with a clever combination of DETools commands or the Physic package).

(The backward step you have taken in combination with a dsolve command that preserves the integration variable and removes the second integration constant is something I have to think about. This could become handy on other occasions.)

I have spared out the second integrations step which is of topic of my questions Q1 and Q2 and has to be approached differently for the pendulum and the elastic beam since the first one is an initial value problem whereas the other is a boundary value problem. I hope I can find a satisfying solution myself.

Thank you for providing the best way for Q1 and Q2 in one go so far!

@Rouben Rostamian  

As I haven't found a solution to this ODE using top-level Maple commands, my objective is to replicate the steps outlined in a publication that solves this ODE manually. I have outlined my random path of experiments in the attached reply.

Your way is smart since it avoids manual substitution of a boundary condition at all and prevents the dead ends one is confronted with when a solution returned from Mapel can’t be differentiated with respect to the independent variable (like Student:-ODEs:-ODESteps({bc, de})). So, thumbs up for that, but how could I have figured that out myself? Is this really the "best" way in the sense of good ode solving practise to avoid manual or "terrible" ways?

I have to admit this ode and its sibling has attracked my attention beyond practical need. First of all, there is everyday physics behind everyone knows: bending of elastic beams and the pendulum.  Secondly, as I have realized in the meantime, the second integration step can’t be formulated in terms of boundary conditions or initial conditions Maple accepts.

Maplesoft has done quite some efforts of providing education material and packages. It's good and I myself have learned allot. I can’t judge if these odes are of value form an educational standpoint. However, I wanted to highlight some problems (in particular defineing and handling ICs and BCs) and related questions a student may encounter. This is kind of a secondary objective.

restart;

de := diff(phi(s), s, s) + K*cos(phi(s)) = 0;

diff(diff(phi(s), s), s)+K*cos(phi(s)) = 0

(1)

bc := D(phi)(L) = phi__0;

(D(phi))(L) = phi__0

(2)

dsol := dsolve({de,bc}, phi(s), implicit);

Int(1/(-2*K*sin(_a)+2*K*sin(phi(L))+phi__0^2)^(1/2), _a = 0 .. phi(s))-s-c__2 = 0, Int(-1/(-2*K*sin(_a)+2*K*sin(phi(L))+phi__0^2)^(1/2), _a = 0 .. phi(s))-s-c__2 = 0

(3)

diff(dsol[1], s):  # either dsol[1] or dsol[2] will do
isolate(%, diff(phi(s), s))^2;

(diff(phi(s), s))^2 = -2*K*sin(phi(s))+2*K*sin(phi(L))+phi__0^2

(4)

subs(`φ__0` = `φ'`[0], phi(L) = `φ__0`, (diff(phi(s), s))^2 = -2*K*sin(phi(s))+2*K*sin(phi(L))+phi__0^2)

(diff(phi(s), s))^2 = -2*K*sin(phi(s))+2*K*sin(phi__0)+`φ'`[0]^2

(5)

My frist attempt to this ode

bvp2 := diff(phi(s), s, s)+K*cos(phi(s)) = 0, Eval(diff(phi(s), s), s = L) = `φ__0`

diff(diff(phi(s), s), s)+K*cos(phi(s)) = 0, Eval(diff(phi(s), s), s = L) = phi__0

(6)

dsolve({bvp2})

phi(s) = RootOf(-(Int(1/(-2*K*sin(_a)+RootOf(-(Int(1/(-2*K*sin(_a)+_Z)^(1/2), _a = 0 .. arcsin((1/2)*(-phi__0^2+_Z)/K)))+L+c__2))^(1/2), _a = 0 .. _Z))+s+c__2), phi(s) = RootOf(-(Int(-1/(-2*K*sin(_a)+RootOf(-(Int(-1/(-2*K*sin(_a)+_Z)^(1/2), _a = 0 .. arcsin((1/2)*(-phi__0^2+_Z)/K)))+L+c__2))^(1/2), _a = 0 .. _Z))+s+c__2)

(7)

ODETools[remove_RootOf]((phi(s) = RootOf(-(Int(1/(-2*K*sin(_a)+RootOf(-(Int(1/(-2*K*sin(_a)+_Z)^(1/2), _a = 0 .. arcsin((1/2)*(-phi__0^2+_Z)/K)))+L+c__2))^(1/2), _a = 0 .. _Z))+s+c__2), phi(s) = RootOf(-(Int(-1/(-2*K*sin(_a)+RootOf(-(Int(-1/(-2*K*sin(_a)+_Z)^(1/2), _a = 0 .. arcsin((1/2)*(-phi__0^2+_Z)/K)))+L+c__2))^(1/2), _a = 0 .. _Z))+s+c__2))[1])

-(Int(1/(-2*K*sin(_a)+RootOf(-(Int(1/(-2*K*sin(_a)+_Z)^(1/2), _a = 0 .. arcsin((1/2)*(-phi__0^2+_Z)/K)))+L+c__2))^(1/2), _a = 0 .. phi(s)))+s+c__2 = 0

(8)

I stopped there since I had no idea what to do next.

Another attempt

Student:-ODEs:-ODESteps({bvp2})

Error, (in Student:-ODEs:-ODESteps) the equation(s) {diff(diff(phi(s),s),s)+K*cos(phi(s)) = 0, Eval(diff(phi(s),s),s = L) = phi__0} are not in the proper format: they are not ODEs for phi(L), and cannot be initial conditions since they depend on L

 

(Strange since dsolve accepts bvp2 with Eval. Naming the independed variable throws a different error. )

 

I also tried

Student:-ODEs:-ODESteps({ode}) without boundaray conditions. That gives a solution with two integration constants where I could not replace one of them afterwards with the bondary condition.

I also tried the silbing equation

Student:-ODEs:-ODESteps(diff(phi(s), s, s)+K*sin(phi(s)) = 0, phi(s))

Error, (in Student:-ODEs:-ODESteps) unable to determine the solving variable(s); please specify solving variable(s) as an extra argument

 

Error, (in Student:-ODEs:-OdeSolveOrder2) ODE is not supported

 


My hope was to pinch some commands from the student package but there seems to be no way to do this (this would be an addtional question Q5).

New attempt with your way of defining the BV does not throw an error message but does not take the BV into account.

Student:-ODEs:-ODESteps({bc, de})

"[[,,"Let's solve"],[,,{((ⅆ)^2)/(ⅆs^2) phi(s)+K cos(phi(s))=0,(ⅆ)/(ⅆL) phi(L)=`phi__0`}],["•",,"Highest derivative means the order of the ODE is" 2],[,,((ⅆ)^2)/(ⅆs^2) phi(s)],["•",,"Define new dependent variable" u],[,,u(s)=[]],["•",,"Compute" ((ⅆ)^2)/(ⅆs^2) phi(s)],[,,[]=[]],["•",,"Use chain rule on the lhs"],[,,([]) ([])=[]],["•",,"Substitute in the definition of" u],[,,u(phi) ([])=[]],["•",,"Make substitutions" (ⅆ)/(ⅆs) phi(s)=u(phi)"," ((ⅆ)^2)/(ⅆs^2) phi(s)=u(phi) ((ⅆ)/(ⅆphi) u(phi)) "to reduce order of ODE"],[,,u(phi) ((ⅆ)/(ⅆphi) u(phi))+K cos(phi)=0],["•",,"Integrate both sides with respect to" phi],[,,∫(u(phi) ((ⅆ)/(ⅆphi) u(phi))+K cos(phi)) ⅆphi=∫0 ⅆphi+C1],["•",,"Evaluate integral"],[,,K sin(phi)+((u(phi))^2)/2=C1],["•",,"Solve for" u(phi)],[,,{u(phi)=sqrt(-2 K sin(phi)+2 C1),u(phi)=-sqrt(-2 K sin(phi)+2 C1)}],["•",,"Solve 1st ODE for" u(phi)],[,,u(phi)=sqrt(-2 K sin(phi)+2 C1)],["•",,"Revert to original variables with substitution" u(phi)=(ⅆ)/(ⅆs) phi(s)"," phi=phi(s)],[,,(ⅆ)/(ⅆs) phi(s)=sqrt(-2 K sin(phi(s))+2 C1)],["•",,"Separate variables"],[,,((ⅆ)/(ⅆs) phi(s))/(sqrt(-2 K sin(phi(s))+2 C1))=1],["•",,"Integrate both sides with respect to" s],[,,∫((ⅆ)/(ⅆs) phi(s))/(sqrt(-2 K sin(phi(s))+2 C1)) ⅆs=∫1 ⅆs+C2],["•",,"Evaluate integral"],[,,-(2 (C1+K) sqrt(-(K sin(phi(s))-C1)/(C1+K)) sqrt(-((sin(phi(s))-1) K)/(-C1+K)) sqrt(((sin(phi(s))+1) K)/(C1+K)) EllipticF(sqrt(-(K sin(phi(s))-C1)/(C1+K)),sqrt(-(C1+K)/(-C1+K))))/(K cos(phi(s)) sqrt(-2 K sin(phi(s))+2 C1))=s+C2],["•",,"Solve for" phi(s)],[,,{phi(s)=arctan(-((JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 K+(JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1-C1)/K,(sqrt(-K^2 (JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2+(JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1^2+K^2-C1^2) sqrt((-C1+K) ((JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 K+(JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1+K-C1)))/((-C1+K) K)),phi(s)=arctan(-((JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 K+(JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1-C1)/K,-(sqrt(-K^2 (JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2+(JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1^2+K^2-C1^2) sqrt((-C1+K) ((JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 K+(JacobiSN((sqrt(2 K-2 C1) (s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1+K-C1)))/((-C1+K) K))}],["•",,"Solve 2nd ODE for" u(phi)],[,,u(phi)=-sqrt(-2 K sin(phi)+2 C1)],["•",,"Revert to original variables with substitution" u(phi)=(ⅆ)/(ⅆs) phi(s)"," phi=phi(s)],[,,(ⅆ)/(ⅆs) phi(s)=-sqrt(-2 K sin(phi(s))+2 C1)],["•",,"Separate variables"],[,,((ⅆ)/(ⅆs) phi(s))/(sqrt(-2 K sin(phi(s))+2 C1))=-1],["•",,"Integrate both sides with respect to" s],[,,∫((ⅆ)/(ⅆs) phi(s))/(sqrt(-2 K sin(phi(s))+2 C1)) ⅆs=∫(-1) ⅆs+C2],["•",,"Evaluate integral"],[,,-(2 (C1+K) sqrt(-(K sin(phi(s))-C1)/(C1+K)) sqrt(-((sin(phi(s))-1) K)/(-C1+K)) sqrt(((sin(phi(s))+1) K)/(C1+K)) EllipticF(sqrt(-(K sin(phi(s))-C1)/(C1+K)),sqrt(-(C1+K)/(-C1+K))))/(K cos(phi(s)) sqrt(-2 K sin(phi(s))+2 C1))=-s+C2],["•",,"Solve for" phi(s)],[,,{phi(s)=arctan(-((JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 K+(JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1-C1)/K,(sqrt(-K^2 (JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2+(JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1^2+K^2-C1^2) sqrt((-C1+K) ((JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 K+(JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1+K-C1)))/((-C1+K) K)),phi(s)=arctan(-((JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 K+(JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1-C1)/K,-(sqrt(-K^2 (JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2+(JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1^2+K^2-C1^2) sqrt((-C1+K) ((JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 K+(JacobiSN((sqrt(2 K-2 C1) (-s+C2))/2,sqrt(-(C1+K)/(-C1+K))))^2 C1+K-C1)))/((-C1+K) K))}]]"

(9)

 

NULL

Download mw-1_reply.mw

@sursumCorda 
I think your way to Q1 with 2 out of more than 130 (!) DETools commands is not terrible. The missing bit for me when I got this Error

was that I can potenially make an ODE exact by multiplying it with an integration factor. If this is the only way, Student:-ODEs:-Integrate could have added a hint.
Also: Strange that the examples of ?DEtools,firint sometime come with _C1 and c__1.

Even if "terrible": Why does this comes as an exponent?Edit: fount the explanation

Let's see if there are less terrible ways.

Thank you

@sursumCorda 

I do not understand. This is how it looks like when I execute your attachment with Maple 2023. Please consider that I have only basic knowledge about ODEs and Maples possibilites. With some additional explanation, I could better understand your answer.

restart;

ode := diff(phi(s), s, s)+K*cos(phi(s)) = 0

isolate(DETools:-firint(ode*DEtools:-intfactor(ode, phi(s)), phi(s)), c__1)

Error, (in isolate) 2*K*sin(phi(s))+diff(phi(s),s)^2+_C1 = 0 does not contain c__1

 

unprotect(Eval)WARNING("Using `unprotect` can be dangerous!")

define(Eval, 'linear', conditional(Eval(a::anything, c::equation) = a, _type(a, freeof(_lhs(c)))), ('conditional')(Eval(a::anything^b::(nonunit(anything)), c::anything) = (Eval(a, c))^b, _type(b, freeof(_lhs(c)))), ('conditional')(Eval(a::anything*sin(b::anything), c::equation) = a*sin(Eval(b, c)), _type(a, freeof(_lhs(c)))))

Warning, Using `unprotect` can be dangerous!

 

`,=`(constants, K, c__1, L)

"subs(((ⅆ)/(ⅆs) phi(s)) ? ()|() ? (s=L)=`phi'`[0],map(Eval,,s=L))"

Error, invalid function arguments

"subs(((ⅆ)/(ⅆs) phi(s)) ? ()|() ? (s=L)=`phi'`[0],map(Eval,,s=L))"

 

unassign('Eval')

NULL

Download 236511-How-To-Integrate-This-Ode-And-How-To-1_reply.mws

@acer This will be an easy fix. Thank you !

Applyrule should have worked on equations (since equations are expressions in Maple terms, see ?equation)

but it does not

a = b;
applyrule(b = c, %);
map2(applyrule, b = c, `%%`);

I have send a software change request that either the helppage is updated or applyrule.

@nm 

You pretty much described what I had in mind. If the LOOP runs in Maple one could think of setting a timer with a bit of extra margin that on average more Mapleserver.exe are terminated than stated. This would prevent a system overflow.

I have managed to start a maple server with the command below and load a *.mw file.

system("\"C:\\Program Files\\Maple 2023\\bin.X86_64_WINDOWS\\maplew.exe\" -a \" C:\\Users\\CR\\Desktop\\kernellost.mw \"");

Similarily esc works, see help(esc).

Also *.bat file can be excecuted with the same windows commands

Using -e instead of -a should execute the argument that follows the -e. I have tried to put a read statement around the file but have to stop here for today.

read(\" C:\\Users\\CR\\Desktop\\kernellost.mw \"")

 

Update:

On MaplePrimes I found more on read

https://www.mapleprimes.com/questions/202016-Batch-Process-Worksheets-And-Save-As-PDF

and the possibility to run skripts *.mpl

https://www.mapleprimes.com/questions/223885-Batch-File-For-Window-Run-Maple-Input-File-

If you could programatically transfrom your problems into a skript files (one per problem) you should be able to either execute them one by one from Maple in a LOOP or run a batch job on a system level.

Also interesting in this contaxt:

https://www.mapleprimes.com/maplesoftblog/209538-Can-I-Programmatically-Modify-Batch

Could you share the CAD component using ?

@sursumCorda 

f__5 is structurally the most ordered result of all: Only one RootOf left and only one root per list element!

👍👍

 

@sursumCorda 

I just tried it to get a better overview myself.
It seems that the complexity driver is the nested RootOf expression

The squared term inside the outer RootOf probably contributes to the high number of counted leafs.

The attempted simplifications left r1 untouched which is maybe not so obvious at a first glance for others from your original doccument.

I would be interested to learn if there is a way from the 2 roots in f0 to the 6 index roots in f4.

fully_simplify_f_0_with_alias.mw

@acer 

After System restart, I checked Maple.ini for any alias entries. There was nothing suspicious.

Also renaming Maple.ini to _Maple.ini did not change anything. (No startup code and no libraries were loaded)

Are there other initialization files that could cause the trouble?

What I did then was:

Loading the latest attachment above -> inserting and excecuting an alias statement at the begining -> saving the file (attached below)

When I load this new flie and excecute it with lessthan is gone.

If I excecute the file stepwise with lessthan reaperas as before after the plot.

The whole thing reminds me of an observation I made here

alias_with_lessthan_output_02.mw

@acer 

When I open the uploaded document above without executing anything I get

after entering alias() at the bottom of the document.

All than on Windows 11.

Below another atempt of uploading just in case

alias_with_lessthan_output.mw

@sursumCorda 

Your solution of using Maple is unexpected and surprised me!  Thank you

It can easily be used in this sequence:

Step 0: Locate the file of a model in its folder and open it by double click.

Step 1: Lauch Maple from within MapelSim (no adding or setting the file path, which is always a hassle)

Step 2: Replace the filename of the model in your command

 

@ Maplesoft: If there is no better way, I suggest to insert this information in the version_update attachment here.
Its usefull information when working with older files without history.

 

@delvin 

I get the error with 2022. If you can I would use 2023.

With 2022 FF still has Psi in a ln term.

First 15 16 17 18 19 20 21 Last Page 17 of 36