## 5610 Reputation

7 years, 185 days

## Duplicate question?...

Isn't it this a duplicate of thar previous question?

BTW, why do you persist in doing the same mistake (unknown=f(x) and parameter mu[f])?

More of this your 4 equations are both identical except for the name of the dependent function, so their solutions will be fundamentaly identical it it is stupid to dsolve 4 equations.
The generic form of these equations is given by coeff(HPMeq, p, 1).
Before doing complex things  ask yourself if this equation can be solved formally;

```# example
test := coeff(HPMEq, p, 0);

# A solution is returned here
Without_bc := dsolve(test);

# But not here
With_bc := dsolve({test, F[0](1) = 1, F[0](-1) = -1, (D(F[0]))(1) = 0, (D(F[0]))(-1)})
```

So trying to take the rhs of this last ouput generates the error message you got.

The only way is to dsolve numerically

`{test, F[0](1) = 1, F[0](-1) = -1, (D(F[0]))(1) = 0, (D(F[0]))(-1)}`

which implies to replace the many parameters by their numerical values.

Make an effort to understand all this and to submit us something that is worth us spending time answering, otherwise it's all a waste of  time for the people here.

## odeplot F not f !!!!!!...

 > restart;
 > with(plots):

HERE IS A CORRECT WAY TO CODE THE THINGS

Note that I treated ONLY the first ode.

