# bug #55031: lsode doesn't integrate correctly if the right side of the equation is not continuous in t

 Submitted by: vasiliy Submitted on: Thu 15 Nov 2018 08:30:31 PM UTC Category: Octave Function Severity: 2 - Minor Priority: 3 - Low Item Group: Inaccurate Result Status: Need Info Assigned to: None Originator Name: Open/Closed: Open Release: dev Operating System: GNU/Linux

You are not logged in

## Discussion

Mon 19 Nov 2018 04:44:17 AM UTC, comment #6:

If you have an exceedlingly difficult equation for the right side (lots of singularities or discontinuities) then no algorithm is going to work very well.

You might need to look at breaking the integration in to pieces where for each piece the integrand is continuous. You can then match boundary conditions for each interval.

You might also want to take a look at the fourth argument to lsode for which I quote the documentation.

The square function certainly looks like it is introducing discontinuities, but at known points.

Finally, I tried freq = 1e5, 1e6, 1e7, 1e8, 1e9 and the plots looked mostly the same to me. If there was supposed to be a dramatic difference around 1e7 I didn't see it.

Antother idea would be to tune the parameters for the lsode solver using the function lsode_options(). In particular, you might want to set "integration method" to "adams" to stop using a finite-difference calculated Jacobian. There are other options ('help lsode_options') which might also be useful for your particular problem.

Rik <rik5>
Sat 17 Nov 2018 08:01:04 AM UTC, comment #5:

I've uploaded simplified version of file, where the bug is triggered.

[u_ref u_ref/R] with u_ref/R=0.8 is a stable point. Therefor when the control u oscillates rapidly, there have to be no movements from constant away.

With freq=1e-6 and time-stepping 1000 there are no problems.
But with freq=1e7 and time stepping 10000 -- yes, there are.

vasiliy <vasiliy22>
Sat 17 Nov 2018 04:59:22 AM UTC, comment #4:

The produced graph is totally wrong. Since the trajectory has to be nearly constant after a t=0.0005.

vasiliy <vasiliy22>
Fri 16 Nov 2018 06:42:30 PM UTC, comment #3:

Version 4.0.0 of Octave is deprecated and no longer supported. As a start, you should update to the latest stable version (4.4.1).

I ran your code in 4.4.1 and it produces a plot. I don't know if there is anything wrong with it. I've attached it as 55031.png. I switched the ODE solver to ode45 and I get the same plot so I can't determine if there is anything wrong with lsode.

Rik <rik5>
Fri 16 Nov 2018 01:35:21 AM UTC, comment #2:

ode4 is a non adaptive runge-kutta method of order 4

vasiliy <vasiliy22>
Fri 16 Nov 2018 01:28:29 AM UTC, comment #1:

uploaded a new testfile. Because the old one does not trigger the bug.

Moreover, it turns out, that the routine ode4, that works correctly is not a part of octave... If you need, I could provide a code here.

vasiliy <vasiliy22>
Thu 15 Nov 2018 08:30:31 PM UTC, original submission:

The lsode function does not integrate the DE correctly. For comparsion see the attached file.

the signal package has to be loaded before running the program:

vasiliy <vasiliy22>

## Attached Files

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

Attach Files:

Comment:

Attached Files
file #45461:  testbug.m added by vasiliy22 (772B - application/vnd.wolfram.mathematica.package)
file #45457:  55031.png added by rik5 (17KiB - image/png)
file #45441:  testbug.m added by vasiliy22 (1KiB - application/vnd.wolfram.mathematica.package - the new one. The old one does not trigger a bug. Need to refine the step for the bug to be triggered...)
file #45435:  testbug.m added by vasiliy22 (1KiB - application/vnd.wolfram.mathematica.package)

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by rik5 (Updated the item)
• -email is unavailable- added by vasiliy22 (Submitted the item)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only project members can vote.

## History

Date Changed by Updated Field Previous Value => Replaced by
2019-02-26 mtmiller Severity3 - Normal 2 - Minor
Priority5 - Normal 3 - Low
Item GroupIncorrect Result Inaccurate Result
Release4.0.0 dev
2018-11-17 vasiliy22 Attached File- Added testbug.m, #45461
2018-11-16 rik5 Attached File- Added 55031.png, #45457
StatusNone Need Info
2018-11-16 vasiliy22 Attached File- Added testbug.m, #45441
2018-11-15 vasiliy22 Attached File- Added testbug.m, #45435