Skip to main content
1-Visitor
August 15, 2015
Solved

Extracting Individual Values from Odesolve

  • August 15, 2015
  • 2 replies
  • 1888 views

I apologize if this has been asked before as it would seem something others would have asked but my search of the blog returned nothing. In the attached file I have a simple 2nd order linear DE. I can see to extract individual values from the Odesolve output. I've also figured out how to extract the response to a vector. My question is how to know I've captured all the important content from the Odesolve output with my selected time increment of .01s. What if I was looking for the exact maximum. Seems like with my approach I'm only getting an approximation of the Odesolve output.

Best answer by lturek

Odesolve by default uses 1000 intervals so it should return 1001 pairs of values. The number of intervals can be changed by using an additional argument of odesolve.

But the output of an odesolveblock is a function which automatically interpolates between those values. Thats the reason you can use the derivative to find relative extremas as Luc had shown.

Of course you can reconstruct the vectors as you had done (see attached file) but you could have a look at the standalone ODE solvers which return the raw vector.

To find the local max and min values, you may use the functions localmax and localmin.

Of course the best results are achieved by the exact symbolic solution which unfortunately is not always that easy to find.

LT

2 replies

23-Emerald IV
August 15, 2015

If you want the exact location of the maximum, there's no better way than the symbolic way. See attached.

{Altough I wonder why I get a single solution for the extreme....}

But if you insist on wanting to do it numerically you could try inserting, just below the first plot:

To find the subsequent (local) extremes, just move the "t:=" guess value near the next location, like:

Etcetera.

Success!

Luc

lturek1-VisitorAnswer
1-Visitor
August 15, 2015

Odesolve by default uses 1000 intervals so it should return 1001 pairs of values. The number of intervals can be changed by using an additional argument of odesolve.

But the output of an odesolveblock is a function which automatically interpolates between those values. Thats the reason you can use the derivative to find relative extremas as Luc had shown.

Of course you can reconstruct the vectors as you had done (see attached file) but you could have a look at the standalone ODE solvers which return the raw vector.

To find the local max and min values, you may use the functions localmax and localmin.

Of course the best results are achieved by the exact symbolic solution which unfortunately is not always that easy to find.

LT

1-Visitor
August 15, 2015

Thanks Luc and Leopold. What is an example of a standalone ODE solver?

1-Visitor
August 16, 2015

You probably know that you can change the numeric algorithm used by odesolve by rightclicking at "odesolve" . Default is Adams/BDF, a hybrid solver..

There are a couple of standalone solvers with completetly different syntax - one for each algorithm.

E.g. AdamsBDF() as the hybrid solver and additionally four solvers for stiff systems (BDF,Radau,Stiffb,Stiffr) and four for non-stiff systems (Adams, rkfixed,Rkadapt,Bulstoer) Lookup the help and quicksheets for more information.

LT

.