## 50 Reputation

1 years, 162 days

## @mmcdara Actually your n=2 file sol...

@mmcdara Actually your n=2 file solved all my problems. Thank you so much sir, inspired by your optimization approach I went on reproducing all alpha. Can you for one last time check my file and comment on improving the accuracy of optimization?. Again thanks for your precious time.Computing_first_3_alpha_for_n=2_case_.mw

## @mmcdara I just noticed this after ...

@mmcdara I just noticed your "The_case_n=2.mw" reply  after submitting my current reply , I will take a look thanks.

## @mmcdara I my previous reply I was ...

@mmcdara I my previous reply I was basically I wanted 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) . Please take a look at the worksheet i attached below. Also Maple never comes out of evaluating mode for analytical solution when n=5 which clearly exists. I waited for an hour. In other words Maple doen't seem to find this n=5 of ode1 analytical solution . Which has > > >  (1)
 >  (2)
 >  (3)
 >  (4)

Let's try to obtain analytical solution

 >  (5)

As you can see its empty, So we try numeric

 >  (6)
 >  (7)

Now here is the >  (8)
 >  (9) in the plot below is the point where the curve first time touches zero on ξ axis

 >  Lets now define our ode2

 >  (10)

What are we expecting here is that solving ode2 with optimal alpha will give derivative of γ i.e solution of ode2 at  ≈0

Optimal alpha depend on value of n.

 >  >  (11)

Now since I don't have access to exact solutions, I don't have EmdenE so I can't define ic2E whats the best stratagy from here?

 > ## @mmcdara So after going through all...

@mmcdara 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!

## @sand15 Thank you for your detailed...

@sand15 Thank you for your detailed explaination. I went ahead and changed the alpha to 1.4 in both code of your and my analytical worksheet that I provided. Keeping rest the same.In my analytical worksheet I am getting diff_at_pi := -27.857 for alpha=1.4 and through your code when epsilon:=Pi in the ic2E which is D(gamma)(Pi) = 0.61819073157125936845 for alpha=1.4. I could be wrong in understanding your code. Maybe ic2E is not same as diff_at_pi. Please point out my mistake as i was expecting these two to be close.

## @nm Thank you very much it wor...

@nm Thank you very much it worked!

Do you know if is there any tutorial that teaches how to use signal processing package using demo or in mini projects?

 Page 1 of 1
﻿