Skip to content

Instantly share code, notes, and snippets.

@jcrvz
Created July 30, 2020 18:04
Show Gist options
  • Save jcrvz/1a684a49927637635065bd260a8eba2f to your computer and use it in GitHub Desktop.
Save jcrvz/1a684a49927637635065bd260a8eba2f to your computer and use it in GitHub Desktop.
Loh's method for quadratic formula
% https://www.poshenloh.com/quadratic/
function rts = altRoots(p2)
if p2(1) ~= 1
p2 = p2 / p2(1);
end
average_value = p2(2) / 2;
product_value = p2(3);
distance = sqrt(average_value^2 - product_value);
rts = -average_value + distance * [-1; 1];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment