
(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 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(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 -24000000.0)
(- (/ c b) (/ b a))
(if (<= b 6.5e+86)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(/ (* -2.0 (/ -1.0 (/ (/ (- b) a) c))) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -24000000.0) {
tmp = (c / b) - (b / a);
} else if (b <= 6.5e+86) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 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 <= (-24000000.0d0)) then
tmp = (c / b) - (b / a)
else if (b <= 6.5d+86) then
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
else
tmp = ((-2.0d0) * ((-1.0d0) / ((-b / a) / c))) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -24000000.0) {
tmp = (c / b) - (b / a);
} else if (b <= 6.5e+86) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -24000000.0: tmp = (c / b) - (b / a) elif b <= 6.5e+86: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -24000000.0) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.5e+86) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-2.0 * Float64(-1.0 / Float64(Float64(Float64(-b) / a) / c))) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -24000000.0) tmp = (c / b) - (b / a); elseif (b <= 6.5e+86) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -24000000.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e+86], 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[(N[(-2.0 * N[(-1.0 / N[(N[((-b) / a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -24000000:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{+86}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{-1}{\frac{\frac{-b}{a}}{c}}}{a \cdot 2}\\
\end{array}
\end{array}
if b < -2.4e7Initial program 64.8%
*-commutative64.8%
Simplified64.8%
Taylor expanded in b around -inf 94.5%
+-commutative94.5%
mul-1-neg94.5%
unsub-neg94.5%
Simplified94.5%
if -2.4e7 < b < 6.49999999999999996e86Initial program 74.6%
if 6.49999999999999996e86 < b Initial program 24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
associate-/l*75.6%
Simplified75.6%
*-un-lft-identity75.6%
div-inv75.6%
times-frac67.4%
Applied egg-rr67.4%
frac-2neg67.4%
metadata-eval67.4%
clear-num67.3%
frac-times67.4%
metadata-eval67.4%
Applied egg-rr67.4%
associate-*r/75.6%
associate-*r/75.7%
*-rgt-identity75.7%
Simplified75.7%
Final simplification80.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.15e-54)
(- (/ c b) (/ b a))
(if (<= b 0.78)
(* 0.5 (/ (pow (* c (* a -4.0)) 0.5) a))
(/ (* -2.0 (/ -1.0 (/ (/ (- b) a) c))) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.15e-54) {
tmp = (c / b) - (b / a);
} else if (b <= 0.78) {
tmp = 0.5 * (pow((c * (a * -4.0)), 0.5) / a);
} else {
tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 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 <= (-2.15d-54)) then
tmp = (c / b) - (b / a)
else if (b <= 0.78d0) then
tmp = 0.5d0 * (((c * (a * (-4.0d0))) ** 0.5d0) / a)
else
tmp = ((-2.0d0) * ((-1.0d0) / ((-b / a) / c))) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.15e-54) {
tmp = (c / b) - (b / a);
} else if (b <= 0.78) {
tmp = 0.5 * (Math.pow((c * (a * -4.0)), 0.5) / a);
} else {
tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.15e-54: tmp = (c / b) - (b / a) elif b <= 0.78: tmp = 0.5 * (math.pow((c * (a * -4.0)), 0.5) / a) else: tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.15e-54) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 0.78) tmp = Float64(0.5 * Float64((Float64(c * Float64(a * -4.0)) ^ 0.5) / a)); else tmp = Float64(Float64(-2.0 * Float64(-1.0 / Float64(Float64(Float64(-b) / a) / c))) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.15e-54) tmp = (c / b) - (b / a); elseif (b <= 0.78) tmp = 0.5 * (((c * (a * -4.0)) ^ 0.5) / a); else tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.15e-54], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.78], N[(0.5 * N[(N[Power[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(-1.0 / N[(N[((-b) / a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.15 \cdot 10^{-54}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 0.78:\\
\;\;\;\;0.5 \cdot \frac{{\left(c \cdot \left(a \cdot -4\right)\right)}^{0.5}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{-1}{\frac{\frac{-b}{a}}{c}}}{a \cdot 2}\\
\end{array}
\end{array}
if b < -2.15e-54Initial program 70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in b around -inf 92.2%
+-commutative92.2%
mul-1-neg92.2%
unsub-neg92.2%
Simplified92.2%
if -2.15e-54 < b < 0.78000000000000003Initial program 71.6%
*-commutative71.6%
Simplified71.6%
prod-diff71.0%
*-commutative71.0%
fma-def71.0%
associate-+l+71.0%
pow271.0%
distribute-lft-neg-in71.0%
*-commutative71.0%
distribute-rgt-neg-in71.0%
metadata-eval71.0%
associate-*r*71.0%
*-commutative71.0%
*-commutative71.0%
fma-udef71.0%
Applied egg-rr71.0%
fma-def71.0%
fma-def71.0%
*-commutative71.0%
Simplified71.0%
Taylor expanded in b around 0 62.4%
associate-*l/62.4%
distribute-rgt-out64.1%
metadata-eval64.1%
associate-*r*64.1%
*-lft-identity64.1%
*-commutative64.1%
Simplified64.1%
div-inv64.1%
add-sqr-sqrt63.8%
associate-*l*63.7%
pow1/263.7%
sqrt-pow163.8%
*-commutative63.8%
*-commutative63.8%
associate-*l*63.8%
metadata-eval63.8%
pow1/263.8%
sqrt-pow163.8%
*-commutative63.8%
*-commutative63.8%
associate-*l*63.8%
metadata-eval63.8%
Applied egg-rr63.8%
associate-*r/63.8%
*-rgt-identity63.8%
associate-*r/63.9%
pow-sqr64.1%
*-commutative64.1%
metadata-eval64.1%
Simplified64.1%
if 0.78000000000000003 < b Initial program 39.1%
*-commutative39.1%
Simplified39.1%
Taylor expanded in b around inf 61.8%
*-commutative61.8%
associate-/l*67.5%
Simplified67.5%
*-un-lft-identity67.5%
div-inv67.5%
times-frac61.8%
Applied egg-rr61.8%
frac-2neg61.8%
metadata-eval61.8%
clear-num61.7%
frac-times61.8%
metadata-eval61.8%
Applied egg-rr61.8%
associate-*r/67.5%
associate-*r/67.5%
*-rgt-identity67.5%
Simplified67.5%
Final simplification74.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e-57)
(- (/ c b) (/ b a))
(if (<= b 480000.0)
(* 0.5 (/ (sqrt (* a (* c -4.0))) a))
(/ (* -2.0 (/ -1.0 (/ (/ (- b) a) c))) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 480000.0) {
tmp = 0.5 * (sqrt((a * (c * -4.0))) / a);
} else {
tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 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 <= (-1.5d-57)) then
tmp = (c / b) - (b / a)
else if (b <= 480000.0d0) then
tmp = 0.5d0 * (sqrt((a * (c * (-4.0d0)))) / a)
else
tmp = ((-2.0d0) * ((-1.0d0) / ((-b / a) / c))) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 480000.0) {
tmp = 0.5 * (Math.sqrt((a * (c * -4.0))) / a);
} else {
tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e-57: tmp = (c / b) - (b / a) elif b <= 480000.0: tmp = 0.5 * (math.sqrt((a * (c * -4.0))) / a) else: tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e-57) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 480000.0) tmp = Float64(0.5 * Float64(sqrt(Float64(a * Float64(c * -4.0))) / a)); else tmp = Float64(Float64(-2.0 * Float64(-1.0 / Float64(Float64(Float64(-b) / a) / c))) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.5e-57) tmp = (c / b) - (b / a); elseif (b <= 480000.0) tmp = 0.5 * (sqrt((a * (c * -4.0))) / a); else tmp = (-2.0 * (-1.0 / ((-b / a) / c))) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-57], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 480000.0], N[(0.5 * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(-1.0 / N[(N[((-b) / a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-57}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 480000:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{-1}{\frac{\frac{-b}{a}}{c}}}{a \cdot 2}\\
\end{array}
\end{array}
if b < -1.5e-57Initial program 70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in b around -inf 92.2%
+-commutative92.2%
mul-1-neg92.2%
unsub-neg92.2%
Simplified92.2%
if -1.5e-57 < b < 4.8e5Initial program 71.6%
*-commutative71.6%
Simplified71.6%
prod-diff71.0%
*-commutative71.0%
fma-def71.0%
associate-+l+71.0%
pow271.0%
distribute-lft-neg-in71.0%
*-commutative71.0%
distribute-rgt-neg-in71.0%
metadata-eval71.0%
associate-*r*71.0%
*-commutative71.0%
*-commutative71.0%
fma-udef71.0%
Applied egg-rr71.0%
fma-def71.0%
fma-def71.0%
*-commutative71.0%
Simplified71.0%
Taylor expanded in b around 0 62.4%
associate-*l/62.4%
distribute-rgt-out64.1%
metadata-eval64.1%
associate-*r*64.1%
*-lft-identity64.1%
*-commutative64.1%
Simplified64.1%
if 4.8e5 < b Initial program 39.1%
*-commutative39.1%
Simplified39.1%
Taylor expanded in b around inf 61.8%
*-commutative61.8%
associate-/l*67.5%
Simplified67.5%
*-un-lft-identity67.5%
div-inv67.5%
times-frac61.8%
Applied egg-rr61.8%
frac-2neg61.8%
metadata-eval61.8%
clear-num61.7%
frac-times61.8%
metadata-eval61.8%
Applied egg-rr61.8%
associate-*r/67.5%
associate-*r/67.5%
*-rgt-identity67.5%
Simplified67.5%
Final simplification74.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- b) a)))
(if (<= b 4e-309)
t_0
(if (<= b 3.2e+86)
(/ (- (+ b (* -2.0 (/ (* c a) b))) b) (* a 2.0))
(/ (* -2.0 (/ -1.0 (/ t_0 c))) (* a 2.0))))))
double code(double a, double b, double c) {
double t_0 = -b / a;
double tmp;
if (b <= 4e-309) {
tmp = t_0;
} else if (b <= 3.2e+86) {
tmp = ((b + (-2.0 * ((c * a) / b))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (-1.0 / (t_0 / c))) / (a * 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) :: t_0
real(8) :: tmp
t_0 = -b / a
if (b <= 4d-309) then
tmp = t_0
else if (b <= 3.2d+86) then
tmp = ((b + ((-2.0d0) * ((c * a) / b))) - b) / (a * 2.0d0)
else
tmp = ((-2.0d0) * ((-1.0d0) / (t_0 / c))) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -b / a;
double tmp;
if (b <= 4e-309) {
tmp = t_0;
} else if (b <= 3.2e+86) {
tmp = ((b + (-2.0 * ((c * a) / b))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (-1.0 / (t_0 / c))) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): t_0 = -b / a tmp = 0 if b <= 4e-309: tmp = t_0 elif b <= 3.2e+86: tmp = ((b + (-2.0 * ((c * a) / b))) - b) / (a * 2.0) else: tmp = (-2.0 * (-1.0 / (t_0 / c))) / (a * 2.0) return tmp
function code(a, b, c) t_0 = Float64(Float64(-b) / a) tmp = 0.0 if (b <= 4e-309) tmp = t_0; elseif (b <= 3.2e+86) tmp = Float64(Float64(Float64(b + Float64(-2.0 * Float64(Float64(c * a) / b))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-2.0 * Float64(-1.0 / Float64(t_0 / c))) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = -b / a; tmp = 0.0; if (b <= 4e-309) tmp = t_0; elseif (b <= 3.2e+86) tmp = ((b + (-2.0 * ((c * a) / b))) - b) / (a * 2.0); else tmp = (-2.0 * (-1.0 / (t_0 / c))) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) / a), $MachinePrecision]}, If[LessEqual[b, 4e-309], t$95$0, If[LessEqual[b, 3.2e+86], N[(N[(N[(b + N[(-2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(-1.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-b}{a}\\
\mathbf{if}\;b \leq 4 \cdot 10^{-309}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{+86}:\\
\;\;\;\;\frac{\left(b + -2 \cdot \frac{c \cdot a}{b}\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{-1}{\frac{t\_0}{c}}}{a \cdot 2}\\
\end{array}
\end{array}
if b < 3.9999999999999977e-309Initial program 72.8%
*-commutative72.8%
Simplified72.8%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
mul-1-neg67.1%
Simplified67.1%
if 3.9999999999999977e-309 < b < 3.2e86Initial program 68.4%
*-commutative68.4%
Simplified68.4%
Taylor expanded in b around inf 33.2%
if 3.2e86 < b Initial program 24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
associate-/l*75.6%
Simplified75.6%
*-un-lft-identity75.6%
div-inv75.6%
times-frac67.4%
Applied egg-rr67.4%
frac-2neg67.4%
metadata-eval67.4%
clear-num67.3%
frac-times67.4%
metadata-eval67.4%
Applied egg-rr67.4%
associate-*r/75.6%
associate-*r/75.7%
*-rgt-identity75.7%
Simplified75.7%
Final simplification59.8%
(FPCore (a b c) :precision binary64 (let* ((t_0 (/ (- b) a))) (if (<= b -5e-310) t_0 (/ (* -2.0 (/ -1.0 (/ t_0 c))) (* a 2.0)))))
double code(double a, double b, double c) {
double t_0 = -b / a;
double tmp;
if (b <= -5e-310) {
tmp = t_0;
} else {
tmp = (-2.0 * (-1.0 / (t_0 / c))) / (a * 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) :: t_0
real(8) :: tmp
t_0 = -b / a
if (b <= (-5d-310)) then
tmp = t_0
else
tmp = ((-2.0d0) * ((-1.0d0) / (t_0 / c))) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -b / a;
double tmp;
if (b <= -5e-310) {
tmp = t_0;
} else {
tmp = (-2.0 * (-1.0 / (t_0 / c))) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): t_0 = -b / a tmp = 0 if b <= -5e-310: tmp = t_0 else: tmp = (-2.0 * (-1.0 / (t_0 / c))) / (a * 2.0) return tmp
function code(a, b, c) t_0 = Float64(Float64(-b) / a) tmp = 0.0 if (b <= -5e-310) tmp = t_0; else tmp = Float64(Float64(-2.0 * Float64(-1.0 / Float64(t_0 / c))) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = -b / a; tmp = 0.0; if (b <= -5e-310) tmp = t_0; else tmp = (-2.0 * (-1.0 / (t_0 / c))) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) / a), $MachinePrecision]}, If[LessEqual[b, -5e-310], t$95$0, N[(N[(-2.0 * N[(-1.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-b}{a}\\
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{-1}{\frac{t\_0}{c}}}{a \cdot 2}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.8%
*-commutative72.8%
Simplified72.8%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
mul-1-neg67.1%
Simplified67.1%
if -4.999999999999985e-310 < b Initial program 48.4%
*-commutative48.4%
Simplified48.4%
Taylor expanded in b around inf 45.5%
*-commutative45.5%
associate-/l*49.4%
Simplified49.4%
*-un-lft-identity49.4%
div-inv49.4%
times-frac45.5%
Applied egg-rr45.5%
frac-2neg45.5%
metadata-eval45.5%
clear-num45.1%
frac-times45.2%
metadata-eval45.2%
Applied egg-rr45.2%
associate-*r/49.3%
associate-*r/49.4%
*-rgt-identity49.4%
Simplified49.4%
Final simplification58.2%
(FPCore (a b c) :precision binary64 (if (<= b 1.6e-308) (/ (- b) a) (* (/ (/ c (/ b a)) 2.0) (/ -2.0 a))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = -b / a;
} else {
tmp = ((c / (b / a)) / 2.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) :: tmp
if (b <= 1.6d-308) then
tmp = -b / a
else
tmp = ((c / (b / a)) / 2.0d0) * ((-2.0d0) / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = -b / a;
} else {
tmp = ((c / (b / a)) / 2.0) * (-2.0 / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.6e-308: tmp = -b / a else: tmp = ((c / (b / a)) / 2.0) * (-2.0 / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.6e-308) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(Float64(c / Float64(b / a)) / 2.0) * Float64(-2.0 / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.6e-308) tmp = -b / a; else tmp = ((c / (b / a)) / 2.0) * (-2.0 / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.6e-308], N[((-b) / a), $MachinePrecision], N[(N[(N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] * N[(-2.0 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6 \cdot 10^{-308}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c}{\frac{b}{a}}}{2} \cdot \frac{-2}{a}\\
\end{array}
\end{array}
if b < 1.6000000000000001e-308Initial program 72.8%
*-commutative72.8%
Simplified72.8%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
mul-1-neg67.1%
Simplified67.1%
if 1.6000000000000001e-308 < b Initial program 48.4%
*-commutative48.4%
Simplified48.4%
Taylor expanded in b around inf 45.5%
*-commutative45.5%
associate-/l*49.4%
Simplified49.4%
*-un-lft-identity49.4%
div-inv49.4%
times-frac45.5%
Applied egg-rr45.5%
*-commutative45.5%
*-commutative45.5%
times-frac45.5%
frac-times49.4%
*-un-lft-identity49.4%
div-inv49.4%
Applied egg-rr49.4%
Final simplification58.2%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (- b) a) (/ (/ (- c) (/ b a)) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -b / a;
} else {
tmp = (-c / (b / a)) / 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 = -b / a
else
tmp = (-c / (b / a)) / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -b / a;
} else {
tmp = (-c / (b / a)) / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -b / a else: tmp = (-c / (b / a)) / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(Float64(-c) / Float64(b / a)) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -b / a; else tmp = (-c / (b / a)) / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[((-b) / a), $MachinePrecision], N[(N[((-c) / N[(b / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-c}{\frac{b}{a}}}{a}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.8%
*-commutative72.8%
Simplified72.8%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
mul-1-neg67.1%
Simplified67.1%
if -4.999999999999985e-310 < b Initial program 48.4%
*-commutative48.4%
Simplified48.4%
Taylor expanded in b around inf 45.5%
*-commutative45.5%
associate-/l*49.4%
Simplified49.4%
*-un-lft-identity49.4%
div-inv49.4%
times-frac45.5%
Applied egg-rr45.5%
*-commutative45.5%
times-frac45.5%
frac-times49.4%
*-un-lft-identity49.4%
div-inv49.4%
metadata-eval49.4%
Applied egg-rr49.4%
Final simplification58.2%
(FPCore (a b c) :precision binary64 (if (<= b -7.4e-300) (/ (- b) a) (/ (- b b) (* a 2.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.4e-300) {
tmp = -b / a;
} else {
tmp = (b - b) / (a * 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.4d-300)) then
tmp = -b / a
else
tmp = (b - b) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7.4e-300) {
tmp = -b / a;
} else {
tmp = (b - b) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.4e-300: tmp = -b / a else: tmp = (b - b) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.4e-300) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(b - b) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.4e-300) tmp = -b / a; else tmp = (b - b) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.4e-300], N[((-b) / a), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.4 \cdot 10^{-300}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -7.4000000000000003e-300Initial program 72.4%
*-commutative72.4%
Simplified72.4%
Taylor expanded in b around -inf 68.1%
associate-*r/68.1%
mul-1-neg68.1%
Simplified68.1%
if -7.4000000000000003e-300 < b Initial program 49.2%
*-commutative49.2%
Simplified49.2%
Taylor expanded in b around inf 46.3%
Final simplification56.9%
(FPCore (a b c) :precision binary64 (if (<= b 3.4e+15) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.4e+15) {
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 <= 3.4d+15) 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 <= 3.4e+15) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.4e+15: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.4e+15) 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 <= 3.4e+15) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.4e+15], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.4 \cdot 10^{+15}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 3.4e15Initial program 69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in b around -inf 49.6%
associate-*r/49.6%
mul-1-neg49.6%
Simplified49.6%
if 3.4e15 < b Initial program 40.9%
*-commutative40.9%
Simplified40.9%
Applied egg-rr6.5%
Taylor expanded in b around -inf 29.7%
Final simplification43.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) 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 <= -5e-310) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.8%
*-commutative72.8%
Simplified72.8%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
mul-1-neg67.1%
Simplified67.1%
if -4.999999999999985e-310 < b Initial program 48.4%
*-commutative48.4%
Simplified48.4%
Taylor expanded in b around inf 39.7%
mul-1-neg39.7%
distribute-neg-frac39.7%
Simplified39.7%
Final simplification53.3%
(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 60.5%
*-commutative60.5%
Simplified60.5%
Applied egg-rr29.3%
Taylor expanded in a around 0 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 60.5%
*-commutative60.5%
Simplified60.5%
Applied egg-rr29.3%
Taylor expanded in b around -inf 11.5%
Final simplification11.5%
herbie shell --seed 2024031
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))