Question

1) (80pts) Consider the following function f(x)--x5-4x4 + 2x3 + x2-3x + 5 Develop a simple program which will give an iterati
0 0
Add a comment Improve this question Transcribed image text
Answer #1


Matlab code for Newton Raphson method clear all close all syms function for which root have to find f(x)--x 5-4*x* 4+2*x* 3+xfunction for which d value have to find symbolic function inputs: x 1st Derivative of this function -5*x4-16#x^3 + 6*x^2 + 2

%%Matlab code for Newton Raphson method
clear all
close all
syms x
% function for which root have to find
f(x)=-x^5-4*x^4+2*x^3+x^2-3*x+5;
fprintf('function for which d value have to find\n')
disp(f)
%1st Derivative of this function
g1(x)=- 5*x^4 - 16*x^3 + 6*x^2 + 2*x - 3;
fprintf('1st Derivative of this function\n')
disp(g1)
max_it=100;         %Maximum number of iterations
xx=0;               %initial guess
fprintf('Newton iteration for initial guess %f\n',xx)
fprintf('\t k\t x\t f(x) \tdf(x)/dx\n')
%Loop for all intial guesses
    n=10^-6; %error limit for close itteration
    for i=1:max_it
        fprintf('\t%d \t%2.5f \t%2.5f \t%2.5f\n',i-1,xx,f(xx),g1(xx))
        x2=double(xx-(f(xx)./g1(xx))); %Newton Raphson Formula
        cc=abs(xx-x2);                 %Error
        xx=x2;
        if cc<=n
            break
        end
    end
    fprintf('\nThe function is f(x)=\n')
    disp(f)
    fprintf('Value of x for the function is %f for total iteration count %d.\n\n',xx,i)
max_it=100;         %Maximum number of iterations
xx=-20;               %initial guess
fprintf('Newton iteration for initial guess %f\n',xx)
fprintf('\t k\t x\t f(x) \tdf(x)/dx\n')
%Loop for all intial guesses
    n=10^-6; %error limit for close itteration
    for i=1:max_it
        fprintf('\t%d \t%2.5f \t%2.5f \t%2.5f\n',i-1,xx,f(xx),g1(xx))
        x2=double(xx-(f(xx)./g1(xx))); %Newton Raphson Formula
        cc=abs(xx-x2);                 %Error
        xx=x2;
        if cc<=n
            break
        end
    end
    fprintf('\nThe function is f(x)=\n')
    disp(f)
    fprintf('Value of x for the function is %f for total iteration count %d.\n\n',xx,i)
  
    %%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
1) (80pts) Consider the following function f(x)--x5-4x4 + 2x3 + x2-3x + 5 Develop a simple program which will give an iterative solution to the problem f(x)=0 by Newton's algorithm. The solut...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT