0% found this document useful (0 votes)
15 views16 pages

Bhaisaab

Neom file

Uploaded by

b22083995
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)
15 views16 pages

Bhaisaab

Neom file

Uploaded by

b22083995
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/ 16

NEOM LAB FILE

Harsh Sharma
23/EE/097

Jai Kumar
23/EE/111
Experiment: 1
AIM:
To find the root of a polynomial equation using bisection method THEORY:

The bisection method is a simple and effective numerical technique for finding the
roots of a continuous function. It is particularly useful when the function changes
sign over an interval, indicating the presence of a root within that interval. Below
is a detailed theory on the bisection method and how you might implement it in
MATLAB.
Steps of the Bisection Method:

1. Initial Interval Selection: Choose two points a and b such that f(a)⋅f(b)<0.
This indicates that there is at least one root in the interval [a,b] due to the
Intermediate Value Theorem.

2. Compute Midpoint: Calculate the midpoint ccc of the interval [a,b][a,


b][a,b] using:
c=a+b/2

3. Evaluate Function at Midpoint: Compute f(c)

4. Update Interval:
o If f(c)=0, then c is the root, and the method terminates. o If
f(a)⋅f(c)<0, then the root lies in the interval [a,c] Update b to c.
o If f(b)⋅f(c)<0, then the root lies in the interval [c,b] Update a to c.

5. Repeat: Repeat steps 2-4 until the interval [a,b] is sufficiently small,
meaning the difference ∣b−a∣ is less than a predefined tolerance ϵ, or the
function value at the midpoint ∣f(c)∣ is less than ϵ.

CODE:
OUTPUT:

The conclusion is 0.6931


EXPERIMENT 2
AIM: To find a root of a polynomial using Regula-Falsi method

THEORY:
The regula-falsi method, also known as the false position method, is a numerical
technique used to find the roots of a continuous function. It is similar to the
bisection method but uses linear interpolation to approximate the root, which can
often converge faster under certain conditions. Below is a detailed explanation of
the regula-falsi method and how you might implement it in MATLAB.
Steps of the Regula-Falsi Method:

1. Initial Interval Selection: Choose two points a and b such that f(a)⋅f(b)<0.
This ensures that a root exists within this interval due to the Intermediate
Value Theorem.

2. Compute Interpolated Root: Calculate the root ccc using linear


interpolation between a and b:
c=b−(f(b)⋅(b−a)/f(b)−f(a))

3. Evaluate Function at Interpolated Root: Compute f(c)

4. Update Interval:
o If f(c)=0, then c is the root, and the method terminates. o If
f(a)⋅f(c)<0, then the root lies in the interval [a,c] Update b to c. o If
f(b)⋅f(c)<0 then the root lies in the interval [c,b]Update a to c.

5. Repeat: Repeat steps 2-4 until the interval [a,b] is sufficiently small,
meaning the difference ∣b−a∣ is less than a predefined tolerance ϵ, or the
function value at the interpolated root ∣f(c)∣ is less than ϵ.

CODE:
OUTPUT:

Conclusion : The final answer we got is 0.6921


Experiment: 3
AIM:
Newton-Raphson method
THEORY:
The Newton-Raphson method is an iterative technique for finding approximate
solutions to equations of the form f(x)=0f(x) = 0f(x)=0, using the formula:

xn+1=xn−(f(xn)/f′(xn) )
It converges rapidly (quadratically) when the initial guess is close to the root.
However, it requires the derivative f′(x)f'(x)f′(x), and poor initial guesses or zero
derivatives can cause failure or divergence. Despite these limitations, the method
is efficient and widely used for solving nonlinear equations.
Steps of the Newton-Raphson Method:

1. Define the function f(x)f(x)f(x) whose root you want to find.

2. Define the derivative f′(x)f'(x)f′(x) of the function.

3. Choose an initial guess x0x_0x0 for the root.

4. Set a tolerance value ϵ\epsilonϵ for convergence (e.g., 10−610^{-6}10−6).

5. Set a maximum number of iterations to avoid infinite loops.

6. Iterate the formula xn+1=xn−(f(xn)/f′(xn) ) until the difference between


successive approximations is smaller than the tolerance or the maximum
iterations are reached.

7. Output the final approximation.

