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
251 stars 35 forks source link

Same expressions shows different surfaces as is not same x interval defined. #386

Open andrejuha opened 2 months ago

andrejuha commented 2 months ago

image

ChristopherChudzicki commented 2 months ago

Same expressions shows different surfaces as is not same x interval defined.

It's important to understand that neither surface shown is really x*sin(1/x). Both are approximations. That will be true of any graphing tool, though some may approximate better than others.

The approximation is made by sampling (evaluating) the surface and connecting points with triangles.

By default, Math3d samples surfaces 64 times in the x direction and 64 times in the y direction (4096 samples total). You can change the number of samples with the gear icon (settings). More samples will degrade performance but yield a better approximation.

Math3d spaces the samples evenly over the plot range. With -10 to 10 that's every (20/64)th unit, and with -2 to 2 that's every (4/64)th unit.

Because the sames are taken at different points, the approximations are different.


All of this is to say: The behavior you see is not unusual, nor is it really a bug. It's just the nature of the tool you're using.

Which isn't to say sampling couldn't be handled better. Some tools, like Wolfram's Mathematica, sample more intelligently: samples are not evenly spaced, but spaced according to how fast the surface is changing. Flat surfaces need fewer samples.