@@ -342,6 +342,33 @@ exactly through each point.
342
342
:scale: 60
343
343
:align: right
344
344
345
+ The ``derivative `` and ``antiderivative `` methods of the result object can be used
346
+ for differentiation and integration. For the latter, the constant of integration is
347
+ assumed to be zero, but we can "wrap" the antiderivative to include a nonzero
348
+ constant of integration.
349
+
350
+ >>> d_interp_spline = interp_spline.derivative()
351
+ >>> d_interp_results = d_interp_spline(interpolation_time)
352
+ >>> i_interp_spline = lambda t : interp_spline.antiderivative()(t) - 1
353
+ >>> i_interp_results = i_interp_spline(interpolation_time)
354
+
355
+ .. image :: auto_examples/images/sphx_glr_plot_interpolation_003.png
356
+ :target: auto_examples/plot_interpolation.html
357
+ :scale: 60
358
+ :align: right
359
+
360
+ For functions that are monotonic on an interval (e.g. :math: `\sin ` from :math: `\pi /2 `
361
+ to :math: `3 \pi /2 `), we can reverse the arguments of ``make_interp_spline `` to
362
+ interpolate the inverse function. Because the first argument is expected to be
363
+ monotonically *increasing *, we also reverse the order of elements in the arrays
364
+ with :func: `numpy.flip `.
365
+
366
+ >>> i = (measured_time > np.pi/ 2 ) & (measured_time < 3 * np.pi/ 2 )
367
+ >>> inverse_spline = sp.interpolate.make_interp_spline(np.flip(function[i]),
368
+ ... np.flip(measured_time[i]))
369
+ >>> inverse_spline(0 )
370
+ array(3.14159265)
371
+
345
372
See the summary exercise on :ref: `summary_exercise_stat_interp ` for a more
346
373
advanced spline interpolation example, and read the
347
374
`SciPy interpolation tutorial <https://scipy.github.io/devdocs/tutorial/interpolate.html >`__
0 commit comments