
(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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -2.5e+153)
(- (/ b a))
(if (<= b 2.4e-208)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(if (<= b 9.2e+107)
(* (/ (* 4.0 c) (+ b (sqrt (fma -4.0 (* a c) (* b b))))) -0.5)
(/ c (- b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e+153) {
tmp = -(b / a);
} else if (b <= 2.4e-208) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else if (b <= 9.2e+107) {
tmp = ((4.0 * c) / (b + sqrt(fma(-4.0, (a * c), (b * b))))) * -0.5;
} else {
tmp = c / -b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.5e+153) tmp = Float64(-Float64(b / a)); elseif (b <= 2.4e-208) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); elseif (b <= 9.2e+107) tmp = Float64(Float64(Float64(4.0 * c) / Float64(b + sqrt(fma(-4.0, Float64(a * c), Float64(b * b))))) * -0.5); else tmp = Float64(c / Float64(-b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.5e+153], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 2.4e-208], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.2e+107], N[(N[(N[(4.0 * c), $MachinePrecision] / N[(b + N[Sqrt[N[(-4.0 * N[(a * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{+153}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-208}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 9.2 \cdot 10^{+107}:\\
\;\;\;\;\frac{4 \cdot c}{b + \sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.50000000000000009e153Initial program 31.7%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.9
Simplified92.9%
if -2.50000000000000009e153 < b < 2.3999999999999999e-208Initial program 88.9%
if 2.3999999999999999e-208 < b < 9.2000000000000001e107Initial program 30.9%
Applied egg-rr30.9%
Applied egg-rr64.9%
lift-*.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
distribute-frac-negN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift--.f64N/A
sub-negN/A
Applied egg-rr69.8%
Applied egg-rr84.9%
if 9.2000000000000001e107 < b Initial program 4.0%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6494.6
Simplified94.6%
Final simplification89.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.5e+153)
(- (/ b a))
(if (<= b 9.8e-36)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(* c (fma (- a) (/ c (* b (* b b))) (/ -1.0 b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e+153) {
tmp = -(b / a);
} else if (b <= 9.8e-36) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = c * fma(-a, (c / (b * (b * b))), (-1.0 / b));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.5e+153) tmp = Float64(-Float64(b / a)); elseif (b <= 9.8e-36) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); else tmp = Float64(c * fma(Float64(-a), Float64(c / Float64(b * Float64(b * b))), Float64(-1.0 / b))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.5e+153], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 9.8e-36], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c * N[((-a) * N[(c / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{+153}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{-36}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \mathsf{fma}\left(-a, \frac{c}{b \cdot \left(b \cdot b\right)}, \frac{-1}{b}\right)\\
\end{array}
\end{array}
if b < -2.50000000000000009e153Initial program 31.7%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.9
Simplified92.9%
if -2.50000000000000009e153 < b < 9.7999999999999994e-36Initial program 83.9%
if 9.7999999999999994e-36 < b Initial program 12.9%
Applied egg-rr12.8%
Taylor expanded in c around 0
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6485.7
Simplified85.7%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(if (<= b -9.5e+139)
(- (/ b a))
(if (<= b 9.8e-36)
(* (/ -0.5 a) (- b (sqrt (fma a (* c -4.0) (* b b)))))
(* c (fma (- a) (/ c (* b (* b b))) (/ -1.0 b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.5e+139) {
tmp = -(b / a);
} else if (b <= 9.8e-36) {
tmp = (-0.5 / a) * (b - sqrt(fma(a, (c * -4.0), (b * b))));
} else {
tmp = c * fma(-a, (c / (b * (b * b))), (-1.0 / b));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -9.5e+139) tmp = Float64(-Float64(b / a)); elseif (b <= 9.8e-36) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(fma(a, Float64(c * -4.0), Float64(b * b))))); else tmp = Float64(c * fma(Float64(-a), Float64(c / Float64(b * Float64(b * b))), Float64(-1.0 / b))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -9.5e+139], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 9.8e-36], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c * N[((-a) * N[(c / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.5 \cdot 10^{+139}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{-36}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \mathsf{fma}\left(-a, \frac{c}{b \cdot \left(b \cdot b\right)}, \frac{-1}{b}\right)\\
\end{array}
\end{array}
if b < -9.5000000000000002e139Initial program 43.1%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6494.1
Simplified94.1%
if -9.5000000000000002e139 < b < 9.7999999999999994e-36Initial program 83.2%
Applied egg-rr83.0%
if 9.7999999999999994e-36 < b Initial program 12.9%
Applied egg-rr12.8%
Taylor expanded in c around 0
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6485.7
Simplified85.7%
Final simplification85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.62e-74)
(- (/ b a))
(if (<= b 8.5e-67)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.62e-74) {
tmp = -(b / a);
} else if (b <= 8.5e-67) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
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.62d-74)) then
tmp = -(b / a)
else if (b <= 8.5d-67) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.62e-74) {
tmp = -(b / a);
} else if (b <= 8.5e-67) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.62e-74: tmp = -(b / a) elif b <= 8.5e-67: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.62e-74) tmp = Float64(-Float64(b / a)); elseif (b <= 8.5e-67) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.62e-74) tmp = -(b / a); elseif (b <= 8.5e-67) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.62e-74], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 8.5e-67], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.62 \cdot 10^{-74}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.62000000000000007e-74Initial program 77.1%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6484.8
Simplified84.8%
if -1.62000000000000007e-74 < b < 8.49999999999999993e-67Initial program 74.6%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.6
Simplified74.6%
if 8.49999999999999993e-67 < b Initial program 13.7%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6485.1
Simplified85.1%
Final simplification81.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.62e-74)
(- (/ b a))
(if (<= b 8.5e-67)
(* (/ -0.5 a) (- b (sqrt (* -4.0 (* a c)))))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.62e-74) {
tmp = -(b / a);
} else if (b <= 8.5e-67) {
tmp = (-0.5 / a) * (b - sqrt((-4.0 * (a * c))));
} else {
tmp = c / -b;
}
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.62d-74)) then
tmp = -(b / a)
else if (b <= 8.5d-67) then
tmp = ((-0.5d0) / a) * (b - sqrt(((-4.0d0) * (a * c))))
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.62e-74) {
tmp = -(b / a);
} else if (b <= 8.5e-67) {
tmp = (-0.5 / a) * (b - Math.sqrt((-4.0 * (a * c))));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.62e-74: tmp = -(b / a) elif b <= 8.5e-67: tmp = (-0.5 / a) * (b - math.sqrt((-4.0 * (a * c)))) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.62e-74) tmp = Float64(-Float64(b / a)); elseif (b <= 8.5e-67) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(-4.0 * Float64(a * c))))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.62e-74) tmp = -(b / a); elseif (b <= 8.5e-67) tmp = (-0.5 / a) * (b - sqrt((-4.0 * (a * c)))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.62e-74], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 8.5e-67], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(-4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.62 \cdot 10^{-74}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{-4 \cdot \left(a \cdot c\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.62000000000000007e-74Initial program 77.1%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6484.8
Simplified84.8%
if -1.62000000000000007e-74 < b < 8.49999999999999993e-67Initial program 74.6%
Applied egg-rr74.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6474.3
Simplified74.3%
if 8.49999999999999993e-67 < b Initial program 13.7%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6485.1
Simplified85.1%
Final simplification81.7%
(FPCore (a b c) :precision binary64 (if (<= b 5.1e-272) (- (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e-272) {
tmp = -(b / a);
} else {
tmp = c / -b;
}
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-272) then
tmp = -(b / a)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e-272) {
tmp = -(b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.1e-272: tmp = -(b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.1e-272) tmp = Float64(-Float64(b / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5.1e-272) tmp = -(b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.1e-272], (-N[(b / a), $MachinePrecision]), N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.1 \cdot 10^{-272}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 5.0999999999999998e-272Initial program 77.9%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6455.3
Simplified55.3%
if 5.0999999999999998e-272 < b Initial program 24.8%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6471.8
Simplified71.8%
Final simplification63.5%
(FPCore (a b c) :precision binary64 (if (<= b 1150000.0) (- (/ b a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1150000.0) {
tmp = -(b / a);
} else {
tmp = c / b;
}
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 <= 1150000.0d0) then
tmp = -(b / a)
else
tmp = c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1150000.0) {
tmp = -(b / a);
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1150000.0: tmp = -(b / a) else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1150000.0) tmp = Float64(-Float64(b / a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1150000.0) tmp = -(b / a); else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1150000.0], (-N[(b / a), $MachinePrecision]), N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1150000:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.15e6Initial program 70.5%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6441.7
Simplified41.7%
if 1.15e6 < b Initial program 11.5%
Applied egg-rr5.4%
Taylor expanded in b around -inf
lower-/.f6423.3
Simplified23.3%
Final simplification35.8%
(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 51.6%
Applied egg-rr32.6%
Taylor expanded in b around -inf
lower-/.f649.7
Simplified9.7%
(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 51.6%
Applied egg-rr32.6%
Taylor expanded in a around 0
lower-/.f642.7
Simplified2.7%
herbie shell --seed 2024215
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))