ChristopherChudzicki / math3d-react

A user-friendly 3d graphing calculator for the web. Create, share, and animate 3d mathematical scenes.
https://www.math3d.org
Mozilla Public License 2.0
250 stars 34 forks source link

Support for integral #323

Open nedisy opened 2 years ago

nedisy commented 2 years ago

Hello, I'm working on integral support for this repo. But I found it hard to get good performance and good accuracy at the same time for the numerical integrator. Currently, I use a nonadaptive version of Cash-Karp. When I use it to calculate pi using the area under a semicircle, it is only accurate to the 8th digit tho. Any ideas to improve?

Also, I'm working on the cache system for mathjs evaluation (no code yet) so that the call can be less than 0.1 ms--as mathjs evaluation took a lot of time. With a conservative amount of draw calls around 10k, it will take 1 s to complete. Anything more is kinda unacceptable IMO.

okay so, what do you think? should I continue or are you already working on a similar code?

o-b-o commented 2 years ago

being accurate to the 8th digit is pretty good though? You could do second order finite centered differences with a matrix. IMO you don't need too much accuracy for a graph, since we are not actually reporting any numbers.

o-b-o commented 2 years ago

I mean, the visual difference between 3.14 and 3.1415926535897932384626433... is pretty minor

nedisy commented 2 years ago

We are reporting a number in "variable or function", like Desmos does, and it shows to 12th digit

o-b-o commented 2 years ago

oh, that's pretty cool Maybe you can choose a "high power" integrator, one which may take longer to compute, and a "low power" integrator which may help graph integrals without the 12th digit precision

nedisy commented 2 years ago

or, tell the users that it uses numerical integrator, and for certain equations, it can be inaccurate

o-b-o commented 2 years ago

good call

Zaq-Xander commented 2 years ago

This sounds really cool, even at low precision. I'm currently computing complex Fourier series coefficients to visualise in Math3D and it is infinitely more tedious to copy them manually off a calculator. In-built support, even if only accurate to a few decimal places, would be greatly appreciated :)

o-b-o commented 2 years ago

that complex fourier series thing sounds awesome, would you like to share? :p