array=input('Specify the coefficients of the quadratic as a row array "[a,b,c]":');
a=array(1);
b=array(2);
c=array(3);
if (a==0) && (b==0)
fprintf('The equation is degenerate');
end
if (a==0) && (b~=0)
fprintf('There is a single root at %g.\n', -c/b);
end
if (a~=0) && (c==0)
fprintf('There are two real roots at 0 and %g.\n', -b/a);
end
if (a~=0) && (c~=0)
root1=((-b+sqrt(b*b-4*a*c))/(2*a));
root2=((-b-sqrt(b*b-4*a*c))/(2*a));
if isreal(root1)
fprintf('There are two real roots at %g and %g.\n.', root1, root2);
else
fprintf('The roots are complex:\n');
fprintf(' ');
disp(root1);
fprintf(' and ');
disp(root2);
end
end
You can solve a quadratic equation in MATLAB using the quadratic formula. Here is an example code snippet:
a = 1; b = 5; c = 6;
delta = b^2 - 4ac;
if delta > 0 x1 = (-b + sqrt(delta))/(2a); x2 = (-b - sqrt(delta))/(2a); disp(['The solutions are: x1 = ', num2str(x1), ', x2 = ', num2str(x2)]); elseif delta == 0 x = -b/(2*a); disp(['The solution is: x = ', num2str(x)]); else disp('No real solutions'); end
computer scince
ax2 + bx + c
Write the quadratic equation in the form ax2 + bx + c = 0 The roots are equal if and only if b2 - 4ac = 0. The expression, b2-4ac is called the [quadratic] discriminant.
First, write the equation in standard form, i.e., put zero on the right. Then, depending on the case, you may have the following options:Factor the polynomialComplete the squareUse the quadratic formula
Just write the equation as: (x - 11)(x - 3) = 0 and convert it to any form you like.
Write an algorithm to find the root of quadratic equation
The easiest way to write a generic algorithm is to simply use the quadratic formula. If it is a computer program, ask the user for the coefficients a, b, and c of the generic equation ax2 + bx + c = 0, then just replace them in the quadratic formula.
readuse the answer
2000X=Y2KoverZzz?
Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.
Write the quadratic equation in the form ax2 + bx + c = 0 then the roots (solutions) of the equation are: [-b ± √(b2 - 4*a*c)]/(2*a)
computer scince
ax2 + bx + c
Write the quadratic equation in the form ax2 + bx + c = 0 The roots are equal if and only if b2 - 4ac = 0. The expression, b2-4ac is called the [quadratic] discriminant.
dejene
Matlab is a scripting and mathematical language processor for working with mathematical equations. C is a structured programming language for writing programs. Those programs can contain mathematical equations, but they won't be in quite the same format that you're used to from math class. Matlab will solve and equation for you. C will allow you to write a program that solves the equation. C++ is an object-oriented version of C. matlab and simulink let us design,simulate,implement & test a variety of time varying system
First, write the equation in standard form, i.e., put zero on the right. Then, depending on the case, you may have the following options:Factor the polynomialComplete the squareUse the quadratic formula