Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make an exercise but I don't know how to start. Is there somebody that can give me a hint so that I can start with the exercise. The exercise is:

Consider the function $f(x) = \sin(x)$ on the interval $[0,\pi]$. Evaluate $f(x)$ in enough points to find an interpolating polynomial $p(x)$ and a natural cubic spline approximation $s(x)$ such that the error functions $|(f-p)(x)|$ and $|(f-s)(x)|$ satisfy

$|(f-p)(x)| \leq 0.005$ for $0 \leq x \leq \pi$

$|(f-s)(x)| \leq 0.005$ for $0 \leq x \leq \pi$

Give the number and the location of the data points for $p$ and $s$. This can be different for $p$ and $s$. Why is the second derivative of the spline function in begin and endpoint equal to zero a good choice?

share|cite|improve this question
up vote 2 down vote accepted

Wherever you get the formulas for constructing the interpolating polynomial and spline should give you an error estimate. For the polynomial, Wikipedia gives an error limit $f(x)-p_n(x)=\frac {f^{(n+1)}(\xi)}{(n+1)!}\prod_{i=0}^n (x-x_i)$ where the $x_i$ are the interpolating points. For $\sin x$ the derivatives are limited to $\pm 1$, so you can use that for your error limit. To minimize the product, you can use Chebyshev nodes. For the last question, what is the derivative of $\sin x$ at $0$ and $\pi$?

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.