Question

How can I code this problem in MATLAB: a) Find the approximations to within 10-4 to all real zeros of the following poly...

How can I code this problem in MATLAB:

a) Find the approximations to within 10-4 to all real zeros of the following polynomials using Newton's method.?

f(x)=x3 - 2*x2- 5.

b) Find approximations to within 10-5 to all the zeros of each of the following polynomials by first
finding the real zeros using Newton’s method and then reducing to polynomials of lower degree to
determine any complex zeros.

f(x)=x4 + 5x3 - 9*x2 - 85*x - 136.

1 0
Add a comment Improve this question Transcribed image text
Answer #1


Matlab code for finding roots using Newton methods clear all close all function for which root have to find fun-e (x) the funMatlab function for Newton Method root ] =newton_method(fun,x0,n) function syms x gl (x) diff ( fun, x) хх3x0; Loop for all i

%Matlab code for finding roots using Newton methods
clear all
close all

%function for which root have to find
fun=@(x) x.^3 - 2.*x.^2- 5;
fprintf('For the function f(x)=\n')
disp(fun)
xx=linspace(-2,4);
%initial guess
x0=10;
%error limit
n=10^-4;
[root]=newton_method(fun,x0,n);
fprintf('\tRoot of the function using Newton method is %f.\n',root)


%function for which root have to find
fun=@(x) x.^4 + 5.*x.^3- 9.*x.^2 -85.*x -136;
fprintf('\nFor the function f(x)=\n')
disp(fun)
xx=linspace(-2,4);
%initial guess
x0=10;
%error limit
n=10^-4;
[root1]=newton_method(fun,x0,n);
fprintf('\t1st Root of the function using Newton method is %f.\n',root1)

%initial guess
x0=-10;
%error limit
n=10^-4;
[root2]=newton_method(fun,x0,n);
fprintf('\t2nd Root of the function using Newton method is %f.\n',root2)

fprintf('\tNow complex root occured for the equation is ')
syms x
p = x.^4 + 5.*x.^3- 9.*x.^2 -85.*x -136;
p2 = (x-root1)*(x-root2);

[q, r] = quorem(p, p2);
disp(vpa(q,2))

fprintf('So that the complex roots are \n')
fprintf('\t-2.5 +1.32287565553229i \n\t-2.5 -1.32287565553229i\n\n')


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Matlab function for Newton Method
function [root]=newton_method(fun,x0,n)
syms x
g1(x) =diff(fun,x);   %1st Derivative of this function
xx=x0;            %initial guess]
%Loop for all intial guesses
    maxit=10000;
    for i=1:maxit
        x2=double(xx-(fun(xx)./g1(xx))); %Newton Raphson Formula
        cc=abs(fun(x2));                 %Error
        err(i)=cc;
        xx=x2;
        if cc<=n
            break
        end
      
    end
    root=xx;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