With a little effort you should be capable to generalize this to the two other odes, so stop
doing again and again the same errors and try to learn something.

 > eq1 := mu[hnf]*rho[f]*(diff(F(x), x, x, x, x))/(rho[hnf]*mu[f])+3*alpha*(diff(F(x), x, x))+alpha*eta*(diff(F(x), x, x, x))-2*R*F(x)*(diff(F(x), x, x, x))-rho[f]*M*(diff(F(x), x, x))/rho[hnf] = 0;
 (1)
 > a1 := { phi[1] = 0.1e-1, phi[2] = 0.1e-1, R = 1.0, M = 1, alpha = -1, eta = 1 }: a2 := { phi[1] = 0.1e-1, phi[2] = 0.1e-1, R = 1.0, M = 1, alpha = -.5, eta = 1 }: a3 := { phi[1] = 0.1e-1, phi[2] = 0.1e-1, R = 1.0, M = 1, alpha = .5, eta = 1 }: a4 := { phi[1] = 0.1e-1, phi[2] = 0.1e-1, R = 1.0, M = 1, alpha = 1, eta = 1 }: AllA := [a1, a2, a3, a4]: print~(AllA):
 (2)
 > data := {   rho[f]   = 997.1,   rho[s1]  = 6320,   rho[s2]  = 3970,   c[p][f]  = 4180,   c[p][s1] = 531.5,   c[p][s2] = 765,   k[s1]    = 76.5,   k[s2]    = 40,   k[f]     = .613,   mu[f]   = 1,     # You forgot assigning it, this is my arbitrary choice   k[nf]   = 1,     # You forgot assigning it, this is my arbitrary choice   k[s1]   = 1,     # You forgot assigning it, this is my arbitrary choice   k[s2]   = 1,     # You forgot assigning it, this is my arbitrary choice   phi[1]  = 0.1,   # You forgot assigning it, this is my arbitrary choice   phi[2]  = 0.1    # You forgot assigning it, this is my arbitrary choice }: AllData := {   data[]   , k[nf]    = eval( k[f]*(k[s1]+2*k[f]-2*phi[1]*(k[f]-k[s1]))/(k[s1]+2*k[f]+phi[1]*(k[f]-k[s1])), data)   , k[hnf]   = simplify(eval( k[nf]*(k[s2]+2*k[nf]-2*phi[2]*(k[nf]-k[s2]))/(k[s2]+2*k[nf]+phi[2]*(k[nf]-k[s2])), data))   , mu[hnf]  = eval( mu[f]/((1-phi[1])^2.5*(1-phi[2])^2.5), data)   , rho[hnf] = eval( (1-phi[2])((1-phi[1])*rho[f]+phi[1]*rho[s1])+phi[2]*rho[s2], data) }: # Check: print~(AllData):
 (3)
 > AllB := [ seq(eval(eq1, AllA[i] union AllData), i=1..numelems(AllA)) ]: print~(AllB):
 (4)
 > bcs := F(-1) = -1, F(1) = 1, (D(F))(-1) = 0, (D(F))(1) = 0;
 (5)
 > AllC := [ seq( dsolve({AllB[i], bcs}, numeric), i=1..numelems(AllA)) ]; AllC[1](0); colors  := [red, gold, green, blue]: legends := [ seq(cat("data set a", i), i=1..numelems(AllA)) ]; display(   seq(     odeplot(AllC[i], [x, diff(F(x), x)], -1..1, color=colors[i], legend=legends[i])     , i=1..numelems(AllA)   ) )
 >

## @shashi598 Let's try to synchro...

Let's try to synchronize our exchanges.

What I propose is for you to read my previous reply (that I updated meanwhile), and for me to wait for your return.
Maybe, or maybe not, the procedure LaneEmdenSolution  my last reply contains will give you some answers.

If not, I propose you to explain again what you want to achieve . For instance:

• Is it enough for you to compute the solution (n=1) from 0 to Pi?
If not, look below to the attached file.

• Is the problem for n <> 1 of the same nature (a condition, or boundary condition) at some specific value of xi?
The LaneEmdenSolution procedure was written assuming this, but I can be cometely out of the way.

See you soon

BTW, here is a procedure that builds the numerical solution of the Lane-Emden equafion on any range 0..some_value:

 > restart

Numerical solution of the Lane-Emden equation on arbitrary ranges

Procedure:

1  Solve numerically the Emden equation  (result = EmdenN)

2  For the Lane-Emden equation

2.1   Use the known option option to instruct dsolve that it has to use the EmdenN solution
2.2   Solve numerically a boundary value problem for the Lane-Emden equation (result = LaneEmden_bc)
from 0 to a given abscissa xi = BC_IC_transition_point with conditions
D(gamma)(0) = 0,
gamma(BC_IC_transition_point)+BC_IC_transition_point*D(gamma)(BC_IC_transition_point) = 0

2.3   Solve numerically an initial value problem for the Lane-Emden equation (result = LaneEmden_ic)
from  xi = BC_IC_transition_point  to xi = EndPoint with conditions
gamma(BC_IC_transition_point)    = eval(gamma(xi), LaneEmden_bc(BC_IC_transition_point)
D(gamma)(BC_IC_transition_point) = eval(diff(gamma(xi), xi), LaneEmden_bc(BC_IC_transition_point)

 > LaneEmden := proc(n, alpha, BC_IC_transition_point, EndPoint)   local gamma:   local ode1, ode2, EmdenN, LaneEmden_bc, LaneEmden_ic, f, bc, End_bc, ic:   ode1   := diff(xi^2*(diff(theta__0(xi), xi)), xi)/xi^2 = -theta__0(xi)^n;   EmdenN := dsolve({ode1, theta__0(0) = 1, (D(theta__0))(0) = 0}, theta__0(xi), numeric);   f := proc(z)     if not type(evalf(z),'numeric') then       'procname'(z);     else       eval(theta__0(xi), EmdenN(z));     end if;   end proc;   printf("Emden = 0 at xi = %a\n", fsolve(f(xi)=0, xi=0..EndPoint));   ode2         := diff(gamma(xi), xi, xi)-2*gamma(xi)/xi^2+alpha^2*gamma(xi) = -f(xi)^n*xi^2:   bc           := D(gamma)(0) = 0, gamma(BC_IC_transition_point)+BC_IC_transition_point*D(gamma)(BC_IC_transition_point) = 0;   LaneEmden_bc := dsolve({ode2, bc}, known=f, numeric, method=bvp[midrich], maxmesh=1024):   End_bc       := eval([gamma(xi), diff(gamma(xi), xi)], LaneEmden_bc(BC_IC_transition_point));   ic           := gamma(BC_IC_transition_point) = End_bc[1], D(gamma)(BC_IC_transition_point) = End_bc[2];   LaneEmden_ic := dsolve({ode2, ic}, known=f, numeric):      DocumentTools:-Tabulate(     [       plots:-display(         plots:-odeplot(           EmdenN           , [xi, theta__0(xi)]           , xi=0..EndPoint           , color=blue           , gridlines=true           , title = cat("Emden, n=", N, ", numerical solution")         )       ),              plots:-display(         plots:-odeplot(           LaneEmden_bc           , [xi, gamma(xi)]           , xi=0..BC_IC_transition_point           , color=blue           , gridlines=true           , title = cat("Lane-Emden, n=", N, ", numerical solution")         ),         plots:-odeplot(           LaneEmden_ic           , [xi, gamma(xi)]           , xi=BC_IC_transition_point..EndPoint           , color=red           , gridlines=true           , title = cat("Lane-Emden, n=", N, ", numerical solution")         )       ),              plots:-display(         plots:-odeplot(           LaneEmden_bc           , [xi, gamma(xi)+xi*D(gamma)(xi)]           , xi=0..BC_IC_transition_point           , color=blue           , gridlines=true           , title = typeset('gamma(xi)+xi*D(gamma)(xi)', `, n`=N)         ),         plots:-odeplot(           LaneEmden_ic           , [xi, gamma(xi)+xi*D(gamma)(xi)]           , xi=BC_IC_transition_point..EndPoint           , color=red           , gridlines=true           , title = typeset('gamma(xi)+xi*D(gamma)(xi)', `, n`=N)         )       )     ], width=80   ): end proc:
 > LaneEmden(1, 1.4, Pi, 10)
 Emden = 0 at xi = 3.141592311
 > LaneEmden(3, 1.4, Pi, 10)
 Emden = 0 at xi = 6.896848025
 > LaneEmden(3, 1.4, 6.896848025, 10)
 Emden = 0 at xi = 6.896848025
 >

## @shashi598Here are the numerical solutio...

@shashi598

Here are the numerical solutions for the Emden and Lane-Emden equations when n=2.

I used the same condition at xi=Pi than for the case n=1.

 > restart
 > local gamma:
 > ode1 := n -> (diff(xi^2*(diff(theta__0(xi), xi)), xi))/xi^2 = -theta__0(xi)^n;
 (1)
 > EmdenN := dsolve({ode1(2), theta__0(0) = 1, (D(theta__0))(0) = 0}, theta__0(xi), numeric);
 (2)
 > f := proc(z)   if not type(evalf(z),'numeric') then     'procname'(z);   else     eval(theta__0(xi), EmdenN(z));   end if; end proc;
 (3)
 > ode2 := n -> diff(gamma(xi), xi, xi)-2*gamma(xi)/xi^2+alpha^2*gamma(xi) = -f(xi)^n*xi^2: bc   := D(gamma)(0) = 0, gamma(Pi)+Pi*D(gamma)(Pi) = 0;
 (4)
 > LaneEmdenN := dsolve(eval({ode2(2),bc}, alpha=1.4), known=f, numeric, method=bvp[midrich])
 (5)
 > DocumentTools:-Tabulate(   [     plots:-odeplot(       EmdenN       , [xi, theta__0(xi)]       , xi=0..Pi       , color=blue       , gridlines=true       , title = "Emden, n=2, numerical solution"       ),     plots:-odeplot(       LaneEmdenN       , [xi, gamma(xi)]       , xi=0..Pi       , color=blue       , gridlines=true       , title = "Lane-Emden, n=2, numerical solution"     ),     plots:-odeplot(       LaneEmdenN       , [xi, gamma(xi)+xi*D(gamma)(xi)]       , xi=0..Pi       , color=blue       , gridlines=true       , title = typeset('gamma(xi)+xi*D(gamma)(xi)', n=2)     )   ], width=80 ): # Check the value of gamma(xi)+xi*diff(gamma(xi), xi) at x=Pi 'gamma(Pi)+Pi*D(gamma)(Pi)' = eval(gamma(xi)+xi*diff(gamma(xi), xi), LaneEmdenN(Pi));
 (6)

To complete this, you will find in this file General_Emden_and_Lane-Emden.mw a procedure named
LaneEmdenSolution whose arguments are, in this order:

1. The vamlue of n.
2. The value of alpha.
3. The value of the right end point X where the right boundary condition
`gamma(X) + X * D(gamma)(X) = 0`

is imposed

This procedure draws the numerical solutions of the Emden and Lane-Emden equations and the evolution of

`gamma(xi)+xi*diff(gamma(xi), xi)  , in the range 0.. right_end_point`

## @shashi598  I'm sorry but I bel...

Fortunately I had another window opened with your text in it: could you copy/paste it in a new reply?

So after going through all your files which explains every step in detail. So an overview of the approach as i understand taken in your file:

- The Emden equation was solved numerically using dsolve to get EmdenN.

- This was then used in the Lane-Emden equation ode2 to define the source term.

- An attempt was made to solve the Lane-Emden equation numerically using dsolve, but it failed due to a singularity at the initial point.

- To get around this, the initial point was shifted to ε > 0 using a parameter.

- However, there were still issues matching the numerical solution LaneEmdenN to the exact solution LaneEmdenE at ε and π.

- To improve the match, the initial conditions were tuned by defining a cost function Control that measures the error between LaneEmdenN and LaneEmdenE at π.

- Control was minimized over the initial conditions to find optimal values that provide a close match to LaneEmdenE.

- The minimized initial conditions were then used in dsolve to get an improved numerical solution LaneEmdenN_opt.

- LaneEmdenN_opt was shown to match LaneEmdenE to high precision, solving the original problem.

So in summary, the key steps were:

1) Shift initial point to avoid singularity

2) Tune initial conditions to match known solution behavior

3) Minimize error between numerical and exact solutions

