Question

Solve the following equations graphically and numerically using roots function on matlab a) x ^ 5...

Solve the following equations graphically and numerically using roots function on matlab

a) x ^ 5 - 3x ^ 3 + 2x ^ 2 - 1 = 0
b) exp(exp(-x)) -5 x^2=0

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

clc
clear
close all

f1 = @(x) x.^5 - 3.*x.^3 + 2.*x.^2 - 1;
f2 = @(x) exp(exp(-x)) - 5.*x.^2;

%% numerical method with roots() function
% on f1
c = [1 0 -3 2 0 -1]; %coefficients
r = roots(c); % all complex and real roots

% getting real roots for f1
j=1;
for i=1:numel(r)
if imag(r(i))==0
real_roots(j) = real(r(i));
j = j+1;
end
end

roots_f1 = real_roots
%% f2
x2 = linspace(-2,1,100);
ff2 = f2(x2);
pos = find(ff2>=0);
neg = find(ff2<=0);
root_id_f2 = ceil((pos(end)+neg(1))/2);
roots_f2 = x2(root_id_f2)

%% graphical method

% with f1
figure
x1 = linspace(-2,2,100);
plot(x1,f1(x1)) % plot f1(x)
hold on
plot(roots_f1,f1(roots_f1),'o r') % show roots
xlabel('x')
ylabel('f(x)')
legend('f(x)','roots','location','best')
title('f(x) = x^5 - 3*x^3 + 2*x^2 - 1')
grid on

% with f2
figure
plot(x2,f2(x2)) % plot f2(x)
hold on
plot(roots_f2,f1(roots_f2),'o r') % show roots
xlabel('x')
ylabel('f(x)')
legend('f(x)','roots','location','best')
title('f(x) = exp(exp(-x)) - 5*x^2')
grid on

%-----------------------------------------------------------------------

----------------------------------------------------------------------------------------


------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,

IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~

Add a comment
Know the answer?
Add Answer to:
Solve the following equations graphically and numerically using roots function on matlab a) x ^ 5...
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
  • 1a): Find the roots of the following polynomial equations using matlab: f(x) = x^5 − 9x^4...

    1a): Find the roots of the following polynomial equations using matlab: f(x) = x^5 − 9x^4 + 31x^3 − 51x^2 + 40x − 12 f(x) = x^5 − 11x^4 + 47x^3 − 97x^2 + 96x − 36 b): Find the coefficients of two polynomial equations in matlab given the following sets of roots: r1 = [ 100 25 50 5 10 ]    r2 = [ 11 22 33 0 55 ] c): Create a figure with four subplots, each showing...

  • Only the matlab nlinear equations x 0.75 Determine the roots of these equations using: a) The...

    Only the matlab nlinear equations x 0.75 Determine the roots of these equations using: a) The Fixed-point iteration method. b) The Newton Raphson method. Employ initial guesses of x y 1.2 and perform the iterations until E.<10%. Note: You can use to solve the problems, but you should sol at least two full iterations manually. AB bl Du Thursd 30/3/ 1. For the displacement in Q3 y 10 e cos at 0 St S 4. a) Plot the displacement y...

  • Exercise 3.3: Nonlinear equations 1. Find the zeros of the following functions graphically: b) g\left(x\right)=2x^2-4x-16 4...

    Exercise 3.3: Nonlinear equations 1. Find the zeros of the following functions graphically: b) g\left(x\right)=2x^2-4x-16 4 c) For the following function determine if x = 1 is a root: 5. Find the rational roots, if any, of the following: b) 8x^3+6x^2-3x-1=0 6. Find the equilibrium solution for each of the following models: a) Q_d=Q_s Q_d=3-P^2 Q_s=6P-4

  • 1.    Solve the following simultaneous equations (i) graphically and (ii) using the elimination method.       (a)   ...

    1.    Solve the following simultaneous equations (i) graphically and (ii) using the elimination method.       (a)    2x + 3y = 12.5       (y on the vertical axis)       (b)     4P – 3Q = 3      (p on the vertical axis)                    -x +2y =6                                                                            P +2Q = 20              2.    Suppose the demand and supply of a good are given as             P = 80 – 2Q    and P=20 + 4Q (a) Calculate the equilibrium price and quantity, algebraically. (b)   Suppose a per...

  • Using MATLAB Write a MATLA code to solve the following system of linear equations: -x +...

    Using MATLAB Write a MATLA code to solve the following system of linear equations: -x + y + 4z = -2 20y + 3x - 1z = 3 3z + 2y + 6z - 3 = 0

  • Solve these nonlinear equations with fsolve function in Matlab. Verify your result with ezplot function. f(x7,x)=...

    Solve these nonlinear equations with fsolve function in Matlab. Verify your result with ezplot function. f(x7,x)= x; - 4x} - x,x2 fz(x, , x)= 2x, – x3 – 3x,X,

  • How to write in matlab program ? (1) Reduce the following system of equations to one equation in ...

    How to write in matlab program ? (1) Reduce the following system of equations to one equation in terms of x and solve the resulting equation numerically using Newton-Raphson method. ex/10 – y = 0 and 2logey – cosx = 2 (2) Solve the above equations numerically using system of equations, first by plotting the graph to obtain an initial approximation of the roots (such as x = 1 with y = 1 or other combinations), then produce the results...

  • 20: Solve the system of equations using substitution method. 2x+5y=26 X+ y= 10 21: Solve the...

    20: Solve the system of equations using substitution method. 2x+5y=26 X+ y= 10 21: Solve the following equation. x-x1/2-6= 0 22: Solve the following system of equations, using elimination method. 2x+3y = 5 5x- y = 4 23: Solve the system of nonlinear equations. Any Method. Y?=x2-9 2y= x-3 24: Convert the log into exponent form. Ln (3x-5)2= 16 25: f(x)= 1/x in words explain the transformation of the following functions. a. g(x) = 1/ (x-3) +5 b. h(x)= -1/(x+2)...

  • QUESTION 5 please. 4. MATLAB can solve second order equations numerically, but it needs to convert...

    QUESTION 5 please. 4. MATLAB can solve second order equations numerically, but it needs to convert it to a sys- tem first. We haven't covered systems yet, but we can make use of them (entirely in MAT- LAB) to solve this problem. The help page https://www.mathworks.com/help/symbolic/ solve-differential-equation-numerically-1.html shows how to do this. Follow those steps to get the solution to day +9y = cos(3) dt2 y(0) = 0 v(0) = 0 Plot this and your solution from the previous part...

  • 4. MATLAB can solve second order equations numerically, but it needs to convert it to a...

    4. MATLAB can solve second order equations numerically, but it needs to convert it to a sys- tem first. We haven't covered systems yet, but we can make use of them (entirely in MAT- LAB) to solve this problem. The help page https://www.mathworks.com/help/symbolic/ solve-differential-equation-numerically-1.html shows how to do this. Follow those steps to get the solution to day +9y = cos(3) dt2 y(0) = 0 v(0) = 0 Plot this and your solution from the previous part on the same...

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