0% found this document useful (0 votes)
99 views4 pages

F (X) Cos (X) + 2 Sin (X) + X: CPE 202 - Numerical Methods

The document describes using the secant method to find the roots of two functions. For the first function f(x) = cos(x) + 2sin(x) + x^2, the secant method converges after 6 iterations to a root of -0.6592 within an absolute error of 0.0001. For the second function f(x) = e^x cos(x) - xsin(x) within the interval [0,3], the secant method converges after 7 iterations to a root of 1.2254 within an absolute error of 0.0001.

Uploaded by

tae hoon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views4 pages

F (X) Cos (X) + 2 Sin (X) + X: CPE 202 - Numerical Methods

The document describes using the secant method to find the roots of two functions. For the first function f(x) = cos(x) + 2sin(x) + x^2, the secant method converges after 6 iterations to a root of -0.6592 within an absolute error of 0.0001. For the second function f(x) = e^x cos(x) - xsin(x) within the interval [0,3], the secant method converges after 7 iterations to a root of 1.2254 within an absolute error of 0.0001.

Uploaded by

tae hoon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Ordanel, Mary Eden L.

CPE 202 – Numerical Methods

Exercises 1

1. Find a root of the function f(x) = cos(x) + 2 sin(x) + x2 using the Secant Method. Use x0 = 0
and x1 = -0.1 as our initial approximations. Terminate the process if the absolute error Ea ≤
0.0001 and tabulate the results.

f(x) = cos(x) + 2 sin(x) + x2

X0 X1
Initial approximations 0 -0.1
f(x) 1 0.8053

1st Iteration:
X0 = 0
X1 = -0.1
(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
(−0.1−0)
X2 = -0.1- 0.8053· = -0.5136
0.8053−1

2nd Iteration:
X0 = -0.1 ; f(-0.1)=0.8053
X1 = -0.5136 ; f(-0.5136) = cos(-0.5136) + 2 sin(-0.5136) + -0.5136 2 = 0.1521

(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
(−0.5136−(−0.1 ) )
X2 = -0.5136 - 0.1521· = -0.6099
0.1521−0.8053

3rd Iteration:
X0 = -0.5136 ; f(-0.1)= 0.1521
X1 = -0.6099 ; f(-0.6099) = cos(-0.6099) + 2 sin(-0.6099) + -0.6099 2 = 0.0461
(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
X2 = -0.6099 - 0.0461 ·¿ ¿ = -0.6519

4th Iteration:
X0 = -0.6099 ; f(-0.1)= 0.0461
X1 = -0.6519 ; f(-0.6519) = cos(-0.6519) + 2 sin(-0.6519) + -0.6519 2 = 0.0065
(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
X2 = -0.6519 – 0.0065 ·¿ ¿ = -0.6588

5th Iteration:
X0 = -0.6519 ; f(-0.1)= 0.0065
X1 = -0.6588 ; f(-0.6588) = cos(-0.6588) + 2 sin(-0.6588) + -0.6588 2 = 0.0004

(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
X2 = -0.6588 – 0.0004 ·¿ ¿ = -0.6593

6th Iteration:
X0 = -0.6588 ; f(-0.1)= 0.0004
X1 = -0.6593 ; f(-0.6593) = cos(-0.6593) + 2 sin(-0.6593) + -0.6593 2 = -0.00003

(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
X2 = -0.6593 –(-0.00003) ·¿ ¿ = -0.6592 is the root
Ea|-0.6592-(-0.6593)|=0.0001

2. Find the root of the function f(x) = eX cos x – x sin x using Secant Method. Assume that the
function has one root within the interval [0,3]. Terminate the process if the absolute error
Ea ≤ 0.0001 and tabulate the results.
f(x) = eX cos x – x sin x

Interval 0 1 2 3
f(x) 1 0.6272 -4.8935 -20.3079

1st Iteration:
X0 = 0
X1 = 1
(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
(1−0)
X2 = 1- 0.6272· = 2.6824
0.6272−1

2nd Iteration:
X0 = 1
X1 = 2.6824 ; f(x) = e2.6824 cos (2.6824)– 2.6824 sin (2.6824) = -14.2946
(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
(2.6824−1)
X2 = 2.6824 - (-14.2946)· = 1.0707
−14.2946−0.6272

3rd Iteration:
X0 = 2.6824
X1 = 1.0707 ; f(x) = e1.0707 cos (1.0707)– 1.0707 sin (1.0707) = 0.4594

(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
(1.0707−2.6824)
X2 = 1.0707 - 0.4594 · = 1.1209
0.4594−(−14.2946)

4th Iteration:
X0 = 1.0707
X1 = 1.1209 ; f(x) = e1.1209 cos (1.1209)– 1.1209 sin (1.1209) = 0.3247

(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
(1.1209−1.0707)
X2 = 1.1209 – 0.3247 · = 1.2419
0.3247−0.4594

5th Iteration:
X0 = 1.1209
X1 = 1.2419 ; f(x) = e1.2419 cos (1.2419)– 1.2419 sin (1.2419) = -0.0571

(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
(1.2419−1.1209)
X2 = 1.2419 – (-0.0571) · = 1.2238
−0.0571−0.3247

6th Iteration:
X0 = 1.2419
X1 = 1.2238 ; f(x) = e1.2238 cos (1.2238)– 1.2238 sin (1.2238) = 0.0054

(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
(1.2238−1.2419)
X2 = 1.2238 – 0.0054 · = 1.2253
0.0054−(−0.0571)
7th Iteration:
X0 = 1.2238
X1 = 1.2253 ; f(x) = e1.2253 cos (1.2253)– 1.2253 sin (1.2253) = 0.0003

(X 1−X 0)
X2 = X1- f(X1)·
f ( x 1 )−f ( x 0)
(1.2253−1.2238)
X2 = 1.2253 – 0.0003 · = 1.2254 is the root for interval 0 and 1
0.0003−0.0054
Ea|1.2254-1.2253|=0.0001

You might also like