bugGNU Octave - Bugs: bug #53669, Add documentation to more fully...

 
 

bug #53669: Add documentation to more fully explain adaptive solver step

Submitter:  None
Submitted:  Mon 16 Apr 2018 05:14:38 PM UTC
   
 
Category:  Documentation Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Confirmed Assigned to:  None
Originator Name:  Jose Ignacio Royo Prieto Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 17 Apr 2018 03:34:32 PM UTC, comment #5: 

If this applies generally to several solvers then it is probably worth adding these as general examples to the manual section on ODEs.  It would show how you can use options, etc. to influence solver behavior.  If this is specific to a single solver, like ode45.m, then it should be documented in the ode45 documentation.

Rik <rik5>
Group administrator
Tue 17 Apr 2018 08:19:12 AM UTC, comment #4: 

Hi,

Patches to documentation would be welcome, where would you suggest to add the examples?

c.

Carlo de Falco <cdf>
Group Member
Tue 17 Apr 2018 06:44:45 AM UTC, comment #3: 

Thank you so much for the detailed explanation.
I shyly suggest adding those examples to complement the help lines of ode45.m

Of course, the bug case should be closed as nonexistent.

José Ignacio Royo (I'm sorry I didn't log in)

Anonymous
Mon 16 Apr 2018 09:06:43 PM UTC, comment #2: 

The selection of time steps by the adaptive algorithm is guided by the attempt of keeping the number of time steps as low as possible while achieving a local truncation error within the selected tolerance.

Therefore, if the algorithm is using fewer steps to achieve the same pointwise accuracy it means the new implementation is working BETTER than the old one.

The graphical appearance of the plot is in no way taken into account when choosing the time steps.

If you want to force the integrator to use a smaller timestep you can set the "MaxStep" option:



>> opt = odeset ('maxstep', 1e-2);
>> [TS,YS] = ode45 (fvdp, [0, 20], [2, 0], opt);
>> [T, Y] = ode45 (fvdp, [0, 20], [2, 0]);
>> plot(Y(:,1),Y(:,2),'rx',YS(:,1), YS(:,2), 'b-')
>> legend ('default adaptive step', '.01 maxstep')


As you can see from this example the smaller timestep does not seem to lead to any noticeable improvement, but the computation time IS slower so the default adaptive step seems to have worked correctly.


You can improve the plot appearance without incurring the higher computation cost if you add a set of interpolation points in the timespan :


>> opt = odeset ('maxstep', 1e-2);
>> [TS,YS] = ode45 (fvdp, [0, 20], [2, 0], opt);
>> [T, Y] = ode45 (fvdp, [0:1e-2:20], [2, 0]);
>> plot(Y(:,1),Y(:,2),'rx',YS(:,1), YS(:,2), 'b-')
>> legend ('default adaptive step', '.01 maxstep')


as you can see from this latter plot the two phase plots are
almost indistinguishable even though the second one worked much faster.

Qualitatively everything seems to have worked correctly here, so unless
you can show quantitative data demonstrating that the computation was inaccurate
in the sense that the truncation error was not within tolerance this bug should be closed as invalid.



Carlo de Falco <cdf>
Group Member
Mon 16 Apr 2018 05:24:36 PM UTC, comment #1: 

Actually, it takes 50 steps with core ode45 and 187 steps with package ode45.

Anonymous
Mon 16 Apr 2018 05:14:38 PM UTC, original submission:  

The "native" core version of ode45 seems to take very long steps when solving.

I tried the example of Van der Pol's oscillator as suggested in the documentation of ode45.m and takes 57 steps. The phase portrait looks very spiky. 

On the other hand, the package version takes some 180 steps and gives a nicely "correct" smooth phase portrait.

The following script gives both graphs so you can compare.

I have got those results in both Octave 4.2.1 and 4.2.2, for Windows 7, Linux Mint 18.3. In octave-online.net (current version is 4.2.1 there) only core ode45 has been tested with same shown result.

The code: (I am uploading the script and the png result)


% This is Van der Pol's oscillator,
% the example offered by the documentation
% of ode45.m

fvdp = @(T,Y) [Y(2); (1 - Y(1)^2) * Y(2) - Y(1)];
[T,Y] = ode45 (fvdp, [0, 20], [2, 0]);

subplot(2,1,1)
plot(Y(:,1),Y(:,2),'-o') % Phase portrait looks horrible
title('core ode45')

% Now, with the "old" C:\Octave\OCTAVE~1.2\share\octave\packages\odepkg-0.8.5
pkg load odepkg

[T,Y] = ode45 (fvdp, [0, 20], [2, 0]);
subplot(2,1,2)
plot(Y(:,1),Y(:,2),'-o') % Plase portrait looks good.
title('ode45 from odepkg-0.8.5 package')

print comparison.png


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #43951:  odexample.m added by None (560B - application/octet-stream)
file #43952:  comparison.png added by None (24KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by cdf (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-04-23 rik5 Release4.2.2 dev
        SummaryAdd documentation to more fully explain adapative solver step Add documentation to more fully explain adaptive solver step
    2018-04-17 rik5 CategoryOctave Function Documentation
        Item GroupInaccurate Result Feature Request
        StatusWorks For Me Confirmed
        Summarycore ode45 takes too long adaptative steps. Add documentation to more fully explain adapative solver step
    2018-04-16 cdf StatusNone Works For Me
    2018-04-16 None Attached File- Added odexample.m, #43951
        Attached File- Added comparison.png, #43952

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code