Chapter 5 Approximting Functions
Chapter 5 Approximting Functions
◊ Objective:
f(x) is given in a very complicated form and is difficult to use,
want to approximate f(x) by a simple polynomial in an interval.
Can we do it? How do we do it accurately?
5.1 Weierstrass Theorem—yes we can!
5.1.1 Weierstrass approximation
◊ Let f(x) be continuous for a ≤ x ≤ b and > 0.
There exists a polynomial P(x) such that
| f(x) - P(x) | ≤ for a ≤ x ≤ b.
we can always find a p(x) that is as close to f(x) as we want.
◊ The polynomial can be constructed using Bernstein polynomial,
n k n
Pn(x) = f(n ) (k) xk(1-x)n-k for 0 ≤ x ≤ 1
k=0
n
where (k) are the binomial coefficients.
3
exp(x)
2.5 q1*(x)
1.5
0.5
x3
0
-1.5 -1 -0.5 0 0.5 1 x
*
* Apparently, there are three locations: -1, x3, 1, where |q1(x)-f(x)|
0.4
Error
0.2 Minimax
-0.2
-0.4
-1 -0.5 0 0.5 1 x
* Indeed the negative error and positive error are evened out.
-0.02
-1 -0.5 0 0.5 1 x
• L2 -norm of f(x):
To minimize E, we require
∂E ∂E
=0 and =0
∂a0 ∂a1
∂E 1 ∂ 2
= ∂a [f(x) - a0 -a1x] dx = -2 −11 [ex - a0 -a1x]dx = 0
∂a0 0
−1
∂E 1 ∂ 2 1
= ∂a [f(x) - a0 - a1x] dx = 2 [ex - a0 - a1x](-x)dx = 0.
∂a1 1
−1 −1
1 1
a0 −1 dx = −1 ex dx = e1 – e-1 = 2.350402
3
f(x)
2.5
2 Linear approximations
1.5
1
exact
0.5 LSQ
Minimax
0
x
-1 -0.5 0 0.5 1
0.8
Error
0.6 LSQ
Minimax
0.4
Taylor series
0.2
-0.2
-0.4
-1 -0.5 0 0.5 1 x
1
Discussion: For a=0, b=1, the coefficient matrix is: Aij = i+j+1
1.2
1.0
0.8
n
x
0.6
n=2
0.4
3
0.2 5
0.0
0.0 0.2 0.4 0.6 0.8 1.0 1.2
x
1(x) = x (
|| 1(x) ||2 = −11 x 2 dx )1 / 2 = (2 / 3)1 / 2
1(x) = 3 / 2 x
1
Similarly 2(x) = 5 / 2 (3x2 - 1)... Legendre polynomials.
2
• Note: (j, j) =1 is not necessary as long as we know the value
of || j(x) ||2 which is usually the case for well-known
orthogonal polynomials.
• Minimization of E2:
∂E2 n
b
= 0 -2 a w(x) [f(x) - ai i(x)] j(x) dx = 0
∂aj i =1
n
ab w(x) f(x) j(x) dx = ai ab w(x) i(x)j(x)dx
i =1
n
= ai(i, j) = aj || j ||2.
i =1
b−a 1 2
=
2 −1
[F(t) - Rn(t)] dt
b+a+(b-a)t
where Rn(t) = rn( ) = rn(x).
2
n
• Rn(t) = ai Pi(t), t [-1, 1]
i =1
2i+1
ai = (F, Pi) / (Pi, Pi) = 2 (F, Pi).
2 1 f(x)Tj(x)
cj = 2 dx, for j = 0, 1,... n.
−1 1-x
2
= cos(j) f() d
0
n
• Finally, Cn(x) = Cn(cos) = ' cjcos(j).
j =1
2.5
1.5 f(x)
C1(x)
C2(x)
1 C3(x)
0.5
0
-1.5 -1 -0.5 0 0.5 1 1.5
2.5
f(x)
2
C4(x)
1.5 C3(x)
0.5
0
-1 -0.75 -0.5 -0.25 0 0.25 0.5 0.75 1 x
0.008
Error_q*3
0.006 Error_C3
Error_C4
0.004
0.002
-0.002
-0.004
-0.006
-0.008
-1 -0.75 -0.5 -0.25 0 0.25 0.5 0.75 1 x
1.E-03
1.E-05
1.E-07
1.E-09
1.E-11
1.E-13
1.E-15
0 5 10 15 k