r/desmos • • Apr 18 '22

Discussion Why can't Desmos compute this simple integral correctly?

Post image
62 Upvotes

17 comments sorted by

58

u/fireflame241 Apr 18 '22

All 65 sample points miss the interval 0.9 to 1: https://www.desmos.com/calculator/06pjqkck2x. If you drag the endpoints of integration, you can see that Desmos gives the correct value (0.1) whenever one sample point x is in the interval.

30

u/fireflame241 Apr 18 '22

In fact, we can create a function f that's almost always 1, but Desmos thinks the integral is 0 because we set f to 0 at exactly the sample points: https://www.desmos.com/calculator/maeuemmqzp

8

u/Square_Forever_3284 Apr 18 '22 edited Apr 18 '22

So what you're saying is that Desmos integration is fundamentally broken when it comes to piecewise defined functions?

23

u/fireflame241 Apr 18 '22

Any numeric integration scheme fundamentally can only sample a finite number of points. This means that it misses all other inputs; there's no way to avoid this besides symbolic integration, which is difficult to implement and can be slow.

8

u/Square_Forever_3284 Apr 18 '22

What if the interval of integration was broken up into the subintervals on which the piecewise-defined integrand was defined? On each one of those subintervals the integrand would be "well-behaved", thus avoiding this issue. At the same time I can see how this could be difficult to implement in general since the integrand could be a complicated function of many separate piecewise-defined functions.

5

u/Esnardoo Apr 18 '22

That would be very slow and complicated and only help in a tiny fraction of specific cases like this

5

u/one-eyed-02 Apr 18 '22

It can be useful for integrating animation variables. One can just then define the piecewise velocity and out pops the position.

2

u/one-eyed-02 Apr 18 '22

Sounds good actually. But that also depends on how piecewise function are implemented in code

1

u/TemperoTempus Feb 15 '25

I knows its very late, but I am curious.

So just add more intervals and simply make them smaller? Which should be faster than making a bunch of subsections and running the calculations again.

2

u/VoidBreakX Run commands like "!bernard" here →→→ redd.it/1ixvsgi Feb 15 '25

well, it's not really "making them smaller", it's just a piecewise specific optimization ensuring that the samples land in the interval specified by the piecewise

1

u/TemperoTempus Feb 15 '25

thanks for answer

1

u/[deleted] Jan 21 '24

[removed] — view removed comment

1

u/fireflame241 Jan 21 '24

That's expected when the upper bound is smaller than the lower bound. (My bad for making the b slider go up to 10 instead of 100; b < a in that graph, even though the b slider thumb is to the right of the a slider)

1

u/[deleted] Apr 19 '22

What is f(t)?

2

u/Square_Forever_3284 Apr 19 '22

It's f(x) as defined in (1) but with the variable x replaced by the dummy integration variable t.

3

u/Lenkense Apr 19 '22

So they are using Gauss integration. Am I wrong?