How can I code this problem in MATLAB: a) Find the approximations to within 10-4 to all real zeros of the following poly...
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
  • Please solve it with MATLAB. Many thanks. Use Newton's method to find, within 10-3, the zeros and critical point...

    Please solve it with MATLAB. Many thanks. Use Newton's method to find, within 10-3, the zeros and critical points of the following functions Use this information to sketch the graph of f. 5. a.f(x)x9 12 b. f(x)x-2r -512r-5 Use Newton's method to find, within 10-3, the zeros and critical points of the following functions Use this information to sketch the graph of f. 5. a.f(x)x9 12 b. f(x)x-2r -512r-5

  • Given f (x) = x4 + 5x3 – 24x2, find all real zeros off and determine...

    Given f (x) = x4 + 5x3 – 24x2, find all real zeros off and determine whether the multiplicity of each zero is even or odd. Then determine the maximum number of turning points of the graph off.

  • Find all the zeros of f (x) = x2 +10 cosx by using the fixed-point iteration...

    Find all the zeros of f (x) = x2 +10 cosx by using the fixed-point iteration method for an appropriate iteration function g. Find the zeros accurate to within 10-4.

  • Use the rational zeros theorem to find all the real zeros of the polynomial function. Use...

    Use the rational zeros theorem to find all the real zeros of the polynomial function. Use the zeros to factor f over the real numbers. f(x)=x4 + 2x3-7x2-8x+12 What are the real zeros? Select the correct choice below and, if necessary, fill in the answer box to complete your answer Simplify your answer. Type an exact answer, using radicals as needed. Use integers or fractions for any rational numbers in the expression. Use a comma to separate answers as needed.)...

  • 3. Any polynomial with real coefficients of degree k can be factored com- pletely into first-degree...

    3. Any polynomial with real coefficients of degree k can be factored com- pletely into first-degree binomials which may include complex numbers. That is, for any real ao, Q1, ..., āk ao + a1x + a22² + ... + axxk = C(x – 21)(x – z2....(x – zk) for some real C and 21, 22, ... Zk possibly real or complex. Therefore, up to multiplicity, every polynomial of degree k has exactly k-many roots, includ- ing complex roots. Find all...

  • (1) Use the Bisection method to find solutions accurate to within 10-2 for x3 – 7x2...

    (1) Use the Bisection method to find solutions accurate to within 10-2 for x3 – 7x2 + 14x – 6 = 0 on the interval [3.2, 4]. Using 4-digit rounding arithmatic. (2) Consider the function f(x) = cos X – X. (a). Approximate a root of f(x) using Fixed- point method accurate to within 10-2 . (b). Approximate a root of f(x) using Newton's method accurate to within 10-2. Find the second Taylor polynomial P2(x) for the function f(x) =...

  • Homework 4 - False Position Find the zeros of the function f(x) within the interval (-4,...

    Homework 4 - False Position Find the zeros of the function f(x) within the interval (-4, 6) using the False Position method with f(-4) > 0 what you must know before you start working on the homework: f(-1) <0 f(x) = sin(21(x/5) + exp(x/5) f(+6) > 0 (a) Write a Matlab function that computes the values for f(x) when xis given as an input. (b) Write a Matlab script entitled "myplot.m” that plots the functions f(x) within the interval (-4,...

  • Please answer this MATLAB questions when able. Thanks. 4. Laboratory Problem Description In this laboratory you...

    Please answer this MATLAB questions when able. Thanks. 4. Laboratory Problem Description In this laboratory you are required to Find the solution of the following systems of linear equation: 1) xl + x2 + x3 3 4x1 - x2 x3-2 x1 2x2 x3-2 2) 2 -1 3 A 1 3 -2. B-2 Given the following system 4x1+3x2+7x3- 3 3x1+2x2+1x3 1 2x1+3x2+4x3- 2 Using MATLAB commands solve the following system using Gaussian elimination with partial pivoting. Find P, L, and U...

  • Question 2 (20 Points) (1) Use the Bisection method to find solutions accurate to within 10-2...

    Question 2 (20 Points) (1) Use the Bisection method to find solutions accurate to within 10-2 for x3 - 7x2 + 14x - 6 = 0 on the interval [3.2, 4]. Using 4-digit rounding arithmatic. (2) Consider the function f(x) = cos x - x. (a). Approximate a root of f(x) using Fixed-point method accurate to within 10-2 (b). Approximate a root of f(x) using Newton's method accurate to within 10-2.

  • #6 Write a Matlab program that finds numerically all the roots (or the zeros) of the...

    #6 Write a Matlab program that finds numerically all the roots (or the zeros) of the algebraic equation below in the interval 1.0 <=x<=3.0: sqrt(log(x^2+1))=x^2*sin(e^x)+2 Part a) Prompt the user to enter a positive integer number n, defined the range 2<=n<=15, and then verify if the number entered lies within the specifications. Your program must allow the user to reenter the number without the need to rerun the program. Part b) Create a user-defined function for the bisection method(see details...

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
ADVERTISEMENT