0% found this document useful (0 votes)
11 views5 pages

Numerical Analysis Formatted Guide

The document provides a complete guide for numerical analysis exam preparation, detailing methods such as the Bisection Method, Newton-Raphson method, Trapezoidal Rule, and Euler's method for solving equations and estimating integrals. Each method is accompanied by a Python code implementation using a script named numanal-2.py. The guide emphasizes the iterative and approximation nature of these numerical techniques.

Uploaded by

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

Numerical Analysis Formatted Guide

The document provides a complete guide for numerical analysis exam preparation, detailing methods such as the Bisection Method, Newton-Raphson method, Trapezoidal Rule, and Euler's method for solving equations and estimating integrals. Each method is accompanied by a Python code implementation using a script named numanal-2.py. The guide emphasizes the iterative and approximation nature of these numerical techniques.

Uploaded by

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

Numerical Analysis Exam Preparation - Complete Guide

Question:
Use the Bisection Method to find a root of f(x) = x^3 - 5x + 1.

Answer:

The Bisection Method is a root-finding algorithm that repeatedly divides an interval in half and selects

the subinterval in which the function changes sign.

Solution:
Using numanal-2.py:

```python
def bisection(f, a, b, tol=1e-6):
while abs(b - a) > tol:
mid = (a + b) / 2
if f(mid) == 0:
return mid
elif f(a) * f(mid) < 0:
b = mid
else:
a = mid
return (a + b) / 2
```
Question:
Apply Newton-Raphson method to approximate a root of f(x) = sin(x) - x/2.

Answer:

Newton-Raphson is an iterative method for finding successively better approximations to the roots of a

real-valued function.

Solution:
Using numanal-2.py:

```python
def newton_raphson(f, df, x0, tol=1e-6):
while True:
x1 = x0 - f(x0) / df(x0)
if abs(x1 - x0) < tol:
return x1
x0 = x1
```
Question:
Implement the Trapezoidal Rule to estimate the integral of e^(-x^2) from 0 to 1.

Answer:

The Trapezoidal Rule approximates the integral by summing up the areas of trapezoids under the

curve.

Solution:
Using numanal-2.py:

```python
def trapezoid(f, a, b, n=256):
h = (b - a) / n
I = (f(a) + f(b)) / 2 + sum(f(a + i * h) for i in range(1, n))
return I * h
```
Question:
Solve dy/dx = x^2 - y with Eulers method.

Answer:

Euler's method is a simple numerical approach for solving first-order differential equations.

Solution:
Using numanal-2.py:

```python
def solve_euler(f, a, b, y_a, steps=256):
x, y = a, y_a
h = (b - a) / steps
for _ in range(steps):
y += f(x, y) * h
x += h
return y
```

You might also like