Skip to content

Commit

Permalink
Merge pull request TheAlgorithms#68 from Abhishek-photon/patch-1
Browse files Browse the repository at this point in the history
Create shreeDharacharyaFormula.m
  • Loading branch information
cozek authored Oct 14, 2020
2 parents e9530c9 + ae07f87 commit 5122cae
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions algorithms/maths/shreeDharacharyaFormula.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%% Shree Dharacharya Formula
% aX^2 + bX + c = 0
function [x1,x2] = shreeDharacharyaFormula(a,b,c)
% calculates the roots of a quadratic equation.
d = b^2 - 4*a*c;

if d < 0
disp('Imaginary roots');

else
x1 = (-b + d^(1/2))/(2*a);

x2 = (-b - d^(1/2))/(2*a);
end

end

0 comments on commit 5122cae

Please sign in to comment.