The document presents a MATLAB program that uses the Newton-Raphson method to solve algebraic and transcendental equations. It prompts the user for a function, the desired number of decimal places, and an initial approximation, then iteratively computes the root until the error is within a specified tolerance. An example input and output demonstrate the program's functionality, showing the root of the equation x^3-4*x-9 as approximately 2.7065 after 10 iterations.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views
Program 6b
The document presents a MATLAB program that uses the Newton-Raphson method to solve algebraic and transcendental equations. It prompts the user for a function, the desired number of decimal places, and an initial approximation, then iteratively computes the root until the error is within a specified tolerance. An example input and output demonstrate the program's functionality, showing the root of the equation x^3-4*x-9 as approximately 2.7065 after 10 iterations.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
PROGRAM 6B
%% solution of algebraic and transdental equation by nwewton raphson
method clc; close all; clear all; syms x; f = input('enter the function:\n'); g=diff(f); n=input('enter the number of decimal places:'); epsilon = 5*10^-(n+1) x0 = input('enter the initial approximation:'); for i=1:100 f0 = vpa(subs(f,x,x0)); f0_der=vpa(subs(g,x,x0)); y=x0-f0/f0_der; err=abs(y-x0) if err<epsilon break end x0=y; end y = y-rem(y,10^-n); fprintf("the root is :%f\n",y); fprintf("no of iteratives : %d\n",i);
INPUT :
enter the function:
x^3-4*x-9 enter the number of decimal places: 4 enter the initial approximation: 0