Keep cumulated error negligible for rapidly increasing functions
ClosedPublic

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

Details

Summary

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

Test Plan
  1. Compile and install KmPlot.
  2. Create the Cartesian plot "f(x) = e^x^2".
  3. Switch to the "Integral" tab and tick the "Show integral" item.
  4. 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
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 18203
Build 18221: arc lint + arc unit
yurchor created this revision.Oct 26 2019, 6:52 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptOct 26 2019, 6:52 PM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
yurchor requested review of this revision.Oct 26 2019, 6:52 PM
yurchor updated this revision to Diff 68835.Oct 27 2019, 3:17 PM

Better deal with the order of approximations

yurchor edited the test plan for this revision. (Show Details)Nov 15 2019, 12:36 PM

Do we have someone that knows "about math"?

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

Just some considerations:

  1. dx ~ (x_max-x_min)/viewport_width (about 0.001 for relatively low values of x).
  2. 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.
  3. 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.
  4. 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.
yurchor updated this revision to Diff 70978.Dec 5 2019, 8:20 PM
yurchor edited the test plan for this revision. (Show Details)

Correct values

Are there any objections to this patch? Can I push it?

This revision was not accepted when it landed; it landed in state Needs Review.Jan 15 2020, 6:59 PM
This revision was automatically updated to reflect the committed changes.