The current scheme violates Runge-Kutta condition on error O(h^4) when dy is too high. This leads to visible shifting and discontinuities on the plots of integrals for e^x^2, e^abs(x), etc.

BUG: 341256

Differential D24972

Keep cumulated error negligible for rapidly increasing functions

Authored by **yurchor** on Oct 26 2019, 6:52 PM.

Details

- Reviewers
*None*- Group Reviewers
KDE Edu - Commits
- R334:2b63a01634fc: Keep cumulated error negligible for rapidly increasing functions

The current scheme violates Runge-Kutta condition on error O(h^4) when dy is too high. This leads to visible shifting and discontinuities on the plots of integrals for e^x^2, e^abs(x), etc.

BUG: 341256

- Compile and install KmPlot.
- Create the Cartesian plot "f(x) = e^x^2".
- Switch to the "Integral" tab and tick the "Show integral" item.
- Try to change the scale (Ctrl+mouse wheel). The integral curve should be plotted as expected (no discontinuities, no extra lines on Ox).

f(x)=e^x^2 and its integral

Before the patch:

After the patch:

Diff Detail

- Repository
- R334 KmPlot
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.

Comment Actions

Do we have someone that knows "about math"?

@cfeck you're a math person right? Is this something that makes sense to you?

Comment Actions

Just some considerations:

- dx ~ (x_max-x_min)/viewport_width (about 0.001 for relatively low values of x).
- Error for Simpson's rule (Runge-Kutta method degrades to this rule in case of y'(x)=f(x) integration) is f^(4)(\xi)*dx^5/2880.
- To have cumulative error less than 1 for a viewport width 1000 it is enough to satisfy f^(4)(\xi)*dx^5/2880 < 0.001.
- If f^(4)(x) is of dy/dx^4 order so it is enough to multiply it with dx^2 to approximately satisfy 3. under the above-mentioned conditions.