
(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 8 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 (/ (* 2.0 c) (- (- b) (sqrt (fma a (* c -4.0) (* b b))))))
double code(double a, double b, double c) {
return (2.0 * c) / (-b - sqrt(fma(a, (c * -4.0), (b * b))));
}
function code(a, b, c) return Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(fma(a, Float64(c * -4.0), Float64(b * b))))) end
code[a_, b_, c_] := N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}
\end{array}
Initial program 56.8%
flip-+56.8%
pow256.8%
add-sqr-sqrt58.3%
*-commutative58.3%
*-commutative58.3%
*-commutative58.3%
*-commutative58.3%
Applied egg-rr58.3%
Taylor expanded in b around 0 99.2%
expm1-log1p-u82.2%
expm1-udef61.6%
Applied egg-rr61.6%
expm1-def82.1%
expm1-log1p99.2%
associate-/r*99.4%
*-commutative99.4%
times-frac99.4%
metadata-eval99.4%
sub-neg99.4%
+-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
fma-def99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in c around 0 99.5%
Final simplification99.5%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)) -0.025) (/ (- (sqrt (+ (* b b) (* -4.0 (* c a)))) b) (* 2.0 a)) (/ (* 2.0 (/ (* c a) a)) (+ (* 2.0 (/ (* c a) b)) (* b -2.0)))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a)) <= -0.025) {
tmp = (sqrt(((b * b) + (-4.0 * (c * a)))) - b) / (2.0 * a);
} else {
tmp = (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0));
}
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 (((sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (2.0d0 * a)) <= (-0.025d0)) then
tmp = (sqrt(((b * b) + ((-4.0d0) * (c * a)))) - b) / (2.0d0 * a)
else
tmp = (2.0d0 * ((c * a) / a)) / ((2.0d0 * ((c * a) / b)) + (b * (-2.0d0)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (((Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a)) <= -0.025) {
tmp = (Math.sqrt(((b * b) + (-4.0 * (c * a)))) - b) / (2.0 * a);
} else {
tmp = (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0));
}
return tmp;
}
def code(a, b, c): tmp = 0 if ((math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a)) <= -0.025: tmp = (math.sqrt(((b * b) + (-4.0 * (c * a)))) - b) / (2.0 * a) else: tmp = (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0)) return tmp
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)) <= -0.025) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) + Float64(-4.0 * Float64(c * a)))) - b) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * Float64(Float64(c * a) / a)) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) + Float64(b * -2.0))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (((sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a)) <= -0.025) tmp = (sqrt(((b * b) + (-4.0 * (c * a)))) - b) / (2.0 * a); else tmp = (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], -0.025], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] + N[(b * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a} \leq -0.025:\\
\;\;\;\;\frac{\sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \frac{c \cdot a}{a}}{2 \cdot \frac{c \cdot a}{b} + b \cdot -2}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) < -0.025000000000000001Initial program 81.9%
*-commutative81.9%
+-commutative81.9%
unsub-neg81.9%
fma-neg82.0%
associate-*l*82.0%
*-commutative82.0%
distribute-rgt-neg-in82.0%
metadata-eval82.0%
Simplified82.0%
fma-udef81.9%
*-commutative81.9%
Applied egg-rr81.9%
if -0.025000000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) Initial program 47.0%
flip-+47.2%
pow247.1%
add-sqr-sqrt48.5%
*-commutative48.5%
*-commutative48.5%
*-commutative48.5%
*-commutative48.5%
Applied egg-rr48.5%
Taylor expanded in b around 0 99.2%
expm1-log1p-u99.2%
expm1-udef70.8%
Applied egg-rr70.8%
expm1-def99.2%
expm1-log1p99.2%
associate-/r*99.4%
*-commutative99.4%
times-frac99.4%
metadata-eval99.4%
sub-neg99.4%
+-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
fma-def99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in b around inf 88.8%
Final simplification86.9%
(FPCore (a b c) :precision binary64 (/ (* 2.0 (/ (* c a) a)) (- (- b) (sqrt (+ (* b b) (* -4.0 (* c a)))))))
double code(double a, double b, double c) {
return (2.0 * ((c * a) / a)) / (-b - sqrt(((b * b) + (-4.0 * (c * a)))));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (2.0d0 * ((c * a) / a)) / (-b - sqrt(((b * b) + ((-4.0d0) * (c * a)))))
end function
public static double code(double a, double b, double c) {
return (2.0 * ((c * a) / a)) / (-b - Math.sqrt(((b * b) + (-4.0 * (c * a)))));
}
def code(a, b, c): return (2.0 * ((c * a) / a)) / (-b - math.sqrt(((b * b) + (-4.0 * (c * a)))))
function code(a, b, c) return Float64(Float64(2.0 * Float64(Float64(c * a) / a)) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) + Float64(-4.0 * Float64(c * a)))))) end
function tmp = code(a, b, c) tmp = (2.0 * ((c * a) / a)) / (-b - sqrt(((b * b) + (-4.0 * (c * a))))); end
code[a_, b_, c_] := N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 \cdot \frac{c \cdot a}{a}}{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}
\end{array}
Initial program 56.8%
flip-+56.8%
pow256.8%
add-sqr-sqrt58.3%
*-commutative58.3%
*-commutative58.3%
*-commutative58.3%
*-commutative58.3%
Applied egg-rr58.3%
Taylor expanded in b around 0 99.2%
expm1-log1p-u82.2%
expm1-udef61.6%
Applied egg-rr61.6%
expm1-def82.1%
expm1-log1p99.2%
associate-/r*99.4%
*-commutative99.4%
times-frac99.4%
metadata-eval99.4%
sub-neg99.4%
+-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
fma-def99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
metadata-eval99.4%
Simplified99.4%
fma-udef99.4%
associate-*l*99.4%
*-commutative99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (a b c) :precision binary64 (if (<= b 7.6) (* (- (sqrt (+ (* b b) (* -4.0 (* c a)))) b) (/ 0.5 a)) (/ (* 2.0 (/ (* c a) a)) (+ (* 2.0 (/ (* c a) b)) (* b -2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.6) {
tmp = (sqrt(((b * b) + (-4.0 * (c * a)))) - b) * (0.5 / a);
} else {
tmp = (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0));
}
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 <= 7.6d0) then
tmp = (sqrt(((b * b) + ((-4.0d0) * (c * a)))) - b) * (0.5d0 / a)
else
tmp = (2.0d0 * ((c * a) / a)) / ((2.0d0 * ((c * a) / b)) + (b * (-2.0d0)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 7.6) {
tmp = (Math.sqrt(((b * b) + (-4.0 * (c * a)))) - b) * (0.5 / a);
} else {
tmp = (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.6: tmp = (math.sqrt(((b * b) + (-4.0 * (c * a)))) - b) * (0.5 / a) else: tmp = (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.6) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) + Float64(-4.0 * Float64(c * a)))) - b) * Float64(0.5 / a)); else tmp = Float64(Float64(2.0 * Float64(Float64(c * a) / a)) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) + Float64(b * -2.0))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7.6) tmp = (sqrt(((b * b) + (-4.0 * (c * a)))) - b) * (0.5 / a); else tmp = (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.6], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] + N[(b * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.6:\\
\;\;\;\;\left(\sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \frac{c \cdot a}{a}}{2 \cdot \frac{c \cdot a}{b} + b \cdot -2}\\
\end{array}
\end{array}
if b < 7.5999999999999996Initial program 84.1%
/-rgt-identity84.1%
metadata-eval84.1%
associate-/l*84.1%
associate-*r/84.0%
+-commutative84.0%
unsub-neg84.0%
fma-neg84.3%
associate-*l*84.3%
*-commutative84.3%
distribute-rgt-neg-in84.3%
metadata-eval84.3%
associate-/r*84.3%
metadata-eval84.3%
metadata-eval84.3%
Simplified84.3%
fma-udef84.0%
*-commutative84.0%
Applied egg-rr84.0%
if 7.5999999999999996 < b Initial program 49.4%
flip-+49.4%
pow249.4%
add-sqr-sqrt50.9%
*-commutative50.9%
*-commutative50.9%
*-commutative50.9%
*-commutative50.9%
Applied egg-rr50.9%
Taylor expanded in b around 0 99.2%
expm1-log1p-u85.9%
expm1-udef62.2%
Applied egg-rr62.2%
expm1-def85.8%
expm1-log1p99.2%
associate-/r*99.3%
*-commutative99.3%
times-frac99.3%
metadata-eval99.3%
sub-neg99.3%
+-commutative99.3%
associate-*r*99.3%
*-commutative99.3%
distribute-rgt-neg-in99.3%
fma-def99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in b around inf 86.3%
Final simplification85.8%
(FPCore (a b c) :precision binary64 (/ (* 2.0 (/ (* c a) a)) (+ (* 2.0 (/ (* c a) b)) (* b -2.0))))
double code(double a, double b, double c) {
return (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (2.0d0 * ((c * a) / a)) / ((2.0d0 * ((c * a) / b)) + (b * (-2.0d0)))
end function
public static double code(double a, double b, double c) {
return (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0));
}
def code(a, b, c): return (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0))
function code(a, b, c) return Float64(Float64(2.0 * Float64(Float64(c * a) / a)) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) + Float64(b * -2.0))) end
function tmp = code(a, b, c) tmp = (2.0 * ((c * a) / a)) / ((2.0 * ((c * a) / b)) + (b * -2.0)); end
code[a_, b_, c_] := N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] + N[(b * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 \cdot \frac{c \cdot a}{a}}{2 \cdot \frac{c \cdot a}{b} + b \cdot -2}
\end{array}
Initial program 56.8%
flip-+56.8%
pow256.8%
add-sqr-sqrt58.3%
*-commutative58.3%
*-commutative58.3%
*-commutative58.3%
*-commutative58.3%
Applied egg-rr58.3%
Taylor expanded in b around 0 99.2%
expm1-log1p-u82.2%
expm1-udef61.6%
Applied egg-rr61.6%
expm1-def82.1%
expm1-log1p99.2%
associate-/r*99.4%
*-commutative99.4%
times-frac99.4%
metadata-eval99.4%
sub-neg99.4%
+-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
fma-def99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in b around inf 79.9%
Final simplification79.9%
(FPCore (a b c) :precision binary64 (- (/ (- c) b) (/ (* c (* c a)) (* b (* b b)))))
double code(double a, double b, double c) {
return (-c / b) - ((c * (c * a)) / (b * (b * 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) - ((c * (c * a)) / (b * (b * b)))
end function
public static double code(double a, double b, double c) {
return (-c / b) - ((c * (c * a)) / (b * (b * b)));
}
def code(a, b, c): return (-c / b) - ((c * (c * a)) / (b * (b * b)))
function code(a, b, c) return Float64(Float64(Float64(-c) / b) - Float64(Float64(c * Float64(c * a)) / Float64(b * Float64(b * b)))) end
function tmp = code(a, b, c) tmp = (-c / b) - ((c * (c * a)) / (b * (b * b))); end
code[a_, b_, c_] := N[(N[((-c) / b), $MachinePrecision] - N[(N[(c * N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-c}{b} - \frac{c \cdot \left(c \cdot a\right)}{b \cdot \left(b \cdot b\right)}
\end{array}
Initial program 56.8%
neg-sub056.8%
associate-+l-56.8%
sub0-neg56.8%
neg-mul-156.8%
associate-*l/56.8%
*-commutative56.8%
associate-/r*56.8%
/-rgt-identity56.8%
metadata-eval56.8%
Simplified56.8%
Taylor expanded in b around inf 79.2%
+-commutative79.2%
mul-1-neg79.2%
unsub-neg79.2%
associate-*r/79.2%
neg-mul-179.2%
unpow279.2%
associate-*l*79.2%
Simplified79.2%
unpow379.2%
Applied egg-rr79.2%
Final simplification79.2%
(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(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 56.8%
neg-sub056.8%
associate-+l-56.8%
sub0-neg56.8%
neg-mul-156.8%
associate-*l/56.8%
*-commutative56.8%
associate-/r*56.8%
/-rgt-identity56.8%
metadata-eval56.8%
Simplified56.8%
Taylor expanded in b around inf 63.3%
associate-*r/63.3%
neg-mul-163.3%
Simplified63.3%
Final simplification63.3%
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
return 0.0 / a;
}
def code(a, b, c): return 0.0 / a
function code(a, b, c) return Float64(0.0 / a) end
function tmp = code(a, b, c) tmp = 0.0 / a; end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 56.8%
add-cube-cbrt56.8%
pow356.8%
neg-mul-156.8%
fma-def56.8%
*-commutative56.8%
*-commutative56.8%
*-commutative56.8%
Applied egg-rr56.8%
Taylor expanded in c around 0 3.2%
distribute-rgt1-in3.2%
metadata-eval3.2%
mul0-lft3.2%
pow-base-13.2%
associate-*l/3.2%
metadata-eval3.2%
associate-*r/3.2%
metadata-eval3.2%
Simplified3.2%
Final simplification3.2%
herbie shell --seed 2023175
(FPCore (a b c)
:name "Quadratic roots, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))