CODE:
OUTPUT:

Conclusion : The result we got is 4.916


Experiment: 4
AIM:
Runge-Kutte (order 2) method
Theory:
The Runge-Kutta method of order 2 (RK2) is a numerical method for solving ordinary differential
equations (ODEs). It improves upon the Euler method by considering two slope estimates: k1 at
the beginning of the interval and k2 at the end, resulting in the formula:

yn+1=yn+1/2(k1+k2)
where k1=h f(tn,yn) and k2=h f(tn+h,yn+k1) provides more accurate results than Euler's method,
with a simple implementation, but is less accurate than higher-order methods like RK4. It strikes
a balance between accuracy and computational cost.
Steps of the Runge-Kutte order 2 Method:

1. Define the differential equation dy/dt=f(t,y) as an anonymous function.


2. Choose the initial condition: Set the initial values for y0.
3. Set the step size h and the range of the independent variable t.
4. Initialize the loop: Iterate over the range of t from t0 to tfinal updating the solution at each
step using the RK2 formula.
5. Compute the two slopes k1 and k2 at each step.
6. Update the solution using yn+1=yn+1/2(k1+k2)
7. Store the values of t and y at each step for later plotting or analysis

CODE:
OUTPUT:

CONCLUSION: The result we got is 4.916


Experiment: 5

AIM:
To find the root of a polynomial equation using Runge-Kutte (order 4) method
THEORY:
The Runge-Kutta 4th order (RK4) method is a numerical technique for solving ordinary
differential equations (ODEs) with high accuracy. It approximates the solution by calculating
intermediate values using weighted averages of function evaluations at different points within
each step. The formula for updating the solution is:

yn+1=yn+1/6(k1+2k2+2k3+k4)

• K1=hf(xn,yn)
• K2=hf(xn+h/2,yn+k1/2)
• K3=hf(xn+h/2,yn+k2/2)
• K4=hf(xn+h,yn+k3)
Steps of the Runge-Kutte order 4 Method: Given
the ordinary differential equation (ODE):
dy/dx=f(x,y)
with initial conditions y(x0)=y0 and a step size h, the RK4 method involves the following steps:

1. Initialize the initial values:

o X0 (initial time) o y0 (initial condition) o h

(step size)

o N (number of steps)

2. Compute the intermediate slopes k1,k2,k3,k4 for each step:

K1=hf(xn,yn)

K2=hf(xn+h/2,yn+k1/2)

K3=hf(xn+h/2,yn+k2/2)

K4=hf(xn+h,yn+k3)
3. Update the solution: yn+1=yn+1/6(k1+2k2+2k3+k4)
4. Update the time:

Xn+1=Xn+h

5. Repeat the process for each step until the desired time is reached.

CODE:
OUTPUT:

CONCLUSION: The result we got is 5.3055


Experiment : 6

AIM:
To find the root of a polynomial equation using Euler’s method
THEORY:
Euler's Method is a simple numerical technique for solving ordinary differential equations (ODEs)
of the form dy/dx = f(x, y) with initial condition y(x0) = y0. The method approximates the solution
by stepping forward in small increments h, using the formula:

Yn+1 = yn + h f(xn, yn)


It updates the solution at each step, incrementing x by h. Although easy to implement and
computationally efficient, Euler’s method is first-order accurate, meaning its error decreases
linearly with step size. It can be inaccurate and unstable for stiff equations or large step sizes.
Steps of the Eulers’s Method:

1. Define the ODE function: Write the differential equation dy/dx = f(x, y) as an anonymous
function in MATLAB.
2. Set initial conditions: Specify the initial values for x0 , y0, the step size h, and the final
value of x (end point).
3. Initialize arrays: Create arrays to store the values of x and y at each step.
4. Apply Euler’s update formula: For each step, update y using the formula: yn+1 = yn + h f(xn,
yn)
where h is the step size and f(xn, yn)is the function evaluated at the current point.
5. Repeat the steps: Loop through the steps until reaching the final xxx-value
CODE:
OUTPUT:

CONCLUSION: The final answer we got is 1.9343


Experiment : 7

AIM:
To study the series RLC circuit on Simulink SIMULINK:
Experiment : 8

AIM:
To study the series RLC circuit on Simulink SIMULINK:

You might also like