This allows dsolve to get an accurate numerical solution without needing the exact analytic form. The same general approach could be applied to other singular ODEs.

So, I want to know in general if I dont have access to Exact solution i.e EmdenE and as a result to LaneEmdenE which are used in defining ic2E to get the high accuracy, in cases for example n=3, whats the best strategy?. Should i evaluate at ApproximateXi__1 where Xi__1 is Pi when n=1?. But have limited accuracy since ic2E is not be available. Putting it in a simple way imagine a blackbox function that takes n ,alpha, epsilon and outputs D(gamma)(xi__1) .

And at last I think these tricks needs to be applied when we have singular ODEs. So, in case where its not the case a straight forward approach will work that doesn't require epsilons.right?

I really appreciate the time and effort you have put in your answer. I learned several new things from your file. Thanks again!

As a reply to the text above: you are right on all the points and understood perfectly what did.
nevertheless I believe the second approach detailed here SecondApproach is much simpler and suficient if you don't want to compute the numerical solution of the Lane-Emden equation beyond xi=Pi.

The "epsilon-eta-tau" strateby is tailored to your problem and I cannot guarantee you it will still work for other values of the exponent n.

If you have something specific in mind, for instance n <> 1, please let me know, I would be interested in working on it.

## @dharr Thank you dharr for the expl...

