 # Incorrect piecewise integral graph

When I try to plot an integral of a piecewise function: I get:

When I expected to get:

Link to the graph: Graphing Calculator

I don’t have an answer, but I can confirm that I am seeing the same error. The problem does not come from the way you defined the piecewise functions, because equivalent formulas for f and g give the same error. Even more baffling, if you change the bounds to be other intervals that contain the interval [-1,1], you can get lots of different answers. I’m very surprised to see Desmos struggle with this convolution. I assume Desmos is just using a Riemann sum approximation for the integral, so this should be an easy calculation for the calculator.

It’s something regarding the integral of g(x-z)dz. If you do just f(z), it equals 1. If you take out f(z), for a few seconds the graph stays as before, but then it changes. Really weird.

The calculator computes integrals by sampling the integrand at a series of points and taking a weighted sum of the samples. This estimation technique is called numerical quadrature.

The accuracy of the approximation generally increases as you add more sample points. In an attempt to balance speed and accuracy, the calculator first samples the integrand on a coarse grid, and then uses a heuristic to try to guess if more samples are necessary to get sufficient accuracy. If more samples are needed, the calculator splits the integration region into two separate regions, repeats the process on each region, and then sums the results. Using this kind of adaptive splitting with numerical quadrature is called adaptive numerical quadrature.

One way things can go wrong with this procedure is if all of the initial samples are exactly 0. In that case, the integration routine has no indication that the function isn’t 0 everywhere, so it will immediately return 0 as the result without attempting to explore further. I think that’s what’s going on here–for some values of x, the integrand is only non-zero over a very small region, and this region may fall between the integration routine’s initial sample points.

The easiest work-around is to limit the integration bounds so that the integrand is non-zero over all (or most) of the integration region. In this case, since f(x) is only non-zero between 0 and 1, you could integrate from 0 to 1 instead of -Infinity to Infinity.

Example: Graphing Calculator