
(FPCore (a b c) :precision binary64 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
def code(a, b, c): return (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
def code(a, b, c): return (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -5.8e-56)
(/ c (- b))
(if (<= b 2.5e+87)
(fma (/ -0.5 a) (sqrt (fma a (* c -4.0) (pow b 2.0))) (* -0.5 (/ b a)))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.8e-56) {
tmp = c / -b;
} else if (b <= 2.5e+87) {
tmp = fma((-0.5 / a), sqrt(fma(a, (c * -4.0), pow(b, 2.0))), (-0.5 * (b / a)));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.8e-56) tmp = Float64(c / Float64(-b)); elseif (b <= 2.5e+87) tmp = fma(Float64(-0.5 / a), sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))), Float64(-0.5 * Float64(b / a))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.8e-56], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 2.5e+87], N[(N[(-0.5 / a), $MachinePrecision] * N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.8 \cdot 10^{-56}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.5}{a}, \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}, -0.5 \cdot \frac{b}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.79999999999999982e-56Initial program 16.3%
div-sub14.9%
sub-neg14.9%
neg-mul-114.9%
*-commutative14.9%
associate-/l*13.7%
distribute-neg-frac13.7%
neg-mul-113.7%
*-commutative13.7%
associate-/l*14.9%
distribute-rgt-out16.3%
associate-/r*16.3%
metadata-eval16.3%
sub-neg16.3%
+-commutative16.3%
Simplified16.3%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
distribute-neg-frac286.2%
Simplified86.2%
if -5.79999999999999982e-56 < b < 2.4999999999999999e87Initial program 79.9%
div-sub79.9%
sub-neg79.9%
neg-mul-179.9%
*-commutative79.9%
associate-/l*79.8%
distribute-neg-frac79.8%
neg-mul-179.8%
*-commutative79.8%
associate-/l*79.8%
distribute-rgt-out79.8%
associate-/r*79.8%
metadata-eval79.8%
sub-neg79.8%
+-commutative79.8%
Simplified79.8%
distribute-lft-in79.8%
associate-*l/79.8%
pow279.8%
Applied egg-rr79.8%
+-commutative79.8%
fma-define79.9%
associate-*r/79.9%
*-commutative79.9%
Simplified79.9%
if 2.4999999999999999e87 < b Initial program 44.5%
div-sub44.5%
sub-neg44.5%
neg-mul-144.5%
*-commutative44.5%
associate-/l*44.5%
distribute-neg-frac44.5%
neg-mul-144.5%
*-commutative44.5%
associate-/l*44.4%
distribute-rgt-out44.4%
associate-/r*44.4%
metadata-eval44.4%
sub-neg44.4%
+-commutative44.4%
Simplified44.4%
Taylor expanded in c around 0 96.0%
+-commutative96.0%
mul-1-neg96.0%
unsub-neg96.0%
Simplified96.0%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.46e-53)
(/ c (- b))
(if (<= b 1e+87)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.46e-53) {
tmp = c / -b;
} else if (b <= 1e+87) {
tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.46d-53)) then
tmp = c / -b
else if (b <= 1d+87) then
tmp = (-b - sqrt(((b * b) - (4.0d0 * (c * a))))) / (a * 2.0d0)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.46e-53) {
tmp = c / -b;
} else if (b <= 1e+87) {
tmp = (-b - Math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.46e-53: tmp = c / -b elif b <= 1e+87: tmp = (-b - math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.46e-53) tmp = Float64(c / Float64(-b)); elseif (b <= 1e+87) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a))))) / Float64(a * 2.0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.46e-53) tmp = c / -b; elseif (b <= 1e+87) tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.46e-53], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 1e+87], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.46 \cdot 10^{-53}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 10^{+87}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.45999999999999989e-53Initial program 16.3%
div-sub14.9%
sub-neg14.9%
neg-mul-114.9%
*-commutative14.9%
associate-/l*13.7%
distribute-neg-frac13.7%
neg-mul-113.7%
*-commutative13.7%
associate-/l*14.9%
distribute-rgt-out16.3%
associate-/r*16.3%
metadata-eval16.3%
sub-neg16.3%
+-commutative16.3%
Simplified16.3%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
distribute-neg-frac286.2%
Simplified86.2%
if -1.45999999999999989e-53 < b < 9.9999999999999996e86Initial program 79.9%
if 9.9999999999999996e86 < b Initial program 44.5%
div-sub44.5%
sub-neg44.5%
neg-mul-144.5%
*-commutative44.5%
associate-/l*44.5%
distribute-neg-frac44.5%
neg-mul-144.5%
*-commutative44.5%
associate-/l*44.4%
distribute-rgt-out44.4%
associate-/r*44.4%
metadata-eval44.4%
sub-neg44.4%
+-commutative44.4%
Simplified44.4%
Taylor expanded in c around 0 96.0%
+-commutative96.0%
mul-1-neg96.0%
unsub-neg96.0%
Simplified96.0%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(if (<= b -5.1e-67)
(/ c (- b))
(if (<= b -1.7e-90)
(* (sqrt (/ (* c -4.0) a)) (- 0.5))
(if (<= b 6.2e-177)
(* 0.5 (sqrt (* c (/ -4.0 a))))
(- (/ c b) (/ b a))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.1e-67) {
tmp = c / -b;
} else if (b <= -1.7e-90) {
tmp = sqrt(((c * -4.0) / a)) * -0.5;
} else if (b <= 6.2e-177) {
tmp = 0.5 * sqrt((c * (-4.0 / a)));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.1d-67)) then
tmp = c / -b
else if (b <= (-1.7d-90)) then
tmp = sqrt(((c * (-4.0d0)) / a)) * -0.5d0
else if (b <= 6.2d-177) then
tmp = 0.5d0 * sqrt((c * ((-4.0d0) / a)))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.1e-67) {
tmp = c / -b;
} else if (b <= -1.7e-90) {
tmp = Math.sqrt(((c * -4.0) / a)) * -0.5;
} else if (b <= 6.2e-177) {
tmp = 0.5 * Math.sqrt((c * (-4.0 / a)));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.1e-67: tmp = c / -b elif b <= -1.7e-90: tmp = math.sqrt(((c * -4.0) / a)) * -0.5 elif b <= 6.2e-177: tmp = 0.5 * math.sqrt((c * (-4.0 / a))) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.1e-67) tmp = Float64(c / Float64(-b)); elseif (b <= -1.7e-90) tmp = Float64(sqrt(Float64(Float64(c * -4.0) / a)) * Float64(-0.5)); elseif (b <= 6.2e-177) tmp = Float64(0.5 * sqrt(Float64(c * Float64(-4.0 / a)))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.1e-67) tmp = c / -b; elseif (b <= -1.7e-90) tmp = sqrt(((c * -4.0) / a)) * -0.5; elseif (b <= 6.2e-177) tmp = 0.5 * sqrt((c * (-4.0 / a))); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.1e-67], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, -1.7e-90], N[(N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision] * (-0.5)), $MachinePrecision], If[LessEqual[b, 6.2e-177], N[(0.5 * N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.1 \cdot 10^{-67}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq -1.7 \cdot 10^{-90}:\\
\;\;\;\;\sqrt{\frac{c \cdot -4}{a}} \cdot \left(-0.5\right)\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-177}:\\
\;\;\;\;0.5 \cdot \sqrt{c \cdot \frac{-4}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.09999999999999982e-67Initial program 16.3%
div-sub14.9%
sub-neg14.9%
neg-mul-114.9%
*-commutative14.9%
associate-/l*13.7%
distribute-neg-frac13.7%
neg-mul-113.7%
*-commutative13.7%
associate-/l*14.9%
distribute-rgt-out16.3%
associate-/r*16.3%
metadata-eval16.3%
sub-neg16.3%
+-commutative16.3%
Simplified16.3%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
distribute-neg-frac286.2%
Simplified86.2%
if -5.09999999999999982e-67 < b < -1.69999999999999997e-90Initial program 85.5%
*-commutative85.5%
*-commutative85.5%
sqr-neg85.5%
*-commutative85.5%
sqr-neg85.5%
*-commutative85.5%
associate-*r*85.5%
Simplified85.5%
add-cube-cbrt85.5%
pow385.1%
*-commutative85.1%
associate-*l*85.1%
Applied egg-rr85.1%
Taylor expanded in c around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt98.7%
neg-mul-198.7%
rem-cube-cbrt99.6%
associate-/l*99.3%
Simplified99.3%
associate-*r/99.6%
Applied egg-rr99.6%
if -1.69999999999999997e-90 < b < 6.20000000000000036e-177Initial program 77.0%
*-commutative77.0%
*-commutative77.0%
sqr-neg77.0%
*-commutative77.0%
sqr-neg77.0%
*-commutative77.0%
associate-*r*77.0%
Simplified77.0%
add-cube-cbrt76.2%
pow376.2%
*-commutative76.2%
associate-*l*76.2%
Applied egg-rr76.2%
Taylor expanded in c around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt25.3%
neg-mul-125.3%
rem-cube-cbrt25.4%
associate-/l*25.3%
Simplified25.3%
add-sqr-sqrt0.9%
sqrt-unprod44.8%
sqr-neg44.8%
add-sqr-sqrt44.8%
pow144.8%
Applied egg-rr44.8%
unpow144.8%
Simplified44.8%
if 6.20000000000000036e-177 < b Initial program 59.5%
div-sub59.5%
sub-neg59.5%
neg-mul-159.5%
*-commutative59.5%
associate-/l*59.5%
distribute-neg-frac59.5%
neg-mul-159.5%
*-commutative59.5%
associate-/l*59.4%
distribute-rgt-out59.4%
associate-/r*59.4%
metadata-eval59.4%
sub-neg59.4%
+-commutative59.4%
Simplified59.4%
Taylor expanded in c around 0 80.0%
+-commutative80.0%
mul-1-neg80.0%
unsub-neg80.0%
Simplified80.0%
Final simplification76.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* c (/ -4.0 a)))))
(if (<= b -1.52e-56)
(/ c (- b))
(if (<= b -3.3e-98)
(* -0.5 t_0)
(if (<= b 1.8e-177) (* 0.5 t_0) (- (/ c b) (/ b a)))))))
double code(double a, double b, double c) {
double t_0 = sqrt((c * (-4.0 / a)));
double tmp;
if (b <= -1.52e-56) {
tmp = c / -b;
} else if (b <= -3.3e-98) {
tmp = -0.5 * t_0;
} else if (b <= 1.8e-177) {
tmp = 0.5 * t_0;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((c * ((-4.0d0) / a)))
if (b <= (-1.52d-56)) then
tmp = c / -b
else if (b <= (-3.3d-98)) then
tmp = (-0.5d0) * t_0
else if (b <= 1.8d-177) then
tmp = 0.5d0 * t_0
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt((c * (-4.0 / a)));
double tmp;
if (b <= -1.52e-56) {
tmp = c / -b;
} else if (b <= -3.3e-98) {
tmp = -0.5 * t_0;
} else if (b <= 1.8e-177) {
tmp = 0.5 * t_0;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt((c * (-4.0 / a))) tmp = 0 if b <= -1.52e-56: tmp = c / -b elif b <= -3.3e-98: tmp = -0.5 * t_0 elif b <= 1.8e-177: tmp = 0.5 * t_0 else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(c * Float64(-4.0 / a))) tmp = 0.0 if (b <= -1.52e-56) tmp = Float64(c / Float64(-b)); elseif (b <= -3.3e-98) tmp = Float64(-0.5 * t_0); elseif (b <= 1.8e-177) tmp = Float64(0.5 * t_0); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt((c * (-4.0 / a))); tmp = 0.0; if (b <= -1.52e-56) tmp = c / -b; elseif (b <= -3.3e-98) tmp = -0.5 * t_0; elseif (b <= 1.8e-177) tmp = 0.5 * t_0; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.52e-56], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, -3.3e-98], N[(-0.5 * t$95$0), $MachinePrecision], If[LessEqual[b, 1.8e-177], N[(0.5 * t$95$0), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{c \cdot \frac{-4}{a}}\\
\mathbf{if}\;b \leq -1.52 \cdot 10^{-56}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq -3.3 \cdot 10^{-98}:\\
\;\;\;\;-0.5 \cdot t\_0\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-177}:\\
\;\;\;\;0.5 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.5199999999999999e-56Initial program 16.3%
div-sub14.9%
sub-neg14.9%
neg-mul-114.9%
*-commutative14.9%
associate-/l*13.7%
distribute-neg-frac13.7%
neg-mul-113.7%
*-commutative13.7%
associate-/l*14.9%
distribute-rgt-out16.3%
associate-/r*16.3%
metadata-eval16.3%
sub-neg16.3%
+-commutative16.3%
Simplified16.3%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
distribute-neg-frac286.2%
Simplified86.2%
if -1.5199999999999999e-56 < b < -3.3000000000000001e-98Initial program 85.5%
*-commutative85.5%
*-commutative85.5%
sqr-neg85.5%
*-commutative85.5%
sqr-neg85.5%
*-commutative85.5%
associate-*r*85.5%
Simplified85.5%
add-cube-cbrt85.5%
pow385.1%
*-commutative85.1%
associate-*l*85.1%
Applied egg-rr85.1%
Taylor expanded in c around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt98.7%
neg-mul-198.7%
rem-cube-cbrt99.6%
associate-/l*99.3%
Simplified99.3%
distribute-rgt-neg-out99.3%
Applied egg-rr99.3%
distribute-lft-neg-in99.3%
metadata-eval99.3%
Simplified99.3%
if -3.3000000000000001e-98 < b < 1.79999999999999991e-177Initial program 77.0%
*-commutative77.0%
*-commutative77.0%
sqr-neg77.0%
*-commutative77.0%
sqr-neg77.0%
*-commutative77.0%
associate-*r*77.0%
Simplified77.0%
add-cube-cbrt76.2%
pow376.2%
*-commutative76.2%
associate-*l*76.2%
Applied egg-rr76.2%
Taylor expanded in c around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt25.3%
neg-mul-125.3%
rem-cube-cbrt25.4%
associate-/l*25.3%
Simplified25.3%
add-sqr-sqrt0.9%
sqrt-unprod44.8%
sqr-neg44.8%
add-sqr-sqrt44.8%
pow144.8%
Applied egg-rr44.8%
unpow144.8%
Simplified44.8%
if 1.79999999999999991e-177 < b Initial program 59.5%
div-sub59.5%
sub-neg59.5%
neg-mul-159.5%
*-commutative59.5%
associate-/l*59.5%
distribute-neg-frac59.5%
neg-mul-159.5%
*-commutative59.5%
associate-/l*59.4%
distribute-rgt-out59.4%
associate-/r*59.4%
metadata-eval59.4%
sub-neg59.4%
+-commutative59.4%
Simplified59.4%
Taylor expanded in c around 0 80.0%
+-commutative80.0%
mul-1-neg80.0%
unsub-neg80.0%
Simplified80.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.35e-61)
(/ c (- b))
(if (<= b 1.35e-69)
(/ (- (- b) (sqrt (* -4.0 (* c a)))) (* a 2.0))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.35e-61) {
tmp = c / -b;
} else if (b <= 1.35e-69) {
tmp = (-b - sqrt((-4.0 * (c * a)))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.35d-61)) then
tmp = c / -b
else if (b <= 1.35d-69) then
tmp = (-b - sqrt(((-4.0d0) * (c * a)))) / (a * 2.0d0)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.35e-61) {
tmp = c / -b;
} else if (b <= 1.35e-69) {
tmp = (-b - Math.sqrt((-4.0 * (c * a)))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.35e-61: tmp = c / -b elif b <= 1.35e-69: tmp = (-b - math.sqrt((-4.0 * (c * a)))) / (a * 2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.35e-61) tmp = Float64(c / Float64(-b)); elseif (b <= 1.35e-69) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(-4.0 * Float64(c * a)))) / Float64(a * 2.0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.35e-61) tmp = c / -b; elseif (b <= 1.35e-69) tmp = (-b - sqrt((-4.0 * (c * a)))) / (a * 2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.35e-61], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 1.35e-69], N[(N[((-b) - N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.35 \cdot 10^{-61}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-69}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -2.3499999999999998e-61Initial program 16.3%
div-sub14.9%
sub-neg14.9%
neg-mul-114.9%
*-commutative14.9%
associate-/l*13.7%
distribute-neg-frac13.7%
neg-mul-113.7%
*-commutative13.7%
associate-/l*14.9%
distribute-rgt-out16.3%
associate-/r*16.3%
metadata-eval16.3%
sub-neg16.3%
+-commutative16.3%
Simplified16.3%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
distribute-neg-frac286.2%
Simplified86.2%
if -2.3499999999999998e-61 < b < 1.3499999999999999e-69Initial program 80.2%
*-commutative80.2%
*-commutative80.2%
sqr-neg80.2%
*-commutative80.2%
sqr-neg80.2%
*-commutative80.2%
associate-*r*80.2%
Simplified80.2%
Taylor expanded in b around 0 77.6%
*-commutative77.6%
Simplified77.6%
if 1.3499999999999999e-69 < b Initial program 56.2%
div-sub56.2%
sub-neg56.2%
neg-mul-156.2%
*-commutative56.2%
associate-/l*56.2%
distribute-neg-frac56.2%
neg-mul-156.2%
*-commutative56.2%
associate-/l*56.1%
distribute-rgt-out56.1%
associate-/r*56.1%
metadata-eval56.1%
sub-neg56.1%
+-commutative56.1%
Simplified56.1%
Taylor expanded in c around 0 85.7%
+-commutative85.7%
mul-1-neg85.7%
unsub-neg85.7%
Simplified85.7%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.05e-64)
(/ c (- b))
(if (<= b 8.8e-67)
(/ (sqrt (* a (* c -4.0))) (* a (- 2.0)))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.05e-64) {
tmp = c / -b;
} else if (b <= 8.8e-67) {
tmp = sqrt((a * (c * -4.0))) / (a * -2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-3.05d-64)) then
tmp = c / -b
else if (b <= 8.8d-67) then
tmp = sqrt((a * (c * (-4.0d0)))) / (a * -2.0d0)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.05e-64) {
tmp = c / -b;
} else if (b <= 8.8e-67) {
tmp = Math.sqrt((a * (c * -4.0))) / (a * -2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.05e-64: tmp = c / -b elif b <= 8.8e-67: tmp = math.sqrt((a * (c * -4.0))) / (a * -2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.05e-64) tmp = Float64(c / Float64(-b)); elseif (b <= 8.8e-67) tmp = Float64(sqrt(Float64(a * Float64(c * -4.0))) / Float64(a * Float64(-2.0))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.05e-64) tmp = c / -b; elseif (b <= 8.8e-67) tmp = sqrt((a * (c * -4.0))) / (a * -2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.05e-64], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 8.8e-67], N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * (-2.0)), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.05 \cdot 10^{-64}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 8.8 \cdot 10^{-67}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot \left(-2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -3.0499999999999998e-64Initial program 16.3%
div-sub14.9%
sub-neg14.9%
neg-mul-114.9%
*-commutative14.9%
associate-/l*13.7%
distribute-neg-frac13.7%
neg-mul-113.7%
*-commutative13.7%
associate-/l*14.9%
distribute-rgt-out16.3%
associate-/r*16.3%
metadata-eval16.3%
sub-neg16.3%
+-commutative16.3%
Simplified16.3%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
distribute-neg-frac286.2%
Simplified86.2%
if -3.0499999999999998e-64 < b < 8.8000000000000004e-67Initial program 80.2%
*-commutative80.2%
*-commutative80.2%
sqr-neg80.2%
*-commutative80.2%
sqr-neg80.2%
*-commutative80.2%
associate-*r*80.2%
Simplified80.2%
add-cube-cbrt79.4%
pow379.4%
*-commutative79.4%
associate-*l*79.4%
Applied egg-rr79.4%
Taylor expanded in c around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt76.8%
mul-1-neg76.8%
rem-cube-cbrt77.2%
Simplified77.2%
if 8.8000000000000004e-67 < b Initial program 56.2%
div-sub56.2%
sub-neg56.2%
neg-mul-156.2%
*-commutative56.2%
associate-/l*56.2%
distribute-neg-frac56.2%
neg-mul-156.2%
*-commutative56.2%
associate-/l*56.1%
distribute-rgt-out56.1%
associate-/r*56.1%
metadata-eval56.1%
sub-neg56.1%
+-commutative56.1%
Simplified56.1%
Taylor expanded in c around 0 85.7%
+-commutative85.7%
mul-1-neg85.7%
unsub-neg85.7%
Simplified85.7%
Final simplification83.8%
(FPCore (a b c) :precision binary64 (if (<= b -3.5e-67) (/ c (- b)) (if (<= b 7e-202) (* -0.5 (sqrt (* c (/ -4.0 a)))) (- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-67) {
tmp = c / -b;
} else if (b <= 7e-202) {
tmp = -0.5 * sqrt((c * (-4.0 / a)));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-3.5d-67)) then
tmp = c / -b
else if (b <= 7d-202) then
tmp = (-0.5d0) * sqrt((c * ((-4.0d0) / a)))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-67) {
tmp = c / -b;
} else if (b <= 7e-202) {
tmp = -0.5 * Math.sqrt((c * (-4.0 / a)));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.5e-67: tmp = c / -b elif b <= 7e-202: tmp = -0.5 * math.sqrt((c * (-4.0 / a))) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.5e-67) tmp = Float64(c / Float64(-b)); elseif (b <= 7e-202) tmp = Float64(-0.5 * sqrt(Float64(c * Float64(-4.0 / a)))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.5e-67) tmp = c / -b; elseif (b <= 7e-202) tmp = -0.5 * sqrt((c * (-4.0 / a))); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.5e-67], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 7e-202], N[(-0.5 * N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-202}:\\
\;\;\;\;-0.5 \cdot \sqrt{c \cdot \frac{-4}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -3.5e-67Initial program 16.3%
div-sub14.9%
sub-neg14.9%
neg-mul-114.9%
*-commutative14.9%
associate-/l*13.7%
distribute-neg-frac13.7%
neg-mul-113.7%
*-commutative13.7%
associate-/l*14.9%
distribute-rgt-out16.3%
associate-/r*16.3%
metadata-eval16.3%
sub-neg16.3%
+-commutative16.3%
Simplified16.3%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
distribute-neg-frac286.2%
Simplified86.2%
if -3.5e-67 < b < 6.9999999999999998e-202Initial program 80.3%
*-commutative80.3%
*-commutative80.3%
sqr-neg80.3%
*-commutative80.3%
sqr-neg80.3%
*-commutative80.3%
associate-*r*80.3%
Simplified80.3%
add-cube-cbrt79.6%
pow379.6%
*-commutative79.6%
associate-*l*79.6%
Applied egg-rr79.6%
Taylor expanded in c around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt36.8%
neg-mul-136.8%
rem-cube-cbrt37.0%
associate-/l*36.9%
Simplified36.9%
distribute-rgt-neg-out36.9%
Applied egg-rr36.9%
distribute-lft-neg-in36.9%
metadata-eval36.9%
Simplified36.9%
if 6.9999999999999998e-202 < b Initial program 59.0%
div-sub59.0%
sub-neg59.0%
neg-mul-159.0%
*-commutative59.0%
associate-/l*59.0%
distribute-neg-frac59.0%
neg-mul-159.0%
*-commutative59.0%
associate-/l*58.9%
distribute-rgt-out58.9%
associate-/r*58.9%
metadata-eval58.9%
sub-neg58.9%
+-commutative58.9%
Simplified58.9%
Taylor expanded in c around 0 78.8%
+-commutative78.8%
mul-1-neg78.8%
unsub-neg78.8%
Simplified78.8%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ c (- b)) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = c / -b;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = c / -b
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = c / -b;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = c / -b else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(c / Float64(-b)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = c / -b; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(c / (-b)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 35.4%
div-sub34.4%
sub-neg34.4%
neg-mul-134.4%
*-commutative34.4%
associate-/l*33.6%
distribute-neg-frac33.6%
neg-mul-133.6%
*-commutative33.6%
associate-/l*34.4%
distribute-rgt-out35.4%
associate-/r*35.4%
metadata-eval35.4%
sub-neg35.4%
+-commutative35.4%
Simplified35.4%
Taylor expanded in b around -inf 64.2%
mul-1-neg64.2%
distribute-neg-frac264.2%
Simplified64.2%
if -4.999999999999985e-310 < b Initial program 60.7%
div-sub60.7%
sub-neg60.7%
neg-mul-160.7%
*-commutative60.7%
associate-/l*60.6%
distribute-neg-frac60.6%
neg-mul-160.6%
*-commutative60.6%
associate-/l*60.6%
distribute-rgt-out60.6%
associate-/r*60.6%
metadata-eval60.6%
sub-neg60.6%
+-commutative60.6%
Simplified60.6%
Taylor expanded in c around 0 71.6%
+-commutative71.6%
mul-1-neg71.6%
unsub-neg71.6%
Simplified71.6%
(FPCore (a b c) :precision binary64 (if (<= b -1.9e-305) (/ c (- b)) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e-305) {
tmp = c / -b;
} else {
tmp = b / -a;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.9d-305)) then
tmp = c / -b
else
tmp = b / -a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e-305) {
tmp = c / -b;
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.9e-305: tmp = c / -b else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.9e-305) tmp = Float64(c / Float64(-b)); else tmp = Float64(b / Float64(-a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.9e-305) tmp = c / -b; else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.9e-305], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{-305}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
if b < -1.9e-305Initial program 34.9%
div-sub33.9%
sub-neg33.9%
neg-mul-133.9%
*-commutative33.9%
associate-/l*33.1%
distribute-neg-frac33.1%
neg-mul-133.1%
*-commutative33.1%
associate-/l*33.9%
distribute-rgt-out34.9%
associate-/r*34.9%
metadata-eval34.9%
sub-neg34.9%
+-commutative34.9%
Simplified34.9%
Taylor expanded in b around -inf 64.7%
mul-1-neg64.7%
distribute-neg-frac264.7%
Simplified64.7%
if -1.9e-305 < b Initial program 61.0%
div-sub61.0%
sub-neg61.0%
neg-mul-161.0%
*-commutative61.0%
associate-/l*60.9%
distribute-neg-frac60.9%
neg-mul-160.9%
*-commutative60.9%
associate-/l*60.9%
distribute-rgt-out60.9%
associate-/r*60.9%
metadata-eval60.9%
sub-neg60.9%
+-commutative60.9%
Simplified60.9%
Taylor expanded in a around 0 70.8%
associate-*r/70.8%
mul-1-neg70.8%
Simplified70.8%
Final simplification67.6%
(FPCore (a b c) :precision binary64 (/ c (- b)))
double code(double a, double b, double c) {
return c / -b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c / -b
end function
public static double code(double a, double b, double c) {
return c / -b;
}
def code(a, b, c): return c / -b
function code(a, b, c) return Float64(c / Float64(-b)) end
function tmp = code(a, b, c) tmp = c / -b; end
code[a_, b_, c_] := N[(c / (-b)), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{-b}
\end{array}
Initial program 47.5%
div-sub47.0%
sub-neg47.0%
neg-mul-147.0%
*-commutative47.0%
associate-/l*46.6%
distribute-neg-frac46.6%
neg-mul-146.6%
*-commutative46.6%
associate-/l*47.0%
distribute-rgt-out47.5%
associate-/r*47.5%
metadata-eval47.5%
sub-neg47.5%
+-commutative47.5%
Simplified47.5%
Taylor expanded in b around -inf 34.4%
mul-1-neg34.4%
distribute-neg-frac234.4%
Simplified34.4%
(FPCore (a b c) :precision binary64 (/ c b))
double code(double a, double b, double c) {
return c / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c / b
end function
public static double code(double a, double b, double c) {
return c / b;
}
def code(a, b, c): return c / b
function code(a, b, c) return Float64(c / b) end
function tmp = code(a, b, c) tmp = c / b; end
code[a_, b_, c_] := N[(c / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b}
\end{array}
Initial program 47.5%
div-sub47.0%
sub-neg47.0%
neg-mul-147.0%
*-commutative47.0%
associate-/l*46.6%
distribute-neg-frac46.6%
neg-mul-146.6%
*-commutative46.6%
associate-/l*47.0%
distribute-rgt-out47.5%
associate-/r*47.5%
metadata-eval47.5%
sub-neg47.5%
+-commutative47.5%
Simplified47.5%
Taylor expanded in c around 0 35.5%
+-commutative35.5%
mul-1-neg35.5%
unsub-neg35.5%
Simplified35.5%
Taylor expanded in c around inf 11.4%
(FPCore (a b c) :precision binary64 (/ b a))
double code(double a, double b, double c) {
return b / a;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = b / a
end function
public static double code(double a, double b, double c) {
return b / a;
}
def code(a, b, c): return b / a
function code(a, b, c) return Float64(b / a) end
function tmp = code(a, b, c) tmp = b / a; end
code[a_, b_, c_] := N[(b / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a}
\end{array}
Initial program 47.5%
div-sub47.0%
sub-neg47.0%
neg-mul-147.0%
*-commutative47.0%
associate-/l*46.6%
distribute-neg-frac46.6%
neg-mul-146.6%
*-commutative46.6%
associate-/l*47.0%
distribute-rgt-out47.5%
associate-/r*47.5%
metadata-eval47.5%
sub-neg47.5%
+-commutative47.5%
Simplified47.5%
Taylor expanded in a around 0 35.6%
associate-*r/35.6%
mul-1-neg35.6%
Simplified35.6%
add-sqr-sqrt1.4%
sqrt-unprod2.0%
sqr-neg2.0%
sqrt-prod0.7%
add-sqr-sqrt2.7%
div-inv2.7%
Applied egg-rr2.7%
associate-*r/2.7%
*-rgt-identity2.7%
Simplified2.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (< b 0.0)
(/ c (* a (/ (+ (- b) t_0) (* 2.0 a))))
(/ (- (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.0 * a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
if (b < 0.0d0) then
tmp = c / (a * ((-b + t_0) / (2.0d0 * a)))
else
tmp = (-b - t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (a * c)))) tmp = 0 if b < 0.0: tmp = c / (a * ((-b + t_0) / (2.0 * a))) else: tmp = (-b - t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) tmp = 0.0 if (b < 0.0) tmp = Float64(c / Float64(a * Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)))); else tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (a * c)))); tmp = 0.0; if (b < 0.0) tmp = c / (a * ((-b + t_0) / (2.0 * a))); else tmp = (-b - t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(c / N[(a * N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t\_0}{2 \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\end{array}
\end{array}
herbie shell --seed 2024139
(FPCore (a b c)
:name "The quadratic formula (r2)"
:precision binary64
:alt
(! :herbie-platform default (let ((d (sqrt (- (* b b) (* 4 (* a c)))))) (let ((r1 (/ (+ (- b) d) (* 2 a)))) (let ((r2 (/ (- (- b) d) (* 2 a)))) (if (< b 0) (/ c (* a r1)) r2)))))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))