@dharr

Thank you dharr for the explanation.
I didn't know about workbook (it seems Maple 2015 doesn't have this heature, the only entry is  ExcelTools[WorkbookData] and  ExcelTools[WorkbookData] which refers to former).

## Look these help pages Matrix LinearAlgeb...

Look these help pages

• Matrix
• LinearAlgebra
more specificaly EigenValues and Eigenvectors

## Seriously!...

Have you read one of my previous reply instructing you what a cirrect parh was???

I repeat myself if your target image has name Maple.jpg its full path is something like "//../../../Maple.jpg", to get it:

• go to the directiory Images,
• copy paste the name full path which should appear in the address bar,
• paste it in your worksheet,
• enclose all this by double quotes,
• change all the backslashes by slashes (maybe it's no longer necessary in recent Maple versions?).

Are you blind not to see that this
is not a correct full path?

• it contains C:                   (maybe this is accepted by Maple 2023?)
• it contains backslashes   (maybe Maple 2023 understand backslashes?)
• I doubt the the directory Maple 2023this even exists,
• if you copy/paste the link, why do you concatenate the result too currentdir() ???
Look to the help pages what currentdir() and cat do mean.
Clearly currentdir() is equal to  C:\Program Files\Maple 2023  in your case.

While you won't pass the correct path fo Read you will get an error, it is as simple as that.
Run this command to see if f is correct

`FileTools:-Exists(f)`

If the answer is false, as I suspect it is, then learn by yourself how to get a full path in Windows (I use Mac-OS and Linux so I can help you with that)

## @AHSAN I don't understand,pleas...

A hint: your message simply means the list is too long to be displayed, example:

```[1\$10^6]
[Length of output exceeds limit of 1000000]
```

BTW, "extended from 6 to 9" cannot be the cause of the message you get. Here I "extended from 6 to 12" :

```interface(rtablesize=13):
ExtendedDOE := `<,>`(DOE\$2):  # DOE repeted twice
ExtendedUpperBounds := [UpperBounds[], UpperBounds[]]:

ExtendedIntegral := Vector(12, i -> int(F(entries(ExtendedDOE[i], nolist)), x=-1..ExtendedUpperBounds[i])):
ExtendedMyTable := `<,>`(titles, `<|>`(ExtendedDOE, ExtendedIntegral))
```

You can verify by yourself this doesn't generate any message, warning nor error.

## @AHSAN  [0.5\$6] means "the li...

@AHSAN

[0.5\$6] means "the list made of 6 elements all equal to 0.5"
Look the help page about \$

## @DrYOUSSEF You're welcome.I saw...

You're welcome.

Feel free to tell me if you face difficulies to do with Maple what you did with Matlab.

## @jalal Can you clearly describe, wi...

Can you clearly describe, with somple words (no Maple here) what you do exactly?

Read(image) has absolutely no reason to fail if image is a string which contains a well formed full path to some image file with a supported extension (llo to the  ImageTools:-Read help page).

I am pretty sure you did something wrong:

• image is not a string,
• image is not a well formed path (did you read my last reply?),
• the file image doesn't exist,
• the image file doesn't have a supported extension.

I suggest you to start by checking the existence of the  image file by doing this

`FileTools:-Exists(image)`

By the way, why don't you simply upload your mw file, this would make things easier for everybody?

@AHSAN

## @jalal Lok to ImageTools;-Read help...

@jalal

First syntax:

```Read( file, img, opts )
```

A few lines below it's written

```file    -   string; the pathname of the image file to read
```

Ask yourself the question: is  this:///Images/Maple.jpg a string?
Obviously not, so Read will fail (for the moment your "Read" is cornered by the special symbol ":" , see the its help page).

Now, is "this:///Images/Maple.jpg" a valid path?
I assume you use Windows and that this: is a the name of some disk? Unfortunately Maple doesn't accept this ,otation: you must enter the full path of Maple.jpg, not a shortcut.
A full path is something like "//../../../Images/Maple.jpg", to get it:

• go to the directiory Images,
• copy paste the name full path which should appear in the address bar,
• paste it in your worksheet,
• enclose all this by double quotes,
• change all the backslashes by slashes (maybe it's no longer necessary in recent Maple versions?).

Now you have a correct full path.

## @jalal I thought you would have und...

I thought you would have understood that my image had full path

`cat(currentdir(), "/Desktop/Maple.jpg"):`

I f you have some image whose full path is My_Image_is_here, just do

`img := Read(My_Image_is_here):`

I updated my previous answer and attached the mw file.

 2 3 4 5 6 7 8 Last Page 4 of 119
﻿