Write A Function That Uses A, B and C As Inputs To...

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Expert Q&A

chegg.com/homework-help/questions-and-answers/write-function-uses-b-c-inputs-characterize-e-non-equal-real-equal-
real-non-equal-complex--q65431335

Question

1. Write a function that uses a, b and c as inputs to characterize


((i.e., non-equal
real, equal real or non-equal complex roots) and
compute the roots of the
quadratic equation.

2. Write an m-file that tells the user if the quadratic equation


ax2 + bx + c = 0 with
input
values of a, b and c has

1) Two real roots with opposite


signs

2) Two complex roots

3) Plot the curve


ax2 + bx + c = 0 over
sufficient intervals (i.e., from 0.9 times of the
smallest root to
1.1 of the largest root ) to illustrate the results obtained in (1)
and (2).

Expert Answer

NOTE:- IN CASE OF ANY QUERY FEEL FREE TO ASK IN COMMENT


ANYTIME.........HAPPY LEARNING AND KEEP CHEGGING.....
MATLAB :

Part-1

% part - (i)
% function
takes 3 arguments a,b,c and return

% two argumnets r1 and r2


% function prints about characterstic of roots


% .^ , .* , ./ is used for element wise operations

function [r1,r2] = characterise(a,b,c)


%% computing value of D

D = b.^2 - 4.*a.*c;

%% computing roots
of equation
r1 = (-b + D.^0.5)./(2.*a);

r2 = (-b - D.^0.5)./(2.*a);

%% printing characterstics
based on D
if D > 0 %% if D is positive


real valued roots");
display("A pair of non-equal
elseif D == 0 % if D is zero

display("A pair of equal real


valued roots");
else % if D is negative or otherwise

display("A pair of non-equal complex


valued roots");
end %% end of if blocks

end % end of function

%% testing of given function


[root1,root2] = characterise(1,0,-1);
display(root1); display(root2);

[root1,root2] = characterise(1,-2,1);
display(root1); display(root2);

[root1,root2] = characterise(1,0,1);
display(root1); display(root2);

--------------I hope my answer met all your requirements......Thank You-----------

Was this answer helpful?

Post a question

Answers from our experts for your tough homework questions


12 questions left - Renews Dec. 28, 2022

Questions viewed by other students

Q:

Write a function that uses a, b and c as inputs to characterize((i.e., non-equal


real, equal real or non-equal complex roots) andcompute the roots of the
quadratic equation. Write an m-file that tells the user if the quadratic
equationax2 + bx + c = 0 with inputvalues of a, b and c has1) Two real roots with
oppositesigns2) Two complex roots3) Plot the curveax2 + bx + c = 0 oversufficient
intervals (i.e., from 0.9 times of the smallest root to1.1 ...

A:

See answer

Q:

Struggling with parts 5 and 6. Please help simplify the BooleanEquation below.

A:

See answer

You might also like