1 / 67100%
MATH 352 - NUMERICAL ANALYSIS
- Numerical Differentiation and
Integration
Question Bank - Set 2
Liberty University
Question 1
Question
Consider the function f(x) = exsin(x) defined on the interval [0, π].
a) Find the first derivative of f(x) numerically at x=π
4using the forward
difference formula with h=π
8.
b) Estimate the value of the definite integral Rπ
0f(x)dx using the trapezoidal
rule with n= 4 subintervals.
Solution
a) To find the first derivative of f(x) at x=π
4numerically using the forward
difference formula, we use the formula:
f(x)f(x+h)f(x)
h
where h=π
8.
Step 1: Calculate f(π
4) and f(π
4+π
8).
f(π
4) = eπ
4sinπ
4=eπ
4·2
2
f(π
4+π
8) = e3π
8sin3π
8=e3π
8·p22
2
Step 2: Compute the numerical estimate of f(π
4).
f(π
4)f(π
4+π
8)f(π
4)
π
8
b) To estimate the value of the definite integral Rπ
0f(x)dx using the trape-
zoidal rule with n= 4 subintervals, we use the formula:
Zb
a
f(x)dx h
2"f(x0)+2
n1
X
i=1
f(xi) + f(xn)#
where h=ba
nand xi=a+ih for i= 0,1,2, ..., n. Given n= 4, we will have
h=π
4.
Step 1: Calculate the values of f(x0), f(x1), f(x2), f(x3), and f(x4).
f(x0) = f(0) = e0sin(0) = 0
f(x1) = f(π
4) = eπ
4sinπ
4=eπ
4·2
2
f(x2) = f(π
2) = eπ
2sinπ
2=eπ
2
f(x3) = f(3π
4) = e3π
4sin3π
4=e3π
4·2
2
f(x4) = f(π) = eπsin(π)=0
Step 2: Substitute the values into the trapezoidal rule formula and calculate
the estimated integral value.
Question 2
Question
Let f(x) = x32x+ 1. Determine the numerical approximation for f(2) using
the central difference formula with a step size of h= 0.1.
Solution
Step 1: Find f(2), f(2 + h), and f(2 h).
f(2) = 232(2) + 1
= 8 4+1
= 5
f(2 + h) = (2 + h)32(2 + h)+1
= (2 + h)(2 + h)(2 + h)2(2 + h)+1
= (2 + h)(4 + 4h+h2)42h+ 1
= 8 + 8h+ 2h2+ 4h+ 4h242h+ 1
= 8 + 12h+ 6h242h+ 1
= 5 + 10h+ 6h2
2
f(2 h) = (2 h)32(2 h)+1
= (2 h)(2 h)(2 h)2(2 h)+1
= (2 h)(4 4h+h2)4+2h+ 1
= 8 8h+ 2h24h+ 4h24+2h+ 1
= 8 10h+ 6h24+2h+ 1
= 5 8h+ 6h2
Step 2: Approximate f(2) using the central difference formula.
f(2) f(2 + h)f(2 h)
2h
(5 + 10h+ 6h2)(5 8h+ 6h2)
2h
10h+ 6h2+ 8h6h2
2h
18h
2h
9
Therefore, the numerical approximation for f(2) using the central difference
formula with a step size of h= 0.1 is 9.
Question 3
Question
Let f(x) = x32x2+ 3x1 be a function. Compute the numerical approxi-
mation of the derivative of f(x) at x= 2 using the forward difference formula
with a step size of h= 0.1. Then, approximate the integral of f(x) from 1 to 2
using the trapezoidal rule with n= 4 subintervals.
Solution
To approximate the derivative of f(x) at x= 2 using the forward difference
formula, we use the formula:
f(x)f(x+h)f(x)
h
Step 1: Calculate f(2) and f(2 + h).
f(2) = 232(2)2+ 3(2) 1 = 8 8+61=5
f(2 + h) = (2 + 0.1)32(2 + 0.1)2+ 3(2 + 0.1) 1=8.24
3
Step 2: Plug the values into the forward difference formula to approximate
f(2).
f(2) f(2 + 0.1) f(2)
0.1=8.24 5
0.1= 32.4
Therefore, the numerical approximation of f(2) is 32.4.
Now, to approximate the integral of f(x) from 1 to 2 using the trapezoidal
rule with 4 subintervals of equal width, we use the formula:
Z2
1
f(x)dx h
2[f(x0)+2
n1
X
i=1
f(xi) + f(xn)]
where his the width of each subinterval, x0= 1, xn= 2, and xi= 1 + ih,
for i= 1,2, . . . , n 1.
Step 3: Calculate the step size h.
h=21
4= 0.25
Step 4: Calculate the integral approximation using the trapezoidal rule.
Z2
1
f(x)dx 0.25 1
2(f(1) + 2[f(1.25) + f(1.5) + f(1.75)] + f(2)
= 0.25 1
2(0 + 1.8594 + 4.4375 + 7.4531) + 5= 3.7578
Therefore, the numerical approximation of R2
1f(x)dx using the trapezoidal
rule with 4 subintervals is 3.7578.
Question 4
Question
Let f(x) = ex2. Calculate the third derivative of f(x) at x= 1 using numerical
differentiation methods.
Solution
To find the third derivative of f(x) = ex2at x= 1, we will use numerical
differentiation methods.
Step 1: Calculate f(x)and its derivatives at x= 1
f(1) = e12=e(first derivative) f(1) = 2xex2x=1
= 2e(second derivative) f′′(1) = (2+4x2)ex2x=1
= 6e
Step 2: Use numerical differentiation to find the third derivative
at x= 1 The third derivative of f(x) at x= 1 can be approximated using the
formula:
f′′′(1) f′′(1 + h)f′′(1)
h
4
where his the step size.
Step 3: Substituting h= 0.1into the formula Substitute h= 0.1 into
the formula and evaluate:
f′′′(1) (2 + 4(1 + 0.1)2)e12+0.12f′′(1)
0.1
f′′′(1) (2 + 4(1.1)2)e1.01 6e
0.1
Step 4: Calculate the final answer Calculate the value of f′′′(1) using
the above expression:
f′′′(1) = (2 + 4(1.1)2)e1.01 6e
0.1
f′′′(1) = (2 + 4(1.21))e1.01 6e
0.1
f′′′(1) = 9.46e6e
0.1
f′′′(1) = 3.46e
0.1
f′′′(1) 34.6e
Question 5
Question
Let f(x) = sin(x) and g(x) be the numerical derivative of f(x) computed using
the forward difference approximation with step size h. If g(x) = f(x+h)f(x)
h,
find the numerical integration G(x) of g(x) using the Trapezoidal Rule with step
size h.
Solution
Step 1: Compute the derivative of f(x) = sin(x):
f(x) = cos(x)
Step 2: Compute the numerical derivative of f(x) using the forward differ-
ence approximation:
g(x) = f(x+h)f(x)
h
g(x) = sin(x+h)sin(x)
h
5
Step 3: Expand sin(x+h) using the angle sum identity:
g(x) = sin(x) cos(h) + cos(x) sin(h)sin(x)
h
g(x) = sin(x)(cos(h)1) + cos(x) sin(h)
h
Step 4: Apply the Trapezoidal Rule to compute the numerical integration
G(x) of g(x) with step size h:
G(x) = 1
2[g(x) + g(x+h)] ·h
G(x) = 1
2sin(x)(cos(h)1) + cos(x) sin(h)
h+sin(x+h)(cos(h)1) + cos(x+h) sin(h)
h·h
Step 5: Simplify the expression for G(x):
G(x) = 1
2sin(x)(cos(h)1) + cos(x) sin(h) + sin(x+h)(cos(h)1) + cos(x+h) sin(h)
h·h
G(x) = 1
2sin(x) cos(h) + cos(x) sin(h)sin(x) + sin(x) cos(h) + cos(x) sin(h) + cos(x) cos(h)sin(x) sin(h)
h·h
Step 6: Further simplify the expression for G(x):
G(x) = 1
22 sin(x) cos(h) + 2 cos(x) sin(h) + cos(x) cos(h)sin(x) sin(h)
h·h
G(x) = sin(x) cos(h) + cos(x) sin(h) + cos(x) cos(h)sin(x) sin(h)
2
Therefore, the numerical integration G(x) of g(x) using the Trapezoidal Rule
with step size his given by:
G(x) = sin(x) cos(h) + cos(x) sin(h) + cos(x) cos(h)sin(x) sin(h)
2
Question 6
Question
Find the numerical approximation of the derivative of the function f(x) = sin(x)
at x=π
4using the central difference formula with a step size of h=π
8.
6
Solution
Step 1: Calculate the central difference formula for numerical differentiation:
The central difference formula for the first derivative is given by:
f(x)f(x+h)f(xh)
2h
Step 2: Substitute the given values into the formula: Given f(x) = sin(x)
and h=π
8, we have:
fπ
4sin π
4+π
8sin π
4π
8
2·π
8
Step 3: Simplify the expression:
fπ
4sin 3π
8sin π
8
π
4
Step 4: Use the angle sum identities to simplify further:
sin(A±B) = sin(A) cos(B)±cos(A) sin(B)
fπ
4sin 3π
8cos π
8cos 3π
8sin π
8
π
4
Step 5: Calculate the numerical approximation:
fπ
4
2·2
22
2·2
2
π
4
fπ
421
π
4
=4
π
Therefore, the numerical approximation of fπ
4using the central difference
formula with a step size of h=π
8is 4
π.
Question 7
Question
Let f(x) = sin(2x).
a) Calculate the approximate value of f(0) using the forward difference
formula with h= 0.1.
b) Estimate the integral R1
0f(x)dx using the trapezoidal rule with n= 4.
7
Solution
a) To approximate f(0) using the forward difference formula, we use the for-
mula:
f(x)f(x+h)f(x)
h
Step 1: Calculate f(0) and f(0.1).
f(0) = sin(2(0)) = sin(0) = 0
f(0.1) = sin(2(0.1)) = sin(0.2) 0.1987
Step 2: Calculate f(0) using the forward difference formula.
f(0) f(0.1) f(0)
0.1
=0.1987 0
0.1
= 1.987
Therefore, the approximate value of f(0) is 1.987.
b) To estimate the integral R1
0f(x)dx using the trapezoidal rule, we use the
formula:
Zb
a
f(x)dx h
2"f(a)+2
n1
X
i=1
f(xi) + f(b)#
where h=ba
nand xi=a+i·h.
Step 1: Calculate h.
h=10
4= 0.25
Step 2: Calculate f(0), f(0.25), f(0.5), f(0.75), and f(1).
f(0) = sin(2(0)) = sin(0) = 0
f(0.25) = sin(2(0.25)) = sin(0.5) 0.4794
f(0.5) = sin(2(0.5)) = sin(1) 0.8415
f(0.75) = sin(2(0.75)) = sin(1.5) 0.9975
f(1) = sin(2(1)) = sin(2) 0.9093
Step 3: Calculate the integral using the trapezoidal rule.
Z1
0
f(x)dx 0.25
2[0 + 2(0.4794 + 0.8415 + 0.9975) + 0.9093]
=0.25
2[3.2368]
= 0.4046
Therefore, the estimated value of R1
0f(x)dx using the trapezoidal rule with
n= 4 is 0.4046.
8
Question 8
Question
Let f(x) = cos(x). Use the central difference method with h= 0.1 to estimate
f(1).
Solution
Step 1: Find f(1), f(0.9), and f(1.1).
f(1) = cos(1) 0.5403,
f(0.9) = cos(0.9) 0.6216,
f(1.1) = cos(1.1) 0.4536.
Step 2: Use the central difference method formula to estimate f(1).
f(1) f(1.1) f(0.9)
2h
Step 3: Substitute the values to find the numerical estimation of f(1).
f(1) 0.4536 0.6216
2×0.1
=0.168
0.2
=0.84.
Therefore, the estimation of f(1) using the central difference method with
h= 0.1 is approximately 0.84.
Question 9
Question
Given the function f(x) = exsin(x), find the numerical derivative of f(x) with
respect to xat x=π
4using the central difference method with a step size of
h= 0.1. Then, use the trapezoidal rule with n= 4 to approximate the integral
of f(x) from 0 to π
2.
Solution
To find the numerical derivative of f(x) at x=π
4using the central difference
method, we have:
f(x)f(x+h)f(xh)
2h
where h= 0.1. Substituting x=π
4into the formula:
9
Step 1: Calculate fπ
4,fπ
4+ 0.1, and fπ
40.1.
fπ
4=eπ
4sin π
4
fπ
4+ 0.1=eπ
4+0.1sin π
4+ 0.1
fπ
40.1=eπ
40.1sin π
40.1
Step 2: Calculate the numerical derivative.
fπ
4fπ
4+ 0.1fπ
40.1
2(0.1)
Now, to approximate the integral of f(x) from 0 to π
2using the trapezoidal
rule with n= 4:
Step 3: Calculate the step size h.
h=
π
20
4
Step 4: Apply the trapezoidal rule formula.
Zπ
2
0
f(x)dx h
2"f(x0)+2
n1
X
i=1
f(xi) + f(xn)#
Step 5: Evaluate the integral using the computed values of f(xi) and h.
Therefore, we have found the numerical derivative of f(x) at x=π
4and
approximated the integral of f(x) from 0 to π
2using the trapezoidal rule.
Question 10
Question
Let f(x) = sin(x)
xand g(x) = ex2. Find the numerical derivative of f(x)·g(x)
at x= 1 using the central difference formula, accurate to four decimal places.
Solution
To find the numerical derivative of f(x)·g(x) at x= 1 using the central difference
formula, we will first compute the derivatives of f(x) and g(x).
Step 1: Find f(x)
f(x) = sin(x)
x=cos(x)·xsin(x)·1
x2=x·cos(x)sin(x)
x2
Step 2: Find g(x)
g(x) = ex2=2x·ex2
10
Step 3: Find f(1) and g(1)
f(1) = 1·cos(1) sin(1)
12=cos(1) sin(1)
g(1) = 2·1·e12=2e1
Step 4: Calculate the numerical derivative of f(x)·g(x) at x= 1
df ·g
dx |x=1 f(1) ·g(1) + f(1) ·g(1)
(cos(1) sin(1)) ·e1+sin(1)
1·(2e1)
(cos(1) sin(1)) ·e12·sin(1) ·e1
(cos(1) sin(1) 2·sin(1)) ·e1
(cos(1) 3·sin(1)) ·e1
Therefore, the numerical derivative of f(x)·g(x) at x= 1 using the central
difference formula is (cos(1) 3·sin(1)) ·e1, accurate to four decimal places.
Question 11
Question
Let f(x) = sin(x) and g(x) = cos(x). Using numerical differentiation and
integration techniques, find the value of the integral Rπ/4
0f(x)·g(x)dx with an
error less than 0.01.
Solution
Step 1: Let’s first find the equation for f(x)·g(x).
f(x)·g(x) = sin(x)·cos(x) = sin(2x)
2
Step 2: To find the integral of sin(2x)
2from 0 to π
4, we can use numerical
integration techniques. Let’s divide the interval 0,π
4into Nsubintervals and
use the midpoint rule to approximate the integral:
Zπ/4
0
sin(2x)
2dx π
4N
N
X
k=1
sin 2( π
4Nkπ
8N)
Step 3: To achieve an error less than 0.01, we can use the fact that for the
midpoint rule, the error is bounded by (ba)3
24N2M, where Mis the maximum
11
value of the second derivative of the function being integrated. In this case,
f′′(x) = 2 sin(2x), so M= 2.
Step 4: Now, we solve the inequality (π
4)3
24N2·2<0.01 to find the minimum
number of subintervals Nrequired for the desired accuracy.
Step 5: After calculating N, we can use the midpoint rule formula to compute
the numerical value of the integral Rπ/4
0f(x)·g(x)dx with an error less than
0.01.
Question 12
Question
Let f(x) = 1
xand consider the integral
I=Z2
1
f(x)dx
Use Simpson’s rule with n= 4 to estimate I. Then, use the trapezoidal rule
with n= 8 to estimate I. Finally, use the composite midpoint rule with n= 16
to estimate I.
Solution
Step 1: Simpson’s Rule with n= 4 The formula for Simpson’s rule with n= 4
is:
I1
3·x·[f(x0)+4f(x1)+2f(x2)+4f(x3) + f(x4)]
where x=ba
n,xi=a+ix, and a= 1, b= 2.
Calculating the estimates:
x=21
4=1
4
x0= 1, x1= 1.25, x2= 1.5, x3= 1.75, x4= 2
Substitute the values into the Simpson’s rule formula to get the estimate.
Step 2: Trapezoidal Rule with n= 8 The formula for the Trapezoidal rule
with n= 8 is:
Ix
2f(x0)+2
n1
X
i=1
f(xi) + f(xn)
Calculate the estimate using the given formula.
Step 3: Composite Midpoint Rule with n= 16 The Composite Midpoint
Rule formula is:
Ix
n
X
i=1
fxi1+xi
2
Determine the values of xand xi, then substitute them into the Composite
Midpoint Rule formula to calculate the estimate.
12
Question 13
Question
Evaluate the definite integral Z1
0
ex2dx using Simpson’s Rule with n= 4
subintervals. Then, use the trapezoidal rule with n= 4 subintervals to approx-
imate the value of d
dx Zx
0
et2dtat x= 0.2.
Solution
To evaluate the integral Z1
0
ex2dx using Simpson’s Rule with n= 4 subinter-
vals, we first need to find the step size h:
h=ba
2n=10
2×4=1
8
Next, we calculate the approximated value of the integral using Simpson’s
Rule:
Approximated Value = h
3[f(x0)+4f(x1)+2f(x2)+4f(x3) + f(x4)]
where xi=a+ih.
For i= 0,1,2,3,4:
f(0) = e02= 1
f(1/8) = e(1/8)20.992
f(2/8) = e(2/8)20.976
f(3/8) = e(3/8)20.943
f(4/8) = e(4/8)2=e1/20.607
Now, substitute the values into the formula to find the approximated value
of the integral.
For the second part, we will use the trapezoidal rule with n= 4 subintervals
to approximate the derivative of Zx
0
et2dt at x= 0.2. The derivative of an
integral is given by the fundamental theorem of calculus:
d
dx Zx
a
f(t)dt=f(x)
Therefore, we need to find the function f(t) to evaluate f(0.2) using the
13
trapezoidal rule. Let’s calculate the function values for t= 0,1/4,2/4,3/4,4/4:
f(0) = e02= 1
f(1/4) = e(1/4)20.939
f(2/4) = e(2/4)20.886
f(3/4) = e(3/4)20.779
f(4/4) = e(4/4)2=e1= 0.367
Now, apply the trapezoidal rule to approximate f(0.2) by interpolating the
function values at t= 0,1/4,2/4:
Approximated Value = h
2[f(t0)+2f(t1)+2f(t2)+2f(t3) + f(t4)]
Finally, evaluate the derivative at x= 0.2 by substituting the calculated
values into the trapezoidal rule formula.
Question 14
Question
Let f(x) = ex. Use the composite Simpson’s rule with 4 subintervals to esti-
mate the value of the integral R1
0f(x)dx. Then, use a central difference formula
to estimate the derivative of f(x) at x= 1, with a step size of h= 0.1.
Solution
To estimate the integral R1
0f(x)dx using the composite Simpson’s rule with 4
subintervals, we first need to partition [0,1] into 4 equal subintervals:
h=10
4=1
4= 0.25
The nodes are: x0= 0, x1= 0.25, x2= 0.50, x3= 0.75, x4= 1.00.
Step 1: Compute f(x)at the nodes
f(0) = e0= 1
f(0.25) = e0.25 0.7788
f(0.50) = e0.50 0.6065
f(0.75) = e0.75 0.4724
f(1.00) = e10.3679
Step 2: Compute the composite Simpson’s rule estimation
14
Using the formula for the composite Simpson’s rule:
Zb
a
f(x)dx h
3[f(x0)+4f(x1)+2f(x2)+4f(x3) + f(x4)]
Substitute the values we calculated:
Z1
0
f(x)dx 0.25
3[1 + 4(0.7788) + 2(0.6065) + 4(0.4724) + 0.3679]
0.25
3[1 + 3.1152 + 1.213 + 1.8896 + 0.3679]
0.25
3·7.5857
0.6313
Therefore, the estimated value of the integral R1
0f(x)dx using the composite
Simpson’s rule with 4 subintervals is approximately 0.6313.
Step 3: Estimate the derivative using central difference formula
The central difference formula for the first derivative is given by:
f(x)f(x+h)f(xh)
2h
Substitute x= 1 and h= 0.1:
f(1) f(1.1) f(0.9)
2(0.1)
Calculate f(1.1) and f(0.9):
f(1.1) = e1.10.3329
f(0.9) = e0.90.4066
Substitute these values:
f(1) 0.3329 0.4066
2(0.1)
0.0737
0.2
0.3685
Therefore, the estimated value of the derivative of f(x) at x= 1 using the
central difference formula with a step size of h= 0.1 is approximately -0.3685.
15
Question 15
Question
Let f(x) = e2x.
(a) Find the 3-point forward difference approximation to f(0) using step
size h= 0.1.
(b) Estimate R1
0e2xdx using the trapezoidal rule with n= 4 subintervals.
Solution
(a) To find the 3-point forward difference approximation to f(0), we can use
the formula:
f(0) 3f(0) + 4f(h)f(2h)
2h
Step 1: Calculate f(0), f(h), and f(2h):
f(0) = e2·0= 1
f(h) = e2·0.1=e0.2
f(2h) = e2·0.2=e0.4
Step 2: Substitute the values into the formula:
f(0) 3(1) + 4(e0.2)e0.4
2(0.1)
f(0) 3+4e0.2e0.4
0.2
(b) To estimate R1
0e2xdx using the trapezoidal rule, we divide the interval
[0,1] into n= 4 subintervals. The trapezoidal rule formula for this case is:
Z1
0
e2xdx h
2 f(x0)+2
n1
X
i=1
f(xi) + f(xn)!
Step 1: Calculate hand the values of f(xi):
h=10
4= 0.25
f(x0) = f(0) = 1
f(x1) = f(0.25) = e0.5
f(x2) = f(0.5) = e1
f(x3) = f(0.75) = e1.5
f(x4) = f(1) = e2
16
Step 2: Substitute the values into the trapezoidal rule formula:
Z1
0
e2xdx 0.25
21 + 2(e0.5+e1+e1.5) + e2
Z1
0
e2xdx 0.125 1+2e0.5+ 2e1+ 2e1.5+e2
Question 16
Question
Let f(x)=2x35x2+ 3x+ 7. Find the value of the definite integral of f(x)
from 1 to 3. Then, use the central difference formula with a step size of h= 0.1
to approximate f(2).
Solution
To find the definite integral of f(x) from 1 to 3, we need to evaluate R3
1(2x3
5x2+ 3x+ 7) dx.
Step 1: Integrate f(x):
Z(2x35x2+ 3x+ 7) dx =1
2·2x41
3·5x3+1
2·3x2+ 7x+C
Z(2x35x2+ 3x+ 7) dx =x45
3x3+3
2x2+ 7x+C
Step 2: Evaluate the definite integral from 1 to 3:
Z3
1
(2x35x2+ 3x+ 7) dx =x45
3x3+3
2x2+ 7x3
1
Z3
1
(2x35x2+3x+7) dx =(3)45
3(3)3+3
2(3)2+ 7(3)(1)45
3(1)3+3
2(1)2+ 7(1)
Z3
1
(2x35x2+ 3x+ 7) dx = 81 45 + 27
2+ 21 1 + 5
3+3
2+ 7
Z3
1
(2x35x2+ 3x+ 7) dx = 56.5
Therefore, the definite integral of f(x) from 1 to 3 is 56.5.
Step 3: Use the central difference formula with h= 0.1 to approximate
f(2): The central difference formula is given by:
f(x)f(x+h)f(xh)
2h
17
Substitute x= 2 and h= 0.1:
f(2) f(2 + 0.1) f(2 0.1)
2·0.1
f(2) f(2.1) f(1.9)
0.2
Now, calculate f(2.1) and f(1.9):
f(2.1) = 2(2.1)35(2.1)2+ 3(2.1) + 7
f(2.1) = 19.661
f(1.9) = 2(1.9)35(1.9)2+ 3(1.9) + 7
f(1.9) = 14.559
Now substitute these values back into the formula:
f(2) 19.661 14.559
0.2
f(2) 25.51
Therefore, the approximate value of f(2) using the central difference formula
with h= 0.1 is 25.51.
Question 17
Question
Let f(x) = exsin(x). Compute the numerical approximations of f(1) using the
central difference method with step sizes h= 0.1 and h= 0.01.
Solution
To approximate f(1) using the central difference method, we use the formula:
f(x)f(x+h)f(xh)
2h
Step 1: Compute f(1) with h= 0.1:
f(1) f(1 + 0.1) f(1 0.1)
2×0.1=f(1.1) f(0.9)
0.2
=e1.1sin(1.1) e0.9sin(0.9)
0.2
Step 2: Compute f(1) with h= 0.01:
f(1) f(1 + 0.01) f(1 0.01)
2×0.01 =f(1.01) f(0.99)
0.02
=e1.01 sin(1.01) e0.99 sin(0.99)
0.02
18
Question 18
Question
Given the function f(x) = sin(x), approximate the derivative of f(x) at x=π
4
using the forward difference method with h= 0.1 and the trapezoidal rule with
4 equal subintervals on the interval [0,π
2].
Solution
We will first approximate the derivative using the forward difference method,
and then approximate the integral using the trapezoidal rule.
Step 1: Approximating the Derivative using Forward Difference
Method The forward difference approximation for the derivative of a function
f(x) at x0with step size his given by:
f(x0)f(x0+h)f(x0)
h
Given f(x) = sin(x) and x0=π
4, we have:
f(π
4)sinπ
4+ 0.1sinπ
4
0.1
Calculating the values:
f(π
4)sin7π
40 sinπ
4
0.1
f(π
4)
2
22
2
0.1= 0
Therefore, the approximate derivative of f(x) at x=π
4using the forward
difference method is 0.
Step 2: Approximating the Integral using Trapezoidal Rule Given
a function f(x) and the interval [a, b], the trapezoidal rule estimates the integral
of f(x) over [a, b] as:
Zb
a
f(x)dx h
2[f(a)+2f(a+h)+2f(a+ 2h) + . . . + 2f(bh) + f(b)]
where h=ba
nand nis the number of subintervals.
In our case, f(x) = sin(x), a= 0, b=π
2,n= 4 and h=π
8.
Substitute these values into the formula:
Zπ
2
0
sin(x)dx
π
8
2[sin(0) + 2 sinπ
8+ 2 sinπ
4+ 2 sin3π
8+ sinπ
2]
19
Calculating the values:
Zπ
2
0
sin(x)dx π
16[0 + 2 sinπ
8+ 2 sinπ
4+ 2 sin3π
8+ 1]
Zπ
2
0
sin(x)dx π
16[0 + 2p2 + 2
2+ 22
2+ 2p22
2+ 1]
Zπ
2
0
sin(x)dx π
16[2 + 2q2 + 2+22+2q22 + 1]
Zπ
2
0
sin(x)dx π
16[3 + 2q2 + 2+3q22]
Therefore, the approximate value of the integral of sin(x) over [0,π
2] using
the
Question 19
Question
Consider the following function: f(x) = ex2. Perform the following operations:
1. Find the first derivative of f(x) at x= 0 using forward difference approx-
imation with h= 0.1.
2. Find the second derivative of f(x) at x= 0 using central difference ap-
proximation with h= 0.01.
3. Find the definite integral of f(x) from x= 0 to x= 1 using the trapezoidal
rule with 4 subintervals.
Solution
1. Find the first derivative of f(x) at x= 0 using forward difference approxi-
mation with h= 0.1: Step 1: The forward difference approximation for the first
derivative is given by:
f(x)f(x+h)f(x)
h
Plugging in x= 0 and h= 0.1, we get:
f(0) f(0 + 0.1) f(0)
0.1=e(0.1)2e0
0.1
f(0) e0.01 1
0.10.99005 1
0.10.00995
0.1 0.0995
20
2. Find the second derivative of f(x) at x= 0 using central difference
approximation with h= 0.01: Step 1: The central difference approximation for
the second derivative is given by:
f′′(x)f(x+h)2f(x) + f(xh)
h2
Plugging in x= 0 and h= 0.01, we get:
f′′(0) f(0 + 0.01) 2f(0) + f(0 0.01)
0.012=e(0.01)22e0+e(0.01)2
0.0001
f′′(0) e0.0001 2e0.0001
0.0001 0.99995 20.99995
0.0001 2.00005
0.0001 20.0005
3. Find the definite integral of f(x) from x= 0 to x= 1 using the trapezoidal
rule with 4 subintervals: Step 1: The trapezoidal rule is given by:
Zb
a
f(x)dx h
2[f(a)+2
n1
X
i=1
f(xi) + f(b)]
where h=ba
n, the width of each subinterval, and xi=a+ih. Plugging in
a= 0, b= 1, n= 4, h=10
4= 0.25, we get:
Z1
0
ex2dx 0.25
2[e(0)2+ 2e(0.25)2+ 2e(0.5)2+ 2e(0.75)2+e(1)2]
Z1
0
ex2dx 0.25
2[1+2e0.0625+2e0.25+2e0.5625+e1]0.25
2[1+2(0.9401)+2(0.7788)+2(0.5718)+0.3679]
Z1
0
ex2dx 0.25
2[1 + 1.8802 + 1.557
Question 20
Question
Let f(x) = x32x23x+ 1. Find the numerical differentiation of f(x) at
x= 2 using the central difference formula with a step size of h= 0.1. Then,
use numerical integration with the trapezoidal rule with n= 4 intervals to
approximate the value of R2.5
1f(x)dx.
Solution
Let’s first find the numerical differentiation of f(x) at x= 2 using the central
difference formula with step size h= 0.1.
21
Step 1: Calculate f(2),f(1.9), and f(2.1)
f(2) = 232(2)23(2) + 1 = 8 86 + 1 = 5
f(1.9) = 1.932(1.9)23(1.9) + 1 = 6.859 6.84 5.7 + 1 = 3.681
f(2.1) = 2.132(2.1)23(2.1) + 1 = 9.261 8.82 6.3 + 1 = 4.859
Step 2: Apply the central difference formula The central difference
formula for numerical differentiation is given by:
f(x)f(x+h)f(xh)
2h
Substitute x= 2 and h= 0.1:
f(2) f(2.1) f(1.9)
2(0.1) =4.859 (3.681)
0.2=1.178
0.2=5.89
Therefore, the numerical differentiation of f(x) at x= 2 is approximately
5.89.
Now, let’s use numerical integration with the trapezoidal rule to approximate
the value of R2.5
1f(x)dx with n= 4 intervals.
Step 3: Calculate the subintervals and function values Divide the
interval [1,2.5] into 4 equal subintervals: [1,1.375], [1.375,1.75], [1.75,2.125],
and [2.125,2.5].
Calculate the function values at the endpoints of the subintervals:
f(1) = 132(1)23(1) + 1 = 3
f(1.375) = 5.514
f(1.75) = 2.875
f(2.125) = 1.766
f(2.5) = 2.375
Step 4: Apply the trapezoidal rule The trapezoidal rule formula for
numerical integration is:
Z2.5
1
f(x)dx h
2[f(x0)+2
n1
X
i=1
f(xi) + f(xn)]
where his the width of each subinterval and xiare the points at which the
function is evaluated.
Substitute the values for our case with h= 0.375:
Z2.5
1
f(x)dx 0.375
2[3 + 2(5.514 2.875 + 1.766) 2.375]
Z2.5
1
f(x)dx 0.1875 ×[13.820]
Z2.5
1
f(x)dx 2.5875
Therefore, using the trapezoidal rule with 4 intervals, the value of R2.5
1f(x
22
Question 21
Question
Find the numerical approximation of the derivative of f(x) = ex2at x= 1
using the central difference formula with a step size of h= 0.1.
Solution
Step 1: Calculate the central difference formula for the derivative of f(x): The
central difference formula for the derivative of a function f(x) is given by:
f(x)f(x+h)f(xh)
2h
where his the step size.
Step 2: Substitute f(x) = ex2into the central difference formula:
f(x)e(1+0.1)2e(10.1)2
2(0.1)
Step 3: Calculate the numerical approximation:
f(1) e1.12e0.92
0.2
f(1) e1.21 e0.81
0.2
f(1) 0.2974 0.4493
0.2
f(1) 0.1519
0.2
f(1) 0.7595
Therefore, the numerical approximation of f(1) using the central difference
formula with a step size of h= 0.1 is approximately 0.7595.
Question 22
Question
Let f(x) = exln(x) and g(x) = Rx
1f(t)dt. Find g(2) using numerical methods.
23
Solution
Step 1: Compute f(x).
f(x) = exln(x)
f(x) = ex·1
x+ex·ln(x)
Step 2: Evaluate f(2).
f(2) = e2·1
2+e2·ln(2)
Step 3: Approximate g(2) using the formula:
g(2) g(2 + h)g(2)
h,
where his a small positive number. Let’s take h= 0.1 for this calculation.
Step 4: Calculate g(2).
g(2) = Z2
1
f(t)dt
g(2) = Z2
1
etln(t)dt
Step 5: Use numerical methods (e.g. Simpson’s rule) to approximate the
integral:
g(2) h
3[f(1) + 4f(1.5) + 2f(2)],
where h= 0.5.
Step 6: Substitute the values of f(x) at different points into the formula and
calculate g(2).
Step 7: Compute g(2 + h).
g(2 + h) = Z2.1
1
f(t)dt
Step 8: Use Simpson’s rule to approximate the integral at the points 1, 1.5,
and 2.1.
Step 9: Substitute the values of f(x) at different points into the formula and
calculate g(2 + h).
Step 10: Finally, find g(2) g(2+h)g(2)
husing the calculated values of g(2)
and g(2 + h).
Question 23
Question
Let f(x) = ex2. Calculate an approximation for f′′(0) using the centered
difference formula with h= 0.1 and an approximation for R1
0ex2dx using the
trapezoidal rule with n= 4.
24
Solution
To approximate f′′(0), we will use the centered difference formula:
f′′(0) f(h)2f(0) + f(h)
h2
where h= 0.1.
Step 1: Calculate f(0.1), f(0), and f(0.1).
f(0.1) = e(0.1)2=e0.01
f(0) = e0= 1
f(0.1) = e(0.1)2=e0.01
Step 2: Substitute the values into the centered difference formula.
f′′(0) e0.01 2(1) + e0.01
0.12
Step 3: Simplify the expression.
f′′(0) e0.01 2 + e0.01
0.01
Now, to approximate R1
0ex2dx using the trapezoidal rule with n= 4, we
have:
Zb
a
f(x)dx h
2(f(x0)+2f(x1)+2f(x2)+2f(x3) + f(x4))
where h=ba
n.
Step 4: Calculate hand determine the values of f(xi).
h=10
4= 0.25
f(x0) = e(0)2= 1
f(x1) = e(0.25)2
f(x2) = e(0.5)2
f(x3) = e(0.75)2
f(x4) = e(1)2=e1
Step 5: Substitute the values into the trapezoidal rule formula.
Z1
0
ex2dx 0.25
21+2f(x1)+2f(x2)+2f(x3) + e1
Step 6: Simplify the expression to find an approximation for the integral.
25
Question 24
Question
Let f(x) = exsin(x).
(a) Find the first derivative of f(x) using the central difference method with
a step size of h= 0.1 at x= 0.5.
(b) Estimate R1
0exsin(x)dx using the trapezoidal rule with n= 4 subinter-
vals.
Solution
(a) To find the first derivative of f(x) at x= 0.5 using the central difference
method with a step size of h= 0.1, we can use the formula:
f(x)f(x+h)f(xh)
2h
Step 1: Calculate f(0.5 + h) and f(0.5h):
f(0.5 + h) = e0.5+0.1sin(0.5+0.1) = e0.6sin(0.6) 0.888
f(0.5h) = e0.50.1sin(0.50.1) = e0.4sin(0.4) 0.233
Step 2: Calculate the derivative at x= 0.5:
f(0.5) 0.888 0.233
2(0.1) =0.655
0.2= 3.275
Therefore, the approximate value of f(0.5) is 3.275.
(b) To estimate R1
0exsin(x)dx using the trapezoidal rule with n= 4 subin-
tervals, we use the formula:
Zb
a
f(x)dx h
2"f(a)+2 n1
X
i=1
f(a+ih)!+f(b)#
where a= 0, b= 1, h=ba
n=1
4= 0.25.
Step 1: Calculate the values of f(x) at the endpoints and interior points:
f(0) = e0sin(0) = 0
f(0.25) = e0.25 sin(0.25) 0.292
f(0.5) = e0.5sin(0.5) 0.420
f(0.75) = e0.75 sin(0.75) 0.565
f(1) = e1sin(1) 1.208
26
Step 2: Apply the trapezoidal rule formula to estimate the integral:
Z1
0
exsin(x)dx 0.25
2[0 + 2(0 + 0.292 + 0.420 + 0.565) + 1.208]
= 0.125 ·2(1.277)
= 0.31925
Therefore, the estimate of R1
0exsin(x)dx using the trapezoidal rule with
n= 4 subintervals is 0.31925.
Question 25
Question
Given the function f(x) = excos(x), approximate the value of f′′(π
2) using a
three-point centered difference formula with step size h=π
4.
Solution
Step 1: Find f′′(x)
f(x) = excos(x)
f(x) = excos(x)exsin(x)
f′′(x)=2excos(x)
Step 2: Apply the three-point centered difference formula The three-point
centered difference formula for the second derivative is given by:
f′′(x)f(x+h)2f(x) + f(xh)
h2
Step 3: Calculate f′′(π
2) Using h=π
4, we have:
f′′(π
2)f(π
2+π
4)2f(π
2) + f(π
2π
4)
(π
4)2
f′′(π
2)f(3π
4)2f(π
2) + f(π
4)
(π
4)2
f′′(π
2)e3π
4cos3π
42eπ
2cosπ
2+eπ
4cosπ
4
(π
4)2
f′′(π
2)e3π
4·(2
2)2eπ
2·0 + eπ
4·2
2
(π
4)2
f′′(π
2)2
2e3π
4+2
2eπ
4
(π
4)2
27
f′′(π
2)2
2eπ
4+2 +2
2eπ
4
(π
4)2
f′′(π
2)2
2eπ
4+2
2eπ
4
(π
4)2
f′′(π
2)0
Question 26
Question
Let f(x) = e3xsin(4x).
a) Determine the fourth order forward difference approximation for f(0)
using equally spaced nodes with step size h= 0.2.
b) Estimate the value of R1.2
0e3xsin(4x)dx using Simpson’s Rule with n= 4
subintervals.
Solution
a) To approximate the fourth order forward difference for f(0), we first need
to find the necessary derivatives of f(x):
f(x)=3e3xsin(4x)+4e3xcos(4x)
f′′(x)=9e3xsin(4x) + 12e3xcos(4x)
f′′′(x) = 27e3xsin(4x)48e3xcos(4x)
Now, we can use these derivatives to find the fourth order forward difference
approximation for f(0):
f(0) 25f(0) + 48f(0.2) 36f(0.4) + 16f(0.6) 3f(0.8)
12h
Substitute f(x) = e3xsin(4x) into the formula above and calculate the numerical
approximation.
b) To estimate the integral using Simpson’s Rule, we divide the interval
[0,1.2] into n= 4 subintervals, where h=ba
n=1.20
4= 0.3. Simpson’s Rule
is given by:
Zb
a
f(x)dx h
3[f(x0)+4f(x1)+2f(x2)+4f(x3)+2f(x4)+···+4f(xn1)+f(xn)]
Substitute f(x) = e3xsin(4x) into the formula above and evaluate the integral
with n= 4 subintervals using the given step size.
28
Question 27
Question
Let f(x) = sinx2and let f(x) and f′′(x) denote the first and second deriva-
tives of frespectively. Consider the integral R1
0f′′(x)dx. Approximate this
integral using the composite Simpson’s rule with n= 4 subintervals.
Solution
Step 1: First, we need to find an expression for f′′(x). Given that f(x) =
sinx2, we have:
f(x)=2xcosx2
f′′(x) = 2 cosx24x2sinx2
Step 2: Next, we need to find the composite Simpson’s rule formula. Given
n= 4 subintervals on [0,1], the composite Simpson’s rule is given by:
Z1
0
f′′(x)dx 1
3h[f′′(x0)+4f′′(x1)+2f′′(x2)+4f′′(x3) + f′′(x4)]
where his the width of each subinterval, given by h=10
4=1
4.
Step 3: Substitute the values of f′′(xi) into the composite Simpson’s rule
formula. We have the following values for f′′(xi):
f′′(0) = 2 cos(0) 4(0)2sin(0) = 2
f′′(1
4) = 2 cos1
1641
42
sin1
16
f′′(1
2) = 2 cos1
441
22
sin1
4
f′′(3
4) = 2 cos9
1643
42
sin9
16
f′′(1) = 2 cos(1) 4(1)2sin(1)
Step 4: Now, substitute these values into the composite Simpson’s rule for-
mula and evaluate the integral. Calculating the numerical integral:
Z1
0
f′′(x)dx 1
3·1
4
[2 + 4f′′(1
4)+2f′′(1
2)+4f′′(3
4) + f′′(1)]
Question 28
Question
Let f(x) = x32x2+ 3x4 be a function. Find the value of the integral
R3
1f(x)dx using the Trapezoidal Rule with n= 4 subintervals.
29
Solution
Step 1: Determine the width of each subinterval. Let xbe the width of each
subinterval. In this case, since we have 4 subintervals in the interval [1,3], we
have x=31
4= 0.5.
Step 2: Create a table of values. We need to evaluate f(x) at the endpoints
and interior points of the subintervals. Below is the table of values:
x f(x)
12
1.52.375
24
2.57.375
310
Step 3: Apply the Trapezoidal Rule formula. The Trapezoidal Rule formula
for numerical integration is:
Zb
a
f(x)dx x
2[f(x0)+2f(x1)+2f(x2)+2f(x3) + f(x4)]
Substitute the values into the formula:
Z3
1
f(x)dx 0.5 [(2) + 2(2.375) + 2(4) + 2(7.375) + (10)]
Z3
1
f(x)dx 0.5[24.75 814.75 10]
Z3
1
f(x)dx 0.5(39.5) = 19.75
Therefore, the value of the integral R3
1f(x)dx using the Trapezoidal Rule
with 4 subintervals is 19.75.
Question 29
Question
Find the numerical approximation of the integral R1
0exsin(x)dx using the trape-
zoidal rule with n= 4 subintervals.
Solution
Step 1: First, we need to calculate the step size, h, using the formula h=ba
n,
where a= 0, b= 1, and n= 4.
Step 1: h=10
4=1
4= 0.25
30
Step 2: Next, we compute the values of the function at each of the subinterval
endpoints: x0= 0, x1= 0.25, x2= 0.5, x3= 0.75, and x4= 1.
y0=e0sin(0) = 0
y1=e0.25 sin(0.25) 0.2834
y2=e0.5sin(0.5) 0.8118
y3=e0.75 sin(0.75) 1.3782
y4=e1sin(1) 1.0672
Step 3: Apply the trapezoidal rule formula Rb
af(x)dx hy0
2+y1+y2+y3+y4
2.Step 3: R1
0exsin(x)dx
0.25 0
2+ 0.2834 + 0.8118 + 1.3782 + 1.0672
2
Step 3: Z1
0
exsin(x)dx 0.25(0.1417 + 0.8118 + 1.3782 + 0.5336)
Step 3: Z1
0
exsin(x)dx 0.25(2.8653)
Step 3: Z1
0
exsin(x)dx 0.716325
Therefore, the numerical approximation of the integral R1
0exsin(x)dx using
the trapezoidal rule with n= 4 subintervals is approximately 0.716325.
Question 30
Question
Let f(x) = sin(x) and g(x) = Rx
0f(t)dt. Find g(x) using numerical differentia-
tion.
Solution
Given f(x) = sin(x) and g(x) = Rx
0f(t)dt, we want to find g(x).
Step 1: Use numerical differentiation formula:
g(x)g(x+h)g(x)
h
where his the step size.
Step 2: Express g(x) in terms of f(x):
g(x) = Zx
0
sin(t)dt
31
Step 3: Let’s find an approximation for g(x) using h= 0.01.
g(x)g(x+ 0.01) g(x)
0.01
Step 4: Calculate g(x) and g(x+ 0.01):
g(x) = Zx
0
sin(t)dt =cos(0) + cos(x) = 1 cos(x)
g(x+ 0.01) = Zx+0.01
0
sin(t)dt = 1 cos(x+ 0.01)
Step 5: Substitute into the formula:
g(x)1cos(x+ 0.01) (1 cos(x))
0.01
Step 6: Simplify the expression:
g(x)cos(x)cos(x+ 0.01)
0.01
Therefore, the numerical approximation for g(x) is cos(x)cos(x+0.01)
0.01 .
Question 31
Question
Let f(x) = e2xcos(3x). Use a centered difference scheme with a step size of
h= 0.1 to approximate f(0.5) and f′′(0.5). Then, use the trapezoidal rule
with n= 4 to approximate R1
0f(x)dx.
Solution
Step 1: Find the approximations for f(0.5) using a centered difference scheme:
First, we have:
f(x)f(x+h)f(xh)
2h
Plugging in x= 0.5 and h= 0.1, we get:
f(0.5) f(0.5+0.1) f(0.50.1)
2(0.1)
Calculating f(0.6) and f(0.4):
f(0.6) = e2(0.6) cos(3(0.6)) 4.11113
f(0.4) = e2(0.4) cos(3(0.4)) 1.86982
32
Therefore:
f(0.5) 4.11113 1.86982
2(0.1) 2.24131
0.211.20655
Step 2: Find the approximation for f′′(0.5) using a centered difference
scheme:
Second derivative can be approximated as:
f′′(x)f(x+h)2f(x) + f(xh)
h2
Plugging in x= 0.5 and h= 0.1, we get:
f′′(0.5) f(0.5+0.1) 2f(0.5) + f(0.50.1)
0.12
Calculating f(0.6), f(0.5), and f(0.4):
f(0.6) 4.11113
f(0.5) = e2(0.5) cos(3(0.5)) 3.1203
f(0.4) 1.86982
Therefore:
f′′(0.5) 4.11113 2(3.1203) + 1.86982
0.120.860723
0.01 86.0723
Step 3: Use the trapezoidal rule to approximate R1
0f(x)dx:
The trapezoidal rule is given by:
Zb
a
f(x)dx hf(a)
2+f(a+h) + f(a+ 2h) + ... +f(bh) + f(b)
2
Using a= 0, b= 1, h=10
4= 0.25:
Z1
0
f(x)dx 0.25 f(0)
2+f(0.25) + f(0.5) + f(0.75) + f(1)
2
Calculating f(0), f(0.25), f(0.75), and f(1):
f(0) = 1
f(0.25) = e2(0.25) cos(3(0.25)) 1.88812
f(0.75) = e2(0.75) cos(3(0.75)) 4.84031
f(1) = e2(1) cos(3(1)) 9.16867
Therefore:
Z1
0
f(x)dx 0
33
Question 32
Question
Let f(x) = x4+ 2x35x2+ 7x3.
a) Find an approximation to f(2) using the forward difference formula with
step size h= 0.1.
b) Estimate R2
1f(x)dx using the trapezoidal rule with n= 4 subintervals.
Solution
a) To approximate f(2) using the forward difference formula, we use the for-
mula:
f(x)f(x+h)f(x)
h
Step 1: Calculate f(2) and f(2.1).
f(2) = (2)4+ 2(2)35(2)2+ 7(2) 3 = 16 + 16 20 + 14 3 = 23
f(2.1) = (2.1)4+ 2(2.1)35(2.1)2+ 7(2.1) 341.441
Step 2: Substitute the values into the formula to find the approximation to
f(2).
f(2) f(2.1) f(2)
0.1=41.441 23
0.1184.41
Therefore, the approximation to f(2) using the forward difference formula
is approximately 184.41.
b) To estimate R2
1f(x)dx using the trapezoidal rule, we use the formula:
Zb
a
f(x)dx h
2 f(x0)+2
n1
X
i=1
f(xi) + f(xn)!
where h=ba
nand xi=a+ih for i= 0,1, . . . , n.
Step 1: Calculate hand the values of f(x) at each subinterval.
h=21
4= 0.25
f(1) = 14+ 2(1)35(1)2+ 7(1) 3 = 1 + 2 5+73=2
f(1.25) = (1.25)4+ 2(1.25)35(1.25)2+ 7(1.25) 34.42
f(1.5) = 1.54+ 2(1.5)35(1.5)2+ 7(1.5) 3=5.0625 + 13.511.25 + 10.53 = 16.8125
f(1.75) = (1.75)4+ 2(1.75)35(1.75)2+ 7(1.75) 339.21
f(2) = 24+ 2(2)35(2)2+ 7(2) 3 = 16 + 16 20 + 14 3 = 23
34
Step 2: Substitute the values into the trapezoidal rule formula to estimate
the integral.
Z2
1
f(x)dx 0.25
2(2 + 2(4.42 + 16.8125 + 39.21) + 23) 21.758
Therefore, the estimate of R2
1f(x)dx using the trapezoidal rule with 4 subin-
tervals is approximately 21.758.
Question 33
Question
Let f(x) = sinx2and f(x) be the derivative of f(x). Consider the following
numerical differentiation and integration methods:
Numerical differentiation:
f(x)f(x+h)f(x)
h
Numerical integration:
Z1
0
f(x)dx 1
6f(0) + 4f1
2+f(1)
Calculate the numerical derivative and the numerical integral of f(x) us-
ing the given methods. Verify the results by evaluating f(x) and R1
0f(x)dx
analytically.
Solution
We will first calculate the numerical derivative f(x) using the numerical differ-
entiation formula:
Step 1: Substitute the function f(x) = sinx2into the numerical differen-
tiation formula:
f(x)f(x+h)f(x)
h
f(x)sin(x+h)2sinx2
h
Step 2: Expand sin(x+h)2using the formula sin(a+b) = sin(a) cos(b)+
cos(a) sin(b):
sin(x+h)2= sinx2+ 2xh +h2= sinx2cos(2xh) + cosx2sin(2xh)
Step 3: Plug the expansion into the numerical differentiation formula:
f(x)sinx2cos(2xh) + cosx2sin(2xh)sinx2
h
35
Step 4: Simplify and take the limit as happroaches 0 to find f(x) analyt-
ically.
Now, we will calculate the numerical integral of f(x) using the given numer-
ical integration formula:
Step 5: Substitute the function f(x) = sinx2into the numerical integra-
tion formula:
Z1
0
f(x)dx 1
6f(0) + 4f1
2+f(1)
Step 6: Evaluate f(0), f1
2, and f(1):
f(0) = sin(0) = 0
f1
2= sin 1
4
f(1) = sin(1)
Step 7: Substitute the values into the numerical integration formula and
simplify to find the numerical integral of f(x).
By comparing the numerical results with the analytical results of f(x) and
R1
0f(x)dx, we can verify the correctness of our calculations.
Question 34
Question
Find the numerical approximation of the derivative of f(x) = e2xsin(x) at
x=π
4using the five-point midpoint formula. Then, use the trapezoidal rule to
approximate the integral of f(x) from 0 to π
2using 4 subintervals.
Solution
Let’s first find the numerical approximation of the derivative of f(x) = e2xsin(x)
at x=π
4using the five-point midpoint formula:
Step 1: Calculate the step size hThe five-point midpoint formula re-
quires equally spaced points around the point at which we are approximating
the derivative. Therefore, let’s choose h=π
8.
Step 2: Compute the derivative of f(x)at x=π4 Using the five-point
midpoint formula:
f(π
4)f(π
4+ 2h)+8f(π
4+h)8f(π
4h) + f(π
42h)
12h
Step 3: Evaluate the derivative Substitute h=π
8and calculate:
f(π
4)f(3π
4)+8f(5π
8)8f(3π
8) + f(π
4)
3π
4
36
Next, let’s use the trapezoidal rule to approximate the integral of f(x) =
e2xsin(x) from 0 to π
2using 4 subintervals:
Step 4: Calculate the interval width hThe trapezoidal rule uses the
formula:
Area h f(x0)
2+
n1
X
i=1
f(xi) + f(xn)
2!
where h=ba
n.
For this case, a= 0, b=π
2, and n= 4 which means h=
π
20
4=π
8.
Step 5: Apply the trapezoidal rule Substitute the values into the for-
mula and calculate the approximate integral using 4 subintervals.
Question 35
Question
Consider the function f(x) = ex2.
(a) Find the second derivative of f(x).
(b) Use numerical differentiation to estimate the value of f′′(1) with a step
size of h= 0.1.
(c) Use numerical integration with the trapezoidal rule to find R1
0f(x)dx
with n= 4 subintervals.
Solution
(a) To find the second derivative of f(x) = ex2, we first need to find the first
derivative, then differentiate again.
Step 1: Find the first derivative of f(x)
f(x) = d
dxex2= 2xex2
Step 2: Find the second derivative of f(x)
f′′(x) = d
dx(2xex2)=2ex2+ 4x2ex2= (2 + 4x2)ex2
(b) Now, to estimate f′′(1) using numerical differentiation with a step size
of h= 0.1, we use the central difference formula:
f′′(1) f(1 + h)2f(1) + f(1 h)
h2
37
Question 8
Question
Let f(x) = cos(x). Use the central difference method with h= 0.1 to estimate
f(1).
Solution
Step 1: Find f(1), f(0.9), and f(1.1).
f(1) = cos(1) 0.5403,
f(0.9) = cos(0.9) 0.6216,
f(1.1) = cos(1.1) 0.4536.
Step 2: Use the central difference method formula to estimate f(1).
f(1) f(1.1) f(0.9)
2h
Step 3: Substitute the values to find the numerical estimation of f(1).
f(1) 0.4536 0.6216
2×0.1
=0.168
0.2
=0.84.
Therefore, the estimation of f(1) using the central difference method with
h= 0.1 is approximately 0.84.
Question 9
Question
Given the function f(x) = exsin(x), find the numerical derivative of f(x) with
respect to xat x=π
4using the central difference method with a step size of
h= 0.1. Then, use the trapezoidal rule with n= 4 to approximate the integral
of f(x) from 0 to π
2.
Solution
To find the numerical derivative of f(x) at x=π
4using the central difference
method, we have:
f(x)f(x+h)f(xh)
2h
where h= 0.1. Substituting x=π
4into the formula:
9
Step 1: Calculate fπ
4,fπ
4+ 0.1, and fπ
40.1.
fπ
4=eπ
4sin π
4
fπ
4+ 0.1=eπ
4+0.1sin π
4+ 0.1
fπ
40.1=eπ
40.1sin π
40.1
Step 2: Calculate the numerical derivative.
fπ
4fπ
4+ 0.1fπ
40.1
2(0.1)
Now, to approximate the integral of f(x) from 0 to π
2using the trapezoidal
rule with n= 4:
Step 3: Calculate the step size h.
h=
π
20
4
Step 4: Apply the trapezoidal rule formula.
Zπ
2
0
f(x)dx h
2"f(x0)+2
n1
X
i=1
f(xi) + f(xn)#
Step 5: Evaluate the integral using the computed values of f(xi) and h.
Therefore, we have found the numerical derivative of f(x) at x=π
4and
approximated the integral of f(x) from 0 to π
2using the trapezoidal rule.
Question 10
Question
Let f(x) = sin(x)
xand g(x) = ex2. Find the numerical derivative of f(x)·g(x)
at x= 1 using the central difference formula, accurate to four decimal places.
Solution
To find the numerical derivative of f(x)·g(x) at x= 1 using the central difference
formula, we will first compute the derivatives of f(x) and g(x).
Step 1: Find f(x)
f(x) = sin(x)
x=cos(x)·xsin(x)·1
x2=x·cos(x)sin(x)
x2
Step 2: Find g(x)
g(x) = ex2=2x·ex2
10
Step 3: Find f(1) and g(1)
f(1) = 1·cos(1) sin(1)
12=cos(1) sin(1)
g(1) = 2·1·e12=2e1
Step 4: Calculate the numerical derivative of f(x)·g(x) at x= 1
df ·g
dx |x=1 f(1) ·g(1) + f(1) ·g(1)
(cos(1) sin(1)) ·e1+sin(1)
1·(2e1)
(cos(1) sin(1)) ·e12·sin(1) ·e1
(cos(1) sin(1) 2·sin(1)) ·e1
(cos(1) 3·sin(1)) ·e1
Therefore, the numerical derivative of f(x)·g(x) at x= 1 using the central
difference formula is (cos(1) 3·sin(1)) ·e1, accurate to four decimal places.
Question 11
Question
Let f(x) = sin(x) and g(x) = cos(x). Using numerical differentiation and
integration techniques, find the value of the integral Rπ/4
0f(x)·g(x)dx with an
error less than 0.01.
Solution
Step 1: Let’s first find the equation for f(x)·g(x).
f(x)·g(x) = sin(x)·cos(x) = sin(2x)
2
Step 2: To find the integral of sin(2x)
2from 0 to π
4, we can use numerical
integration techniques. Let’s divide the interval 0,π
4into Nsubintervals and
use the midpoint rule to approximate the integral:
Zπ/4
0
sin(2x)
2dx π
4N
N
X
k=1
sin 2( π
4Nkπ
8N)
Step 3: To achieve an error less than 0.01, we can use the fact that for the
midpoint rule, the error is bounded by (ba)3
24N2M, where Mis the maximum
11
value of the second derivative of the function being integrated. In this case,
f′′(x) = 2 sin(2x), so M= 2.
Step 4: Now, we solve the inequality (π
4)3
24N2·2<0.01 to find the minimum
number of subintervals Nrequired for the desired accuracy.
Step 5: After calculating N, we can use the midpoint rule formula to compute
the numerical value of the integral Rπ/4
0f(x)·g(x)dx with an error less than
0.01.
Question 12
Question
Let f(x) = 1
xand consider the integral
I=Z2
1
f(x)dx
Use Simpson’s rule with n= 4 to estimate I. Then, use the trapezoidal rule
with n= 8 to estimate I. Finally, use the composite midpoint rule with n= 16
to estimate I.
Solution
Step 1: Simpson’s Rule with n= 4 The formula for Simpson’s rule with n= 4
is:
I1
3·x·[f(x0)+4f(x1)+2f(x2)+4f(x3) + f(x4)]
where x=ba
n,xi=a+ix, and a= 1, b= 2.
Calculating the estimates:
x=21
4=1
4
x0= 1, x1= 1.25, x2= 1.5, x3= 1.75, x4= 2
Substitute the values into the Simpson’s rule formula to get the estimate.
Step 2: Trapezoidal Rule with n= 8 The formula for the Trapezoidal rule
with n= 8 is:
Ix
2f(x0)+2
n1
X
i=1
f(xi) + f(xn)
Calculate the estimate using the given formula.
Step 3: Composite Midpoint Rule with n= 16 The Composite Midpoint
Rule formula is:
Ix
n
X
i=1
fxi1+xi
2
Determine the values of xand xi, then substitute them into the Composite
Midpoint Rule formula to calculate the estimate.
12
Question 13
Question
Evaluate the definite integral Z1
0
ex2dx using Simpson’s Rule with n= 4
subintervals. Then, use the trapezoidal rule with n= 4 subintervals to approx-
imate the value of d
dx Zx
0
et2dtat x= 0.2.
Solution
To evaluate the integral Z1
0
ex2dx using Simpson’s Rule with n= 4 subinter-
vals, we first need to find the step size h:
h=ba
2n=10
2×4=1
8
Next, we calculate the approximated value of the integral using Simpson’s
Rule:
Approximated Value = h
3[f(x0)+4f(x1)+2f(x2)+4f(x3) + f(x4)]
where xi=a+ih.
For i= 0,1,2,3,4:
f(0) = e02= 1
f(1/8) = e(1/8)20.992
f(2/8) = e(2/8)20.976
f(3/8) = e(3/8)20.943
f(4/8) = e(4/8)2=e1/20.607
Now, substitute the values into the formula to find the approximated value
of the integral.
For the second part, we will use the trapezoidal rule with n= 4 subintervals
to approximate the derivative of Zx
0
et2dt at x= 0.2. The derivative of an
integral is given by the fundamental theorem of calculus:
d
dx Zx
a
f(t)dt=f(x)
Therefore, we need to find the function f(t) to evaluate f(0.2) using the
13
trapezoidal rule. Let’s calculate the function values for t= 0,1/4,2/4,3/4,4/4:
f(0) = e02= 1
f(1/4) = e(1/4)20.939
f(2/4) = e(2/4)20.886
f(3/4) = e(3/4)20.779
f(4/4) = e(4/4)2=e1= 0.367
Now, apply the trapezoidal rule to approximate f(0.2) by interpolating the
function values at t= 0,1/4,2/4:
Approximated Value = h
2[f(t0)+2f(t1)+2f(t2)+2f(t3) + f(t4)]
Finally, evaluate the derivative at x= 0.2 by substituting the calculated
values into the trapezoidal rule formula.
Question 14
Question
Let f(x) = ex. Use the composite Simpson’s rule with 4 subintervals to esti-
mate the value of the integral R1
0f(x)dx. Then, use a central difference formula
to estimate the derivative of f(x) at x= 1, with a step size of h= 0.1.
Solution
To estimate the integral R1
0f(x)dx using the composite Simpson’s rule with 4
subintervals, we first need to partition [0,1] into 4 equal subintervals:
h=10
4=1
4= 0.25
The nodes are: x0= 0, x1= 0.25, x2= 0.50, x3= 0.75, x4= 1.00.
Step 1: Compute f(x)at the nodes
f(0) = e0= 1
f(0.25) = e0.25 0.7788
f(0.50) = e0.50 0.6065
f(0.75) = e0.75 0.4724
f(1.00) = e10.3679
Step 2: Compute the composite Simpson’s rule estimation
14
Using the formula for the composite Simpson’s rule:
Zb
a
f(x)dx h
3[f(x0)+4f(x1)+2f(x2)+4f(x3) + f(x4)]
Substitute the values we calculated:
Z1
0
f(x)dx 0.25
3[1 + 4(0.7788) + 2(0.6065) + 4(0.4724) + 0.3679]
0.25
3[1 + 3.1152 + 1.213 + 1.8896 + 0.3679]
0.25
3·7.5857
0.6313
Therefore, the estimated value of the integral R1
0f(x)dx using the composite
Simpson’s rule with 4 subintervals is approximately 0.6313.
Step 3: Estimate the derivative using central difference formula
The central difference formula for the first derivative is given by:
f(x)f(x+h)f(xh)
2h
Substitute x= 1 and h= 0.1:
f(1) f(1.1) f(0.9)
2(0.1)
Calculate f(1.1) and f(0.9):
f(1.1) = e1.10.3329
f(0.9) = e0.90.4066
Substitute these values:
f(1) 0.3329 0.4066
2(0.1)
0.0737
0.2
0.3685
Therefore, the estimated value of the derivative of f(x) at x= 1 using the
central difference formula with a step size of h= 0.1 is approximately -0.3685.
15
Question 15
Question
Let f(x) = e2x.
(a) Find the 3-point forward difference approximation to f(0) using step
size h= 0.1.
(b) Estimate R1
0e2xdx using the trapezoidal rule with n= 4 subintervals.
Solution
(a) To find the 3-point forward difference approximation to f(0), we can use
the formula:
f(0) 3f(0) + 4f(h)f(2h)
2h
Step 1: Calculate f(0), f(h), and f(2h):
f(0) = e2·0= 1
f(h) = e2·0.1=e0.2
f(2h) = e2·0.2=e0.4
Step 2: Substitute the values into the formula:
f(0) 3(1) + 4(e0.2)e0.4
2(0.1)
f(0) 3+4e0.2e0.4
0.2
(b) To estimate R1
0e2xdx using the trapezoidal rule, we divide the interval
[0,1] into n= 4 subintervals. The trapezoidal rule formula for this case is:
Z1
0
e2xdx h
2 f(x0)+2
n1
X
i=1
f(xi) + f(xn)!
Step 1: Calculate hand the values of f(xi):
h=10
4= 0.25
f(x0) = f(0) = 1
f(x1) = f(0.25) = e0.5
f(x2) = f(0.5) = e1
f(x3) = f(0.75) = e1.5
f(x4) = f(1) = e2
16
Step 2: Substitute the values into the trapezoidal rule formula:
Z1
0
e2xdx 0.25
21 + 2(e0.5+e1+e1.5) + e2
Z1
0
e2xdx 0.125 1+2e0.5+ 2e1+ 2e1.5+e2
Question 16
Question
Let f(x)=2x35x2+ 3x+ 7. Find the value of the definite integral of f(x)
from 1 to 3. Then, use the central difference formula with a step size of h= 0.1
to approximate f(2).
Solution
To find the definite integral of f(x) from 1 to 3, we need to evaluate R3
1(2x3
5x2+ 3x+ 7) dx.
Step 1: Integrate f(x):
Z(2x35x2+ 3x+ 7) dx =1
2·2x41
3·5x3+1
2·3x2+ 7x+C
Z(2x35x2+ 3x+ 7) dx =x45
3x3+3
2x2+ 7x+C
Step 2: Evaluate the definite integral from 1 to 3:
Z3
1
(2x35x2+ 3x+ 7) dx =x45
3x3+3
2x2+ 7x3
1
Z3
1
(2x35x2+3x+7) dx =(3)45
3(3)3+3
2(3)2+ 7(3)(1)45
3(1)3+3
2(1)2+ 7(1)
Z3
1
(2x35x2+ 3x+ 7) dx = 81 45 + 27
2+ 21 1 + 5
3+3
2+ 7
Z3
1
(2x35x2+ 3x+ 7) dx = 56.5
Therefore, the definite integral of f(x) from 1 to 3 is 56.5.
Step 3: Use the central difference formula with h= 0.1 to approximate
f(2): The central difference formula is given by:
f(x)f(x+h)f(xh)
2h
17
Substitute x= 2 and h= 0.1:
f(2) f(2 + 0.1) f(2 0.1)
2·0.1
f(2) f(2.1) f(1.9)
0.2
Now, calculate f(2.1) and f(1.9):
f(2.1) = 2(2.1)35(2.1)2+ 3(2.1) + 7
f(2.1) = 19.661
f(1.9) = 2(1.9)35(1.9)2+ 3(1.9) + 7
f(1.9) = 14.559
Now substitute these values back into the formula:
f(2) 19.661 14.559
0.2
f(2) 25.51
Therefore, the approximate value of f(2) using the central difference formula
with h= 0.1 is 25.51.
Question 17
Question
Let f(x) = exsin(x). Compute the numerical approximations of f(1) using the
central difference method with step sizes h= 0.1 and h= 0.01.
Solution
To approximate f(1) using the central difference method, we use the formula:
f(x)f(x+h)f(xh)
2h
Step 1: Compute f(1) with h= 0.1:
f(1) f(1 + 0.1) f(1 0.1)
2×0.1=f(1.1) f(0.9)
0.2
=e1.1sin(1.1) e0.9sin(0.9)
0.2
Step 2: Compute f(1) with h= 0.01:
f(1) f(1 + 0.01) f(1 0.01)
2×0.01 =f(1.01) f(0.99)
0.02
=e1.01 sin(1.01) e0.99 sin(0.99)
0.02
18
Question 18
Question
Given the function f(x) = sin(x), approximate the derivative of f(x) at x=π
4
using the forward difference method with h= 0.1 and the trapezoidal rule with
4 equal subintervals on the interval [0,π
2].
Solution
We will first approximate the derivative using the forward difference method,
and then approximate the integral using the trapezoidal rule.
Step 1: Approximating the Derivative using Forward Difference
Method The forward difference approximation for the derivative of a function
f(x) at x0with step size his given by:
f(x0)f(x0+h)f(x0)
h
Given f(x) = sin(x) and x0=π
4, we have:
f(π
4)sinπ
4+ 0.1sinπ
4
0.1
Calculating the values:
f(π
4)sin7π
40 sinπ
4
0.1
f(π
4)
2
22
2
0.1= 0
Therefore, the approximate derivative of f(x) at x=π
4using the forward
difference method is 0.
Step 2: Approximating the Integral using Trapezoidal Rule Given
a function f(x) and the interval [a, b], the trapezoidal rule estimates the integral
of f(x) over [a, b] as:
Zb
a
f(x)dx h
2[f(a)+2f(a+h)+2f(a+ 2h) + . . . + 2f(bh) + f(b)]
where h=ba
nand nis the number of subintervals.
In our case, f(x) = sin(x), a= 0, b=π
2,n= 4 and h=π
8.
Substitute these values into the formula:
Zπ
2
0
sin(x)dx
π
8
2[sin(0) + 2 sinπ
8+ 2 sinπ
4+ 2 sin3π
8+ sinπ
2]
19
Calculating the values:
Zπ
2
0
sin(x)dx π
16[0 + 2 sinπ
8+ 2 sinπ
4+ 2 sin3π
8+ 1]
Zπ
2
0
sin(x)dx π
16[0 + 2p2 + 2
2+ 22
2+ 2p22
2+ 1]
Zπ
2
0
sin(x)dx π
16[2 + 2q2 + 2+22+2q22 + 1]
Zπ
2
0
sin(x)dx π
16[3 + 2q2 + 2+3q22]
Therefore, the approximate value of the integral of sin(x) over [0,π
2] using
the
Question 19
Question
Consider the following function: f(x) = ex2. Perform the following operations:
1. Find the first derivative of f(x) at x= 0 using forward difference approx-
imation with h= 0.1.
2. Find the second derivative of f(x) at x= 0 using central difference ap-
proximation with h= 0.01.
3. Find the definite integral of f(x) from x= 0 to x= 1 using the trapezoidal
rule with 4 subintervals.
Solution
1. Find the first derivative of f(x) at x= 0 using forward difference approxi-
mation with h= 0.1: Step 1: The forward difference approximation for the first
derivative is given by:
f(x)f(x+h)f(x)
h
Plugging in x= 0 and h= 0.1, we get:
f(0) f(0 + 0.1) f(0)
0.1=e(0.1)2e0
0.1
f(0) e0.01 1
0.10.99005 1
0.10.00995
0.1 0.0995
20
2. Find the second derivative of f(x) at x= 0 using central difference
approximation with h= 0.01: Step 1: The central difference approximation for
the second derivative is given by:
f′′(x)f(x+h)2f(x) + f(xh)
h2
Plugging in x= 0 and h= 0.01, we get:
f′′(0) f(0 + 0.01) 2f(0) + f(0 0.01)
0.012=e(0.01)22e0+e(0.01)2
0.0001
f′′(0) e0.0001 2e0.0001
0.0001 0.99995 20.99995
0.0001 2.00005
0.0001 20.0005
3. Find the definite integral of f(x) from x= 0 to x= 1 using the trapezoidal
rule with 4 subintervals: Step 1: The trapezoidal rule is given by:
Zb
a
f(x)dx h
2[f(a)+2
n1
X
i=1
f(xi) + f(b)]
where h=ba
n, the width of each subinterval, and xi=a+ih. Plugging in
a= 0, b= 1, n= 4, h=10
4= 0.25, we get:
Z1
0
ex2dx 0.25
2[e(0)2+ 2e(0.25)2+ 2e(0.5)2+ 2e(0.75)2+e(1)2]
Z1
0
ex2dx 0.25
2[1+2e0.0625+2e0.25+2e0.5625+e1]0.25
2[1+2(0.9401)+2(0.7788)+2(0.5718)+0.3679]
Z1
0
ex2dx 0.25
2[1 + 1.8802 + 1.557
Question 20
Question
Let f(x) = x32x23x+ 1. Find the numerical differentiation of f(x) at
x= 2 using the central difference formula with a step size of h= 0.1. Then,
use numerical integration with the trapezoidal rule with n= 4 intervals to
approximate the value of R2.5
1f(x)dx.
Solution
Let’s first find the numerical differentiation of f(x) at x= 2 using the central
difference formula with step size h= 0.1.
21
Step 1: Calculate f(2),f(1.9), and f(2.1)
f(2) = 232(2)23(2) + 1 = 8 86 + 1 = 5
f(1.9) = 1.932(1.9)23(1.9) + 1 = 6.859 6.84 5.7 + 1 = 3.681
f(2.1) = 2.132(2.1)23(2.1) + 1 = 9.261 8.82 6.3 + 1 = 4.859
Step 2: Apply the central difference formula The central difference
formula for numerical differentiation is given by:
f(x)f(x+h)f(xh)
2h
Substitute x= 2 and h= 0.1:
f(2) f(2.1) f(1.9)
2(0.1) =4.859 (3.681)
0.2=1.178
0.2=5.89
Therefore, the numerical differentiation of f(x) at x= 2 is approximately
5.89.
Now, let’s use numerical integration with the trapezoidal rule to approximate
the value of R2.5
1f(x)dx with n= 4 intervals.
Step 3: Calculate the subintervals and function values Divide the
interval [1,2.5] into 4 equal subintervals: [1,1.375], [1.375,1.75], [1.75,2.125],
and [2.125,2.5].
Calculate the function values at the endpoints of the subintervals:
f(1) = 132(1)23(1) + 1 = 3
f(1.375) = 5.514
f(1.75) = 2.875
f(2.125) = 1.766
f(2.5) = 2.375
Step 4: Apply the trapezoidal rule The trapezoidal rule formula for
numerical integration is:
Z2.5
1
f(x)dx h
2[f(x0)+2
n1
X
i=1
f(xi) + f(xn)]
where his the width of each subinterval and xiare the points at which the
function is evaluated.
Substitute the values for our case with h= 0.375:
Z2.5
1
f(x)dx 0.375
2[3 + 2(5.514 2.875 + 1.766) 2.375]
Z2.5
1
f(x)dx 0.1875 ×[13.820]
Z2.5
1
f(x)dx 2.5875
Therefore, using the trapezoidal rule with 4 intervals, the value of R2.5
1f(x
22
Question 21
Question
Find the numerical approximation of the derivative of f(x) = ex2at x= 1
using the central difference formula with a step size of h= 0.1.
Solution
Step 1: Calculate the central difference formula for the derivative of f(x): The
central difference formula for the derivative of a function f(x) is given by:
f(x)f(x+h)f(xh)
2h
where his the step size.
Step 2: Substitute f(x) = ex2into the central difference formula:
f(x)e(1+0.1)2e(10.1)2
2(0.1)
Step 3: Calculate the numerical approximation:
f(1) e1.12e0.92
0.2
f(1) e1.21 e0.81
0.2
f(1) 0.2974 0.4493
0.2
f(1) 0.1519
0.2
f(1) 0.7595
Therefore, the numerical approximation of f(1) using the central difference
formula with a step size of h= 0.1 is approximately 0.7595.
Question 22
Question
Let f(x) = exln(x) and g(x) = Rx
1f(t)dt. Find g(2) using numerical methods.
23
Solution
Step 1: Compute f(x).
f(x) = exln(x)
f(x) = ex·1
x+ex·ln(x)
Step 2: Evaluate f(2).
f(2) = e2·1
2+e2·ln(2)
Step 3: Approximate g(2) using the formula:
g(2) g(2 + h)g(2)
h,
where his a small positive number. Let’s take h= 0.1 for this calculation.
Step 4: Calculate g(2).
g(2) = Z2
1
f(t)dt
g(2) = Z2
1
etln(t)dt
Step 5: Use numerical methods (e.g. Simpson’s rule) to approximate the
integral:
g(2) h
3[f(1) + 4f(1.5) + 2f(2)],
where h= 0.5.
Step 6: Substitute the values of f(x) at different points into the formula and
calculate g(2).
Step 7: Compute g(2 + h).
g(2 + h) = Z2.1
1
f(t)dt
Step 8: Use Simpson’s rule to approximate the integral at the points 1, 1.5,
and 2.1.
Step 9: Substitute the values of f(x) at different points into the formula and
calculate g(2 + h).
Step 10: Finally, find g(2) g(2+h)g(2)
husing the calculated values of g(2)
and g(2 + h).
Question 23
Question
Let f(x) = ex2. Calculate an approximation for f′′(0) using the centered
difference formula with h= 0.1 and an approximation for R1
0ex2dx using the
trapezoidal rule with n= 4.
24
Solution
To approximate f′′(0), we will use the centered difference formula:
f′′(0) f(h)2f(0) + f(h)
h2
where h= 0.1.
Step 1: Calculate f(0.1), f(0), and f(0.1).
f(0.1) = e(0.1)2=e0.01
f(0) = e0= 1
f(0.1) = e(0.1)2=e0.01
Step 2: Substitute the values into the centered difference formula.
f′′(0) e0.01 2(1) + e0.01
0.12
Step 3: Simplify the expression.
f′′(0) e0.01 2 + e0.01
0.01
Now, to approximate R1
0ex2dx using the trapezoidal rule with n= 4, we
have:
Zb
a
f(x)dx h
2(f(x0)+2f(x1)+2f(x2)+2f(x3) + f(x4))
where h=ba
n.
Step 4: Calculate hand determine the values of f(xi).
h=10
4= 0.25
f(x0) = e(0)2= 1
f(x1) = e(0.25)2
f(x2) = e(0.5)2
f(x3) = e(0.75)2
f(x4) = e(1)2=e1
Step 5: Substitute the values into the trapezoidal rule formula.
Z1
0
ex2dx 0.25
21+2f(x1)+2f(x2)+2f(x3) + e1
Step 6: Simplify the expression to find an approximation for the integral.
25
Question 24
Question
Let f(x) = exsin(x).
(a) Find the first derivative of f(x) using the central difference method with
a step size of h= 0.1 at x= 0.5.
(b) Estimate R1
0exsin(x)dx using the trapezoidal rule with n= 4 subinter-
vals.
Solution
(a) To find the first derivative of f(x) at x= 0.5 using the central difference
method with a step size of h= 0.1, we can use the formula:
f(x)f(x+h)f(xh)
2h
Step 1: Calculate f(0.5 + h) and f(0.5h):
f(0.5 + h) = e0.5+0.1sin(0.5+0.1) = e0.6sin(0.6) 0.888
f(0.5h) = e0.50.1sin(0.50.1) = e0.4sin(0.4) 0.233
Step 2: Calculate the derivative at x= 0.5:
f(0.5) 0.888 0.233
2(0.1) =0.655
0.2= 3.275
Therefore, the approximate value of f(0.5) is 3.275.
(b) To estimate R1
0exsin(x)dx using the trapezoidal rule with n= 4 subin-
tervals, we use the formula:
Zb
a
f(x)dx h
2"f(a)+2 n1
X
i=1
f(a+ih)!+f(b)#
where a= 0, b= 1, h=ba
n=1
4= 0.25.
Step 1: Calculate the values of f(x) at the endpoints and interior points:
f(0) = e0sin(0) = 0
f(0.25) = e0.25 sin(0.25) 0.292
f(0.5) = e0.5sin(0.5) 0.420
f(0.75) = e0.75 sin(0.75) 0.565
f(1) = e1sin(1) 1.208
26
Step 2: Apply the trapezoidal rule formula to estimate the integral:
Z1
0
exsin(x)dx 0.25
2[0 + 2(0 + 0.292 + 0.420 + 0.565) + 1.208]
= 0.125 ·2(1.277)
= 0.31925
Therefore, the estimate of R1
0exsin(x)dx using the trapezoidal rule with
n= 4 subintervals is 0.31925.
Question 25
Question
Given the function f(x) = excos(x), approximate the value of f′′(π
2) using a
three-point centered difference formula with step size h=π
4.
Solution
Step 1: Find f′′(x)
f(x) = excos(x)
f(x) = excos(x)exsin(x)
f′′(x)=2excos(x)
Step 2: Apply the three-point centered difference formula The three-point
centered difference formula for the second derivative is given by:
f′′(x)f(x+h)2f(x) + f(xh)
h2
Step 3: Calculate f′′(π
2) Using h=π
4, we have:
f′′(π
2)f(π
2+π
4)2f(π
2) + f(π
2π
4)
(π
4)2
f′′(π
2)f(3π
4)2f(π
2) + f(π
4)
(π
4)2
f′′(π
2)e3π
4cos3π
42eπ
2cosπ
2+eπ
4cosπ
4
(π
4)2
f′′(π
2)e3π
4·(2
2)2eπ
2·0 + eπ
4·2
2
(π
4)2
f′′(π
2)2
2e3π
4+2
2eπ
4
(π
4)2
27
f′′(π
2)2
2eπ
4+2 +2
2eπ
4
(π
4)2
f′′(π
2)2
2eπ
4+2
2eπ
4
(π
4)2
f′′(π
2)0
Question 26
Question
Let f(x) = e3xsin(4x).
a) Determine the fourth order forward difference approximation for f(0)
using equally spaced nodes with step size h= 0.2.
b) Estimate the value of R1.2
0e3xsin(4x)dx using Simpson’s Rule with n= 4
subintervals.
Solution
a) To approximate the fourth order forward difference for f(0), we first need
to find the necessary derivatives of f(x):
f(x)=3e3xsin(4x)+4e3xcos(4x)
f′′(x)=9e3xsin(4x) + 12e3xcos(4x)
f′′′(x) = 27e3xsin(4x)48e3xcos(4x)
Now, we can use these derivatives to find the fourth order forward difference
approximation for f(0):
f(0) 25f(0) + 48f(0.2) 36f(0.4) + 16f(0.6) 3f(0.8)
12h
Substitute f(x) = e3xsin(4x) into the formula above and calculate the numerical
approximation.
b) To estimate the integral using Simpson’s Rule, we divide the interval
[0,1.2] into n= 4 subintervals, where h=ba
n=1.20
4= 0.3. Simpson’s Rule
is given by:
Zb
a
f(x)dx h
3[f(x0)+4f(x1)+2f(x2)+4f(x3)+2f(x4)+···+4f(xn1)+f(xn)]
Substitute f(x) = e3xsin(4x) into the formula above and evaluate the integral
with n= 4 subintervals using the given step size.
28
Question 27
Question
Let f(x) = sinx2and let f(x) and f′′(x) denote the first and second deriva-
tives of frespectively. Consider the integral R1
0f′′(x)dx. Approximate this
integral using the composite Simpson’s rule with n= 4 subintervals.
Solution
Step 1: First, we need to find an expression for f′′(x). Given that f(x) =
sinx2, we have:
f(x)=2xcosx2
f′′(x) = 2 cosx24x2sinx2
Step 2: Next, we need to find the composite Simpson’s rule formula. Given
n= 4 subintervals on [0,1], the composite Simpson’s rule is given by:
Z1
0
f′′(x)dx 1
3h[f′′(x0)+4f′′(x1)+2f′′(x2)+4f′′(x3) + f′′(x4)]
where his the width of each subinterval, given by h=10
4=1
4.
Step 3: Substitute the values of f′′(xi) into the composite Simpson’s rule
formula. We have the following values for f′′(xi):
f′′(0) = 2 cos(0) 4(0)2sin(0) = 2
f′′(1
4) = 2 cos1
1641
42
sin1
16
f′′(1
2) = 2 cos1
441
22
sin1
4
f′′(3
4) = 2 cos9
1643
42
sin9
16
f′′(1) = 2 cos(1) 4(1)2sin(1)
Step 4: Now, substitute these values into the composite Simpson’s rule for-
mula and evaluate the integral. Calculating the numerical integral:
Z1
0
f′′(x)dx 1
3·1
4
[2 + 4f′′(1
4)+2f′′(1
2)+4f′′(3
4) + f′′(1)]
Question 28
Question
Let f(x) = x32x2+ 3x4 be a function. Find the value of the integral
R3
1f(x)dx using the Trapezoidal Rule with n= 4 subintervals.
29
Solution
Step 1: Determine the width of each subinterval. Let xbe the width of each
subinterval. In this case, since we have 4 subintervals in the interval [1,3], we
have x=31
4= 0.5.
Step 2: Create a table of values. We need to evaluate f(x) at the endpoints
and interior points of the subintervals. Below is the table of values:
x f(x)
12
1.52.375
24
2.57.375
310
Step 3: Apply the Trapezoidal Rule formula. The Trapezoidal Rule formula
for numerical integration is:
Zb
a
f(x)dx x
2[f(x0)+2f(x1)+2f(x2)+2f(x3) + f(x4)]
Substitute the values into the formula:
Z3
1
f(x)dx 0.5 [(2) + 2(2.375) + 2(4) + 2(7.375) + (10)]
Z3
1
f(x)dx 0.5[24.75 814.75 10]
Z3
1
f(x)dx 0.5(39.5) = 19.75
Therefore, the value of the integral R3
1f(x)dx using the Trapezoidal Rule
with 4 subintervals is 19.75.
Question 29
Question
Find the numerical approximation of the integral R1
0exsin(x)dx using the trape-
zoidal rule with n= 4 subintervals.
Solution
Step 1: First, we need to calculate the step size, h, using the formula h=ba
n,
where a= 0, b= 1, and n= 4.
Step 1: h=10
4=1
4= 0.25
30
Step 2: Next, we compute the values of the function at each of the subinterval
endpoints: x0= 0, x1= 0.25, x2= 0.5, x3= 0.75, and x4= 1.
y0=e0sin(0) = 0
y1=e0.25 sin(0.25) 0.2834
y2=e0.5sin(0.5) 0.8118
y3=e0.75 sin(0.75) 1.3782
y4=e1sin(1) 1.0672
Step 3: Apply the trapezoidal rule formula Rb
af(x)dx hy0
2+y1+y2+y3+y4
2.Step 3: R1
0exsin(x)dx
0.25 0
2+ 0.2834 + 0.8118 + 1.3782 + 1.0672
2
Step 3: Z1
0
exsin(x)dx 0.25(0.1417 + 0.8118 + 1.3782 + 0.5336)
Step 3: Z1
0
exsin(x)dx 0.25(2.8653)
Step 3: Z1
0
exsin(x)dx 0.716325
Therefore, the numerical approximation of the integral R1
0exsin(x)dx using
the trapezoidal rule with n= 4 subintervals is approximately 0.716325.
Question 30
Question
Let f(x) = sin(x) and g(x) = Rx
0f(t)dt. Find g(x) using numerical differentia-
tion.
Solution
Given f(x) = sin(x) and g(x) = Rx
0f(t)dt, we want to find g(x).
Step 1: Use numerical differentiation formula:
g(x)g(x+h)g(x)
h
where his the step size.
Step 2: Express g(x) in terms of f(x):
g(x) = Zx
0
sin(t)dt
31
Step 3: Let’s find an approximation for g(x) using h= 0.01.
g(x)g(x+ 0.01) g(x)
0.01
Step 4: Calculate g(x) and g(x+ 0.01):
g(x) = Zx
0
sin(t)dt =cos(0) + cos(x) = 1 cos(x)
g(x+ 0.01) = Zx+0.01
0
sin(t)dt = 1 cos(x+ 0.01)
Step 5: Substitute into the formula:
g(x)1cos(x+ 0.01) (1 cos(x))
0.01
Step 6: Simplify the expression:
g(x)cos(x)cos(x+ 0.01)
0.01
Therefore, the numerical approximation for g(x) is cos(x)cos(x+0.01)
0.01 .
Question 31
Question
Let f(x) = e2xcos(3x). Use a centered difference scheme with a step size of
h= 0.1 to approximate f(0.5) and f′′(0.5). Then, use the trapezoidal rule
with n= 4 to approximate R1
0f(x)dx.
Solution
Step 1: Find the approximations for f(0.5) using a centered difference scheme:
First, we have:
f(x)f(x+h)f(xh)
2h
Plugging in x= 0.5 and h= 0.1, we get:
f(0.5) f(0.5+0.1) f(0.50.1)
2(0.1)
Calculating f(0.6) and f(0.4):
f(0.6) = e2(0.6) cos(3(0.6)) 4.11113
f(0.4) = e2(0.4) cos(3(0.4)) 1.86982
32
Therefore:
f(0.5) 4.11113 1.86982
2(0.1) 2.24131
0.211.20655
Step 2: Find the approximation for f′′(0.5) using a centered difference
scheme:
Second derivative can be approximated as:
f′′(x)f(x+h)2f(x) + f(xh)
h2
Plugging in x= 0.5 and h= 0.1, we get:
f′′(0.5) f(0.5+0.1) 2f(0.5) + f(0.50.1)
0.12
Calculating f(0.6), f(0.5), and f(0.4):
f(0.6) 4.11113
f(0.5) = e2(0.5) cos(3(0.5)) 3.1203
f(0.4) 1.86982
Therefore:
f′′(0.5) 4.11113 2(3.1203) + 1.86982
0.120.860723
0.01 86.0723
Step 3: Use the trapezoidal rule to approximate R1
0f(x)dx:
The trapezoidal rule is given by:
Zb
a
f(x)dx hf(a)
2+f(a+h) + f(a+ 2h) + ... +f(bh) + f(b)
2
Using a= 0, b= 1, h=10
4= 0.25:
Z1
0
f(x)dx 0.25 f(0)
2+f(0.25) + f(0.5) + f(0.75) + f(1)
2
Calculating f(0), f(0.25), f(0.75), and f(1):
f(0) = 1
f(0.25) = e2(0.25) cos(3(0.25)) 1.88812
f(0.75) = e2(0.75) cos(3(0.75)) 4.84031
f(1) = e2(1) cos(3(1)) 9.16867
Therefore:
Z1
0
f(x)dx 0
33
Question 32
Question
Let f(x) = x4+ 2x35x2+ 7x3.
a) Find an approximation to f(2) using the forward difference formula with
step size h= 0.1.
b) Estimate R2
1f(x)dx using the trapezoidal rule with n= 4 subintervals.
Solution
a) To approximate f(2) using the forward difference formula, we use the for-
mula:
f(x)f(x+h)f(x)
h
Step 1: Calculate f(2) and f(2.1).
f(2) = (2)4+ 2(2)35(2)2+ 7(2) 3 = 16 + 16 20 + 14 3 = 23
f(2.1) = (2.1)4+ 2(2.1)35(2.1)2+ 7(2.1) 341.441
Step 2: Substitute the values into the formula to find the approximation to
f(2).
f(2) f(2.1) f(2)
0.1=41.441 23
0.1184.41
Therefore, the approximation to f(2) using the forward difference formula
is approximately 184.41.
b) To estimate R2
1f(x)dx using the trapezoidal rule, we use the formula:
Zb
a
f(x)dx h
2 f(x0)+2
n1
X
i=1
f(xi) + f(xn)!
where h=ba
nand xi=a+ih for i= 0,1, . . . , n.
Step 1: Calculate hand the values of f(x) at each subinterval.
h=21
4= 0.25
f(1) = 14+ 2(1)35(1)2+ 7(1) 3 = 1 + 2 5+73=2
f(1.25) = (1.25)4+ 2(1.25)35(1.25)2+ 7(1.25) 34.42
f(1.5) = 1.54+ 2(1.5)35(1.5)2+ 7(1.5) 3=5.0625 + 13.511.25 + 10.53 = 16.8125
f(1.75) = (1.75)4+ 2(1.75)35(1.75)2+ 7(1.75) 339.21
f(2) = 24+ 2(2)35(2)2+ 7(2) 3 = 16 + 16 20 + 14 3 = 23
34
Step 2: Substitute the values into the trapezoidal rule formula to estimate
the integral.
Z2
1
f(x)dx 0.25
2(2 + 2(4.42 + 16.8125 + 39.21) + 23) 21.758
Therefore, the estimate of R2
1f(x)dx using the trapezoidal rule with 4 subin-
tervals is approximately 21.758.
Question 33
Question
Let f(x) = sinx2and f(x) be the derivative of f(x). Consider the following
numerical differentiation and integration methods:
Numerical differentiation:
f(x)f(x+h)f(x)
h
Numerical integration:
Z1
0
f(x)dx 1
6f(0) + 4f1
2+f(1)
Calculate the numerical derivative and the numerical integral of f(x) us-
ing the given methods. Verify the results by evaluating f(x) and R1
0f(x)dx
analytically.
Solution
We will first calculate the numerical derivative f(x) using the numerical differ-
entiation formula:
Step 1: Substitute the function f(x) = sinx2into the numerical differen-
tiation formula:
f(x)f(x+h)f(x)
h
f(x)sin(x+h)2sinx2
h
Step 2: Expand sin(x+h)2using the formula sin(a+b) = sin(a) cos(b)+
cos(a) sin(b):
sin(x+h)2= sinx2+ 2xh +h2= sinx2cos(2xh) + cosx2sin(2xh)
Step 3: Plug the expansion into the numerical differentiation formula:
f(x)sinx2cos(2xh) + cosx2sin(2xh)sinx2
h
35
Step 4: Simplify and take the limit as happroaches 0 to find f(x) analyt-
ically.
Now, we will calculate the numerical integral of f(x) using the given numer-
ical integration formula:
Step 5: Substitute the function f(x) = sinx2into the numerical integra-
tion formula:
Z1
0
f(x)dx 1
6f(0) + 4f1
2+f(1)
Step 6: Evaluate f(0), f1
2, and f(1):
f(0) = sin(0) = 0
f1
2= sin 1
4
f(1) = sin(1)
Step 7: Substitute the values into the numerical integration formula and
simplify to find the numerical integral of f(x).
By comparing the numerical results with the analytical results of f(x) and
R1
0f(x)dx, we can verify the correctness of our calculations.
Question 34
Question
Find the numerical approximation of the derivative of f(x) = e2xsin(x) at
x=π
4using the five-point midpoint formula. Then, use the trapezoidal rule to
approximate the integral of f(x) from 0 to π
2using 4 subintervals.
Solution
Let’s first find the numerical approximation of the derivative of f(x) = e2xsin(x)
at x=π
4using the five-point midpoint formula:
Step 1: Calculate the step size hThe five-point midpoint formula re-
quires equally spaced points around the point at which we are approximating
the derivative. Therefore, let’s choose h=π
8.
Step 2: Compute the derivative of f(x)at x=π4 Using the five-point
midpoint formula:
f(π
4)f(π
4+ 2h)+8f(π
4+h)8f(π
4h) + f(π
42h)
12h
Step 3: Evaluate the derivative Substitute h=π
8and calculate:
f(π
4)f(3π
4)+8f(5π
8)8f(3π
8) + f(π
4)
3π
4
36
Next, let’s use the trapezoidal rule to approximate the integral of f(x) =
e2xsin(x) from 0 to π
2using 4 subintervals:
Step 4: Calculate the interval width hThe trapezoidal rule uses the
formula:
Area h f(x0)
2+
n1
X
i=1
f(xi) + f(xn)
2!
where h=ba
n.
For this case, a= 0, b=π
2, and n= 4 which means h=
π
20
4=π
8.
Step 5: Apply the trapezoidal rule Substitute the values into the for-
mula and calculate the approximate integral using 4 subintervals.
Question 35
Question
Consider the function f(x) = ex2.
(a) Find the second derivative of f(x).
(b) Use numerical differentiation to estimate the value of f′′(1) with a step
size of h= 0.1.
(c) Use numerical integration with the trapezoidal rule to find R1
0f(x)dx
with n= 4 subintervals.
Solution
(a) To find the second derivative of f(x) = ex2, we first need to find the first
derivative, then differentiate again.
Step 1: Find the first derivative of f(x)
f(x) = d
dxex2= 2xex2
Step 2: Find the second derivative of f(x)
f′′(x) = d
dx(2xex2)=2ex2+ 4x2ex2= (2 + 4x2)ex2
(b) Now, to estimate f′′(1) using numerical differentiation with a step size
of h= 0.1, we use the central difference formula:
f′′(1) f(1 + h)2f(1) + f(1 h)
h2
37
Step 1: Substitute into the formula
f′′(1) f(1 + 0.1) 2f(1) + f(1 0.1)
0.12
=e(1+0.1)22e12+e(10.1)2
0.01
=e1.01 2e+e0.81
0.01
(c) To find R1
0f(x)dx using the trapezoidal rule with n= 4 subintervals, we
have:
Z1
0
f(x)dx h
2"f(x0)+2
n1
X
i=1
f(xi) + f(xn)#
Step 1: Calculate hand the values of xi
h=10
4= 0.25
The xivalues are: x0= 0, x1= 0.25, x2= 0.5, x3= 0.75, x4= 1
Step 2: Substitute into the formula
Z1
0
f(x)dx 0.25
2[f(0) + 2f(0.25) + 2f(0.5) + 2f(0.75) + f(1)]
=0.25
2he0+ 2e0.252+ 2e0.52+ 2e0.752+e12i
38
Students also viewed