# Scilab Program for Newton Raphson Method to Find Roots

## Problem:

Write a Scilab program for Newton Raphson Method.## Algorithm or Solution:

In numerical analysis, Newton's method which is also known as Newton Raphson method is used to find the roots of given function/equation. This method is named after Sir Isaac Newton and Joseph Raphson. Get more information about Derivation of Newton Raphson formula. Here is algorithm or the logical solution of Scilab program for Newton Raphson Method- Start
- Define a function f(x)=0 as required using deff keyword in scilab.
- Define the derivative function f'(x)=0 using deff keyword in scilab.
- If two points are given in which the root lies then calculate the average of both, if they are not given then choose a suitable starting value according to the function.
- Initialize the counter variable i=1.
- Use any loop (for loop, while loop) according to your convenience, if you are using for loop there is no need to initialize 'i' earlier.
- Use the formula of Newton Raphson method inside the loop. We are using x to store the current value as well as next approximation as we are using loop.
- Loop up to desired iterations and stop.
- Print the value of root i.e value of 'x'.
- Stop.

X

to implement scilab program for Newton Raphson method.
_{n+1}=X_{n}-
f(X

_{n}) f'(X_{n})## Scilab Program / Source Code:

Here is the source code of Scilab program for Newton Raphson Method.```
// Scilab code for newton raphson methos to find the roots of given equation
deff('y=f(x)','y=x^4-x-10'); // Defining the function f(x)=0
deff('z=f1(x)','z=4*x^3-1'); // Defining the function f'(x)=0
a=1;b=2;
x=(a+b)/2; // Calculate average if values in between the root lies are given
i=1; // Initialize counter variable i=1
while(i<=15) // Loop up to desired number of iterations
x=(x-(f(x)/f1(x))); // use the Newton Raphson Formula
i=i+1;
[x] // Print value of root every time to see the difference
end;
```