
(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.75e+82)
(- (/ c b) (/ b a))
(if (<= b 6.4e-66)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.75e+82) {
tmp = (c / b) - (b / a);
} else if (b <= 6.4e-66) {
tmp = (sqrt(((b * b) - (c * (a * 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 <= (-2.75d+82)) then
tmp = (c / b) - (b / a)
else if (b <= 6.4d-66) then
tmp = (sqrt(((b * b) - (c * (a * 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 <= -2.75e+82) {
tmp = (c / b) - (b / a);
} else if (b <= 6.4e-66) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.75e+82: tmp = (c / b) - (b / a) elif b <= 6.4e-66: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.75e+82) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.4e-66) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.75e+82) tmp = (c / b) - (b / a); elseif (b <= 6.4e-66) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.75e+82], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.4e-66], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $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 -2.75 \cdot 10^{+82}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.74999999999999998e82Initial program 65.1%
neg-sub065.1%
associate-+l-65.1%
sub0-neg65.1%
neg-mul-165.1%
associate-*l/64.9%
*-commutative64.9%
associate-/r*64.9%
/-rgt-identity64.9%
metadata-eval64.9%
Simplified65.0%
Taylor expanded in b around -inf 96.4%
mul-1-neg96.4%
unsub-neg96.4%
Simplified96.4%
if -2.74999999999999998e82 < b < 6.39999999999999963e-66Initial program 82.7%
if 6.39999999999999963e-66 < b Initial program 10.7%
neg-sub010.7%
associate-+l-10.7%
sub0-neg10.7%
neg-mul-110.7%
associate-*l/10.7%
*-commutative10.7%
associate-/r*10.7%
/-rgt-identity10.7%
metadata-eval10.7%
Simplified10.7%
Taylor expanded in b around inf 88.6%
associate-*r/88.6%
neg-mul-188.6%
Simplified88.6%
Final simplification87.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.75e+82)
(- (/ c b) (/ b a))
(if (<= b 7.5e-67)
(* (- (sqrt (+ (* b b) (* a (* c -4.0)))) b) (/ 0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.75e+82) {
tmp = (c / b) - (b / a);
} else if (b <= 7.5e-67) {
tmp = (sqrt(((b * b) + (a * (c * -4.0)))) - b) * (0.5 / 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 <= (-2.75d+82)) then
tmp = (c / b) - (b / a)
else if (b <= 7.5d-67) then
tmp = (sqrt(((b * b) + (a * (c * (-4.0d0))))) - b) * (0.5d0 / 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 <= -2.75e+82) {
tmp = (c / b) - (b / a);
} else if (b <= 7.5e-67) {
tmp = (Math.sqrt(((b * b) + (a * (c * -4.0)))) - b) * (0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.75e+82: tmp = (c / b) - (b / a) elif b <= 7.5e-67: tmp = (math.sqrt(((b * b) + (a * (c * -4.0)))) - b) * (0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.75e+82) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.5e-67) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) + Float64(a * Float64(c * -4.0)))) - b) * Float64(0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.75e+82) tmp = (c / b) - (b / a); elseif (b <= 7.5e-67) tmp = (sqrt(((b * b) + (a * (c * -4.0)))) - b) * (0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.75e+82], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-67], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.75 \cdot 10^{+82}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-67}:\\
\;\;\;\;\left(\sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.74999999999999998e82Initial program 65.1%
neg-sub065.1%
associate-+l-65.1%
sub0-neg65.1%
neg-mul-165.1%
associate-*l/64.9%
*-commutative64.9%
associate-/r*64.9%
/-rgt-identity64.9%
metadata-eval64.9%
Simplified65.0%
Taylor expanded in b around -inf 96.4%
mul-1-neg96.4%
unsub-neg96.4%
Simplified96.4%
if -2.74999999999999998e82 < b < 7.5000000000000005e-67Initial program 82.7%
/-rgt-identity82.7%
metadata-eval82.7%
associate-/l*82.7%
associate-*r/82.5%
+-commutative82.5%
unsub-neg82.5%
fma-neg82.5%
associate-*l*82.5%
*-commutative82.5%
distribute-rgt-neg-in82.5%
metadata-eval82.5%
associate-/r*82.5%
metadata-eval82.5%
metadata-eval82.5%
Simplified82.5%
fma-udef82.5%
associate-*l*82.5%
Applied egg-rr82.5%
if 7.5000000000000005e-67 < b Initial program 10.7%
neg-sub010.7%
associate-+l-10.7%
sub0-neg10.7%
neg-mul-110.7%
associate-*l/10.7%
*-commutative10.7%
associate-/r*10.7%
/-rgt-identity10.7%
metadata-eval10.7%
Simplified10.7%
Taylor expanded in b around inf 88.6%
associate-*r/88.6%
neg-mul-188.6%
Simplified88.6%
Final simplification87.4%
(FPCore (a b c) :precision binary64 (if (<= b -4.5e-92) (- (/ c b) (/ b a)) (if (<= b 1e-66) (* (/ 0.5 a) (- (sqrt (* c (* a -4.0))) b)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-92) {
tmp = (c / b) - (b / a);
} else if (b <= 1e-66) {
tmp = (0.5 / a) * (sqrt((c * (a * -4.0))) - b);
} 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 <= (-4.5d-92)) then
tmp = (c / b) - (b / a)
else if (b <= 1d-66) then
tmp = (0.5d0 / a) * (sqrt((c * (a * (-4.0d0)))) - b)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-92) {
tmp = (c / b) - (b / a);
} else if (b <= 1e-66) {
tmp = (0.5 / a) * (Math.sqrt((c * (a * -4.0))) - b);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.5e-92: tmp = (c / b) - (b / a) elif b <= 1e-66: tmp = (0.5 / a) * (math.sqrt((c * (a * -4.0))) - b) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.5e-92) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1e-66) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(c * Float64(a * -4.0))) - b)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.5e-92) tmp = (c / b) - (b / a); elseif (b <= 1e-66) tmp = (0.5 / a) * (sqrt((c * (a * -4.0))) - b); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.5e-92], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-66], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-92}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 10^{-66}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{c \cdot \left(a \cdot -4\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.5e-92Initial program 78.1%
neg-sub078.1%
associate-+l-78.1%
sub0-neg78.1%
neg-mul-178.1%
associate-*l/77.9%
*-commutative77.9%
associate-/r*77.9%
/-rgt-identity77.9%
metadata-eval77.9%
Simplified77.9%
Taylor expanded in b around -inf 86.8%
mul-1-neg86.8%
unsub-neg86.8%
Simplified86.8%
if -4.5e-92 < b < 9.9999999999999998e-67Initial program 76.2%
/-rgt-identity76.2%
metadata-eval76.2%
associate-/l*76.2%
associate-*r/76.1%
+-commutative76.1%
unsub-neg76.1%
fma-neg76.1%
associate-*l*76.1%
*-commutative76.1%
distribute-rgt-neg-in76.1%
metadata-eval76.1%
associate-/r*76.1%
metadata-eval76.1%
metadata-eval76.1%
Simplified76.1%
Taylor expanded in b around 0 74.9%
*-commutative74.9%
*-commutative74.9%
*-commutative74.9%
associate-*r*74.9%
Simplified74.9%
if 9.9999999999999998e-67 < b Initial program 10.7%
neg-sub010.7%
associate-+l-10.7%
sub0-neg10.7%
neg-mul-110.7%
associate-*l/10.7%
*-commutative10.7%
associate-/r*10.7%
/-rgt-identity10.7%
metadata-eval10.7%
Simplified10.7%
Taylor expanded in b around inf 88.6%
associate-*r/88.6%
neg-mul-188.6%
Simplified88.6%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-92)
(- (/ c b) (/ b a))
(if (<= b 1.5e-67)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-92) {
tmp = (c / b) - (b / a);
} else if (b <= 1.5e-67) {
tmp = (sqrt((c * (a * -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 <= (-4.6d-92)) then
tmp = (c / b) - (b / a)
else if (b <= 1.5d-67) then
tmp = (sqrt((c * (a * (-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 <= -4.6e-92) {
tmp = (c / b) - (b / a);
} else if (b <= 1.5e-67) {
tmp = (Math.sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e-92: tmp = (c / b) - (b / a) elif b <= 1.5e-67: tmp = (math.sqrt((c * (a * -4.0))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-92) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.5e-67) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.6e-92) tmp = (c / b) - (b / a); elseif (b <= 1.5e-67) tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-92], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-67], N[(N[(N[Sqrt[N[(c * N[(a * -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 -4.6 \cdot 10^{-92}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.60000000000000032e-92Initial program 78.1%
neg-sub078.1%
associate-+l-78.1%
sub0-neg78.1%
neg-mul-178.1%
associate-*l/77.9%
*-commutative77.9%
associate-/r*77.9%
/-rgt-identity77.9%
metadata-eval77.9%
Simplified77.9%
Taylor expanded in b around -inf 86.8%
mul-1-neg86.8%
unsub-neg86.8%
Simplified86.8%
if -4.60000000000000032e-92 < b < 1.50000000000000016e-67Initial program 76.2%
add-sqr-sqrt75.8%
pow275.8%
pow1/275.8%
sqrt-pow175.9%
*-commutative75.9%
*-commutative75.9%
metadata-eval75.9%
Applied egg-rr75.9%
Taylor expanded in b around 0 74.7%
associate-*r*74.7%
*-commutative74.7%
Simplified74.7%
Taylor expanded in c around 0 33.0%
metadata-eval33.0%
pow-base-133.0%
sub-neg33.0%
log-prod70.2%
*-commutative70.2%
exp-to-pow74.7%
unpow274.7%
pow-sqr75.0%
metadata-eval75.0%
+-commutative75.0%
times-frac75.0%
*-commutative75.0%
Simplified75.0%
if 1.50000000000000016e-67 < b Initial program 10.7%
neg-sub010.7%
associate-+l-10.7%
sub0-neg10.7%
neg-mul-110.7%
associate-*l/10.7%
*-commutative10.7%
associate-/r*10.7%
/-rgt-identity10.7%
metadata-eval10.7%
Simplified10.7%
Taylor expanded in b around inf 88.6%
associate-*r/88.6%
neg-mul-188.6%
Simplified88.6%
Final simplification83.9%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = (c / b) - (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 <= (-1d-309)) then
tmp = (c / b) - (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 <= -1e-309) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-309) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 79.7%
neg-sub079.7%
associate-+l-79.7%
sub0-neg79.7%
neg-mul-179.7%
associate-*l/79.5%
*-commutative79.5%
associate-/r*79.5%
/-rgt-identity79.5%
metadata-eval79.5%
Simplified79.5%
Taylor expanded in b around -inf 67.7%
mul-1-neg67.7%
unsub-neg67.7%
Simplified67.7%
if -1.000000000000002e-309 < b Initial program 29.8%
neg-sub029.8%
associate-+l-29.8%
sub0-neg29.8%
neg-mul-129.8%
associate-*l/29.8%
*-commutative29.8%
associate-/r*29.8%
/-rgt-identity29.8%
metadata-eval29.8%
Simplified29.8%
Taylor expanded in b around inf 66.7%
associate-*r/66.7%
neg-mul-166.7%
Simplified66.7%
Final simplification67.2%
(FPCore (a b c) :precision binary64 (if (<= b 6.5) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5) {
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 <= 6.5d0) 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 <= 6.5) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.5: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.5) 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 <= 6.5) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.5], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 6.5Initial program 71.9%
neg-sub071.9%
associate-+l-71.9%
sub0-neg71.9%
neg-mul-171.9%
associate-*l/71.8%
*-commutative71.8%
associate-/r*71.8%
/-rgt-identity71.8%
metadata-eval71.8%
Simplified71.8%
Taylor expanded in b around -inf 47.1%
associate-*r/47.1%
neg-mul-147.1%
Simplified47.1%
if 6.5 < b Initial program 9.5%
neg-sub09.5%
associate-+l-9.5%
sub0-neg9.5%
neg-mul-19.5%
associate-*l/9.5%
*-commutative9.5%
associate-/r*9.5%
/-rgt-identity9.5%
metadata-eval9.5%
Simplified9.5%
Taylor expanded in b around -inf 2.7%
mul-1-neg2.7%
unsub-neg2.7%
Simplified2.7%
Taylor expanded in c around inf 23.5%
Final simplification40.5%
(FPCore (a b c) :precision binary64 (if (<= b 7.5e-308) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.5e-308) {
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 <= 7.5d-308) 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 <= 7.5e-308) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.5e-308: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.5e-308) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7.5e-308) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.5e-308], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.5 \cdot 10^{-308}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 7.4999999999999998e-308Initial program 79.1%
neg-sub079.1%
associate-+l-79.1%
sub0-neg79.1%
neg-mul-179.1%
associate-*l/78.9%
*-commutative78.9%
associate-/r*78.9%
/-rgt-identity78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
neg-mul-167.1%
Simplified67.1%
if 7.4999999999999998e-308 < b Initial program 30.0%
neg-sub030.0%
associate-+l-30.0%
sub0-neg30.0%
neg-mul-130.0%
associate-*l/30.0%
*-commutative30.0%
associate-/r*30.0%
/-rgt-identity30.0%
metadata-eval30.0%
Simplified30.0%
Taylor expanded in b around inf 67.2%
associate-*r/67.2%
neg-mul-167.2%
Simplified67.2%
Final simplification67.2%
(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 54.4%
clear-num54.3%
inv-pow54.3%
*-commutative54.3%
neg-mul-154.3%
fma-def54.3%
*-commutative54.3%
*-commutative54.3%
Applied egg-rr54.3%
Taylor expanded in b around inf 35.1%
mul-1-neg35.1%
sub-neg35.1%
Simplified35.1%
Taylor expanded in a around inf 2.6%
Final simplification2.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 / 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 54.4%
neg-sub054.4%
associate-+l-54.4%
sub0-neg54.4%
neg-mul-154.4%
associate-*l/54.3%
*-commutative54.3%
associate-/r*54.3%
/-rgt-identity54.3%
metadata-eval54.3%
Simplified54.3%
Taylor expanded in b around -inf 34.5%
mul-1-neg34.5%
unsub-neg34.5%
Simplified34.5%
Taylor expanded in c around inf 8.9%
Final simplification8.9%
herbie shell --seed 2023175
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))