
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -8.2e+67)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 3.2)
(/ (- (sqrt (fma a (- c) (* b_2 b_2))) b_2) a)
(/ (* -0.5 (/ c (/ b_2 a))) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8.2e+67) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 3.2) {
tmp = (sqrt(fma(a, -c, (b_2 * b_2))) - b_2) / a;
} else {
tmp = (-0.5 * (c / (b_2 / a))) / a;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -8.2e+67) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 3.2) tmp = Float64(Float64(sqrt(fma(a, Float64(-c), Float64(b_2 * b_2))) - b_2) / a); else tmp = Float64(Float64(-0.5 * Float64(c / Float64(b_2 / a))) / a); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8.2e+67], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 3.2], N[(N[(N[Sqrt[N[(a * (-c) + N[(b$95$2 * b$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -8.2 \cdot 10^{+67}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 3.2:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, -c, b_2 \cdot b_2\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{c}{\frac{b_2}{a}}}{a}\\
\end{array}
\end{array}
if b_2 < -8.19999999999999959e67Initial program 61.0%
+-commutative61.0%
unsub-neg61.0%
Simplified61.0%
Taylor expanded in b_2 around -inf 97.8%
if -8.19999999999999959e67 < b_2 < 3.2000000000000002Initial program 80.1%
Simplified80.1%
if 3.2000000000000002 < b_2 Initial program 30.7%
+-commutative30.7%
unsub-neg30.7%
Simplified30.7%
Taylor expanded in b_2 around inf 73.6%
associate-/l*78.8%
associate-/r/79.2%
Simplified79.2%
*-commutative79.2%
clear-num79.9%
un-div-inv79.9%
Applied egg-rr79.9%
Final simplification83.1%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (* a (- c))) b_2) a)))
(if (<= b_2 -4.6e-41)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 1.55e-113)
t_0
(if (<= b_2 8e-63)
(* (/ (* 0.5 (* a c)) b_2) (/ 1.0 (- a)))
(if (<= b_2 0.0016) t_0 (/ (* -0.5 (/ c (/ b_2 a))) a)))))))
double code(double a, double b_2, double c) {
double t_0 = (sqrt((a * -c)) - b_2) / a;
double tmp;
if (b_2 <= -4.6e-41) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.55e-113) {
tmp = t_0;
} else if (b_2 <= 8e-63) {
tmp = ((0.5 * (a * c)) / b_2) * (1.0 / -a);
} else if (b_2 <= 0.0016) {
tmp = t_0;
} else {
tmp = (-0.5 * (c / (b_2 / a))) / a;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = (sqrt((a * -c)) - b_2) / a
if (b_2 <= (-4.6d-41)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 1.55d-113) then
tmp = t_0
else if (b_2 <= 8d-63) then
tmp = ((0.5d0 * (a * c)) / b_2) * (1.0d0 / -a)
else if (b_2 <= 0.0016d0) then
tmp = t_0
else
tmp = ((-0.5d0) * (c / (b_2 / a))) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double t_0 = (Math.sqrt((a * -c)) - b_2) / a;
double tmp;
if (b_2 <= -4.6e-41) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.55e-113) {
tmp = t_0;
} else if (b_2 <= 8e-63) {
tmp = ((0.5 * (a * c)) / b_2) * (1.0 / -a);
} else if (b_2 <= 0.0016) {
tmp = t_0;
} else {
tmp = (-0.5 * (c / (b_2 / a))) / a;
}
return tmp;
}
def code(a, b_2, c): t_0 = (math.sqrt((a * -c)) - b_2) / a tmp = 0 if b_2 <= -4.6e-41: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 1.55e-113: tmp = t_0 elif b_2 <= 8e-63: tmp = ((0.5 * (a * c)) / b_2) * (1.0 / -a) elif b_2 <= 0.0016: tmp = t_0 else: tmp = (-0.5 * (c / (b_2 / a))) / a return tmp
function code(a, b_2, c) t_0 = Float64(Float64(sqrt(Float64(a * Float64(-c))) - b_2) / a) tmp = 0.0 if (b_2 <= -4.6e-41) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 1.55e-113) tmp = t_0; elseif (b_2 <= 8e-63) tmp = Float64(Float64(Float64(0.5 * Float64(a * c)) / b_2) * Float64(1.0 / Float64(-a))); elseif (b_2 <= 0.0016) tmp = t_0; else tmp = Float64(Float64(-0.5 * Float64(c / Float64(b_2 / a))) / a); end return tmp end
function tmp_2 = code(a, b_2, c) t_0 = (sqrt((a * -c)) - b_2) / a; tmp = 0.0; if (b_2 <= -4.6e-41) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 1.55e-113) tmp = t_0; elseif (b_2 <= 8e-63) tmp = ((0.5 * (a * c)) / b_2) * (1.0 / -a); elseif (b_2 <= 0.0016) tmp = t_0; else tmp = (-0.5 * (c / (b_2 / a))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[b$95$2, -4.6e-41], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.55e-113], t$95$0, If[LessEqual[b$95$2, 8e-63], N[(N[(N[(0.5 * N[(a * c), $MachinePrecision]), $MachinePrecision] / b$95$2), $MachinePrecision] * N[(1.0 / (-a)), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 0.0016], t$95$0, N[(N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\
\mathbf{if}\;b_2 \leq -4.6 \cdot 10^{-41}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.55 \cdot 10^{-113}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b_2 \leq 8 \cdot 10^{-63}:\\
\;\;\;\;\frac{0.5 \cdot \left(a \cdot c\right)}{b_2} \cdot \frac{1}{-a}\\
\mathbf{elif}\;b_2 \leq 0.0016:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{c}{\frac{b_2}{a}}}{a}\\
\end{array}
\end{array}
if b_2 < -4.6000000000000002e-41Initial program 70.1%
+-commutative70.1%
unsub-neg70.1%
Simplified70.1%
Taylor expanded in b_2 around -inf 89.4%
if -4.6000000000000002e-41 < b_2 < 1.55000000000000006e-113 or 8.00000000000000053e-63 < b_2 < 0.00160000000000000008Initial program 81.9%
+-commutative81.9%
unsub-neg81.9%
Simplified81.9%
Taylor expanded in b_2 around 0 67.4%
associate-*r*67.4%
neg-mul-167.4%
Simplified67.4%
if 1.55000000000000006e-113 < b_2 < 8.00000000000000053e-63Initial program 57.7%
+-commutative57.7%
unsub-neg57.7%
Simplified57.7%
Taylor expanded in b_2 around inf 75.9%
associate-/l*58.3%
associate-/r/58.2%
Simplified58.2%
frac-2neg58.2%
div-inv58.2%
*-commutative58.2%
distribute-rgt-neg-in58.2%
metadata-eval58.2%
associate-*l/76.1%
associate-*l/76.1%
Applied egg-rr76.1%
if 0.00160000000000000008 < b_2 Initial program 30.7%
+-commutative30.7%
unsub-neg30.7%
Simplified30.7%
Taylor expanded in b_2 around inf 73.6%
associate-/l*78.8%
associate-/r/79.2%
Simplified79.2%
*-commutative79.2%
clear-num79.9%
un-div-inv79.9%
Applied egg-rr79.9%
Final simplification77.9%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -5e+67)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 11.0)
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
(/ (* -0.5 (/ c (/ b_2 a))) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e+67) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 11.0) {
tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = (-0.5 * (c / (b_2 / a))) / a;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-5d+67)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 11.0d0) then
tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a
else
tmp = ((-0.5d0) * (c / (b_2 / a))) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e+67) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 11.0) {
tmp = (Math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = (-0.5 * (c / (b_2 / a))) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e+67: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 11.0: tmp = (math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a else: tmp = (-0.5 * (c / (b_2 / a))) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e+67) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 11.0) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) - b_2) / a); else tmp = Float64(Float64(-0.5 * Float64(c / Float64(b_2 / a))) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e+67) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 11.0) tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a; else tmp = (-0.5 * (c / (b_2 / a))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e+67], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 11.0], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{+67}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 11:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{c}{\frac{b_2}{a}}}{a}\\
\end{array}
\end{array}
if b_2 < -4.99999999999999976e67Initial program 61.0%
+-commutative61.0%
unsub-neg61.0%
Simplified61.0%
Taylor expanded in b_2 around -inf 97.8%
if -4.99999999999999976e67 < b_2 < 11Initial program 80.1%
+-commutative80.1%
unsub-neg80.1%
Simplified80.1%
if 11 < b_2 Initial program 30.7%
+-commutative30.7%
unsub-neg30.7%
Simplified30.7%
Taylor expanded in b_2 around inf 73.6%
associate-/l*78.8%
associate-/r/79.2%
Simplified79.2%
*-commutative79.2%
clear-num79.9%
un-div-inv79.9%
Applied egg-rr79.9%
Final simplification83.1%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -4e-310)
(/ (* b_2 -2.0) a)
(if (<= b_2 7.6e+261)
(/ -0.5 (/ b_2 c))
(if (<= b_2 1.6e+294) (/ (- b_2 b_2) a) (* c (/ -0.5 b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 7.6e+261) {
tmp = -0.5 / (b_2 / c);
} else if (b_2 <= 1.6e+294) {
tmp = (b_2 - b_2) / a;
} else {
tmp = c * (-0.5 / b_2);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-4d-310)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 7.6d+261) then
tmp = (-0.5d0) / (b_2 / c)
else if (b_2 <= 1.6d+294) then
tmp = (b_2 - b_2) / a
else
tmp = c * ((-0.5d0) / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 7.6e+261) {
tmp = -0.5 / (b_2 / c);
} else if (b_2 <= 1.6e+294) {
tmp = (b_2 - b_2) / a;
} else {
tmp = c * (-0.5 / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4e-310: tmp = (b_2 * -2.0) / a elif b_2 <= 7.6e+261: tmp = -0.5 / (b_2 / c) elif b_2 <= 1.6e+294: tmp = (b_2 - b_2) / a else: tmp = c * (-0.5 / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4e-310) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 7.6e+261) tmp = Float64(-0.5 / Float64(b_2 / c)); elseif (b_2 <= 1.6e+294) tmp = Float64(Float64(b_2 - b_2) / a); else tmp = Float64(c * Float64(-0.5 / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4e-310) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 7.6e+261) tmp = -0.5 / (b_2 / c); elseif (b_2 <= 1.6e+294) tmp = (b_2 - b_2) / a; else tmp = c * (-0.5 / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4e-310], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 7.6e+261], N[(-0.5 / N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.6e+294], N[(N[(b$95$2 - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(c * N[(-0.5 / b$95$2), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 7.6 \cdot 10^{+261}:\\
\;\;\;\;\frac{-0.5}{\frac{b_2}{c}}\\
\mathbf{elif}\;b_2 \leq 1.6 \cdot 10^{+294}:\\
\;\;\;\;\frac{b_2 - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in b_2 around -inf 64.2%
*-commutative64.2%
Simplified64.2%
if -3.999999999999988e-310 < b_2 < 7.6000000000000003e261Initial program 52.9%
+-commutative52.9%
unsub-neg52.9%
Simplified52.9%
Taylor expanded in b_2 around inf 54.7%
associate-/l*56.4%
associate-/r/55.8%
Simplified55.8%
Taylor expanded in a around 0 47.2%
associate-*r/47.2%
associate-/l*47.8%
Simplified47.8%
if 7.6000000000000003e261 < b_2 < 1.5999999999999999e294Initial program 1.6%
+-commutative1.6%
unsub-neg1.6%
Simplified1.6%
Taylor expanded in b_2 around inf 98.4%
if 1.5999999999999999e294 < b_2 Initial program 1.6%
+-commutative1.6%
unsub-neg1.6%
Simplified1.6%
Taylor expanded in b_2 around inf 75.7%
associate-/l*99.6%
associate-/r/87.6%
Simplified87.6%
Taylor expanded in a around 0 88.2%
associate-*r/88.2%
associate-/l*88.0%
Simplified88.0%
associate-/r/88.2%
Applied egg-rr88.2%
Final simplification57.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-310) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (/ (* -0.5 (/ c (/ b_2 a))) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (-0.5 * (c / (b_2 / a))) / a;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-4d-310)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else
tmp = ((-0.5d0) * (c / (b_2 / a))) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (-0.5 * (c / (b_2 / a))) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4e-310: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) else: tmp = (-0.5 * (c / (b_2 / a))) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4e-310) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); else tmp = Float64(Float64(-0.5 * Float64(c / Float64(b_2 / a))) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4e-310) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); else tmp = (-0.5 * (c / (b_2 / a))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4e-310], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{c}{\frac{b_2}{a}}}{a}\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in b_2 around -inf 64.5%
if -3.999999999999988e-310 < b_2 Initial program 47.0%
+-commutative47.0%
unsub-neg47.0%
Simplified47.0%
Taylor expanded in b_2 around inf 56.7%
associate-/l*59.4%
associate-/r/59.6%
Simplified59.6%
*-commutative59.6%
clear-num60.0%
un-div-inv60.0%
Applied egg-rr60.0%
Final simplification61.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-310) (/ (* b_2 -2.0) a) (* (/ -0.5 a) (/ a (/ b_2 c)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (-0.5 / a) * (a / (b_2 / c));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-4d-310)) then
tmp = (b_2 * (-2.0d0)) / a
else
tmp = ((-0.5d0) / a) * (a / (b_2 / c))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (-0.5 / a) * (a / (b_2 / c));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4e-310: tmp = (b_2 * -2.0) / a else: tmp = (-0.5 / a) * (a / (b_2 / c)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4e-310) tmp = Float64(Float64(b_2 * -2.0) / a); else tmp = Float64(Float64(-0.5 / a) * Float64(a / Float64(b_2 / c))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4e-310) tmp = (b_2 * -2.0) / a; else tmp = (-0.5 / a) * (a / (b_2 / c)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4e-310], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(a / N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \frac{a}{\frac{b_2}{c}}\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in b_2 around -inf 64.2%
*-commutative64.2%
Simplified64.2%
if -3.999999999999988e-310 < b_2 Initial program 47.0%
+-commutative47.0%
unsub-neg47.0%
Simplified47.0%
Taylor expanded in b_2 around inf 56.7%
associate-/l*59.4%
associate-/r/59.6%
Simplified59.6%
associate-/l*59.4%
associate-/r/59.5%
associate-/r/59.4%
Applied egg-rr59.4%
Final simplification61.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 4.6e-263) (/ (* b_2 -2.0) a) (/ (* -0.5 (* c (/ a b_2))) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 4.6e-263) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (-0.5 * (c * (a / b_2))) / a;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= 4.6d-263) then
tmp = (b_2 * (-2.0d0)) / a
else
tmp = ((-0.5d0) * (c * (a / b_2))) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 4.6e-263) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (-0.5 * (c * (a / b_2))) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 4.6e-263: tmp = (b_2 * -2.0) / a else: tmp = (-0.5 * (c * (a / b_2))) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 4.6e-263) tmp = Float64(Float64(b_2 * -2.0) / a); else tmp = Float64(Float64(-0.5 * Float64(c * Float64(a / b_2))) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 4.6e-263) tmp = (b_2 * -2.0) / a; else tmp = (-0.5 * (c * (a / b_2))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 4.6e-263], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(-0.5 * N[(c * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 4.6 \cdot 10^{-263}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot \left(c \cdot \frac{a}{b_2}\right)}{a}\\
\end{array}
\end{array}
if b_2 < 4.60000000000000006e-263Initial program 76.2%
+-commutative76.2%
unsub-neg76.2%
Simplified76.2%
Taylor expanded in b_2 around -inf 62.6%
*-commutative62.6%
Simplified62.6%
if 4.60000000000000006e-263 < b_2 Initial program 45.9%
+-commutative45.9%
unsub-neg45.9%
Simplified45.9%
Taylor expanded in b_2 around inf 57.8%
associate-/l*60.6%
associate-/r/60.8%
Simplified60.8%
Final simplification61.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 4.6e-263) (/ (* b_2 -2.0) a) (/ (* -0.5 (/ c (/ b_2 a))) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 4.6e-263) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (-0.5 * (c / (b_2 / a))) / a;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= 4.6d-263) then
tmp = (b_2 * (-2.0d0)) / a
else
tmp = ((-0.5d0) * (c / (b_2 / a))) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 4.6e-263) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (-0.5 * (c / (b_2 / a))) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 4.6e-263: tmp = (b_2 * -2.0) / a else: tmp = (-0.5 * (c / (b_2 / a))) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 4.6e-263) tmp = Float64(Float64(b_2 * -2.0) / a); else tmp = Float64(Float64(-0.5 * Float64(c / Float64(b_2 / a))) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 4.6e-263) tmp = (b_2 * -2.0) / a; else tmp = (-0.5 * (c / (b_2 / a))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 4.6e-263], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 4.6 \cdot 10^{-263}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{c}{\frac{b_2}{a}}}{a}\\
\end{array}
\end{array}
if b_2 < 4.60000000000000006e-263Initial program 76.2%
+-commutative76.2%
unsub-neg76.2%
Simplified76.2%
Taylor expanded in b_2 around -inf 62.6%
*-commutative62.6%
Simplified62.6%
if 4.60000000000000006e-263 < b_2 Initial program 45.9%
+-commutative45.9%
unsub-neg45.9%
Simplified45.9%
Taylor expanded in b_2 around inf 57.8%
associate-/l*60.6%
associate-/r/60.8%
Simplified60.8%
*-commutative60.8%
clear-num61.2%
un-div-inv61.2%
Applied egg-rr61.2%
Final simplification61.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-310) (/ (* b_2 -2.0) a) (/ -0.5 (/ b_2 c))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = -0.5 / (b_2 / c);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-4d-310)) then
tmp = (b_2 * (-2.0d0)) / a
else
tmp = (-0.5d0) / (b_2 / c)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = -0.5 / (b_2 / c);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4e-310: tmp = (b_2 * -2.0) / a else: tmp = -0.5 / (b_2 / c) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4e-310) tmp = Float64(Float64(b_2 * -2.0) / a); else tmp = Float64(-0.5 / Float64(b_2 / c)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4e-310) tmp = (b_2 * -2.0) / a; else tmp = -0.5 / (b_2 / c); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4e-310], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 / N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b_2}{c}}\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in b_2 around -inf 64.2%
*-commutative64.2%
Simplified64.2%
if -3.999999999999988e-310 < b_2 Initial program 47.0%
+-commutative47.0%
unsub-neg47.0%
Simplified47.0%
Taylor expanded in b_2 around inf 56.7%
associate-/l*59.4%
associate-/r/59.6%
Simplified59.6%
Taylor expanded in a around 0 49.4%
associate-*r/49.4%
associate-/l*49.9%
Simplified49.9%
Final simplification56.1%
(FPCore (a b_2 c) :precision binary64 (* c (/ -0.5 b_2)))
double code(double a, double b_2, double c) {
return c * (-0.5 / b_2);
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = c * ((-0.5d0) / b_2)
end function
public static double code(double a, double b_2, double c) {
return c * (-0.5 / b_2);
}
def code(a, b_2, c): return c * (-0.5 / b_2)
function code(a, b_2, c) return Float64(c * Float64(-0.5 / b_2)) end
function tmp = code(a, b_2, c) tmp = c * (-0.5 / b_2); end
code[a_, b$95$2_, c_] := N[(c * N[(-0.5 / b$95$2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{-0.5}{b_2}
\end{array}
Initial program 59.2%
+-commutative59.2%
unsub-neg59.2%
Simplified59.2%
Taylor expanded in b_2 around inf 33.3%
associate-/l*34.8%
associate-/r/34.9%
Simplified34.9%
Taylor expanded in a around 0 29.1%
associate-*r/29.1%
associate-/l*29.4%
Simplified29.4%
associate-/r/29.1%
Applied egg-rr29.1%
Final simplification29.1%
(FPCore (a b_2 c) :precision binary64 (/ -0.5 (/ b_2 c)))
double code(double a, double b_2, double c) {
return -0.5 / (b_2 / c);
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-0.5d0) / (b_2 / c)
end function
public static double code(double a, double b_2, double c) {
return -0.5 / (b_2 / c);
}
def code(a, b_2, c): return -0.5 / (b_2 / c)
function code(a, b_2, c) return Float64(-0.5 / Float64(b_2 / c)) end
function tmp = code(a, b_2, c) tmp = -0.5 / (b_2 / c); end
code[a_, b$95$2_, c_] := N[(-0.5 / N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{\frac{b_2}{c}}
\end{array}
Initial program 59.2%
+-commutative59.2%
unsub-neg59.2%
Simplified59.2%
Taylor expanded in b_2 around inf 33.3%
associate-/l*34.8%
associate-/r/34.9%
Simplified34.9%
Taylor expanded in a around 0 29.1%
associate-*r/29.1%
associate-/l*29.4%
Simplified29.4%
Final simplification29.4%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (* (sqrt (fabs a)) (sqrt (fabs c))))
(t_1
(if (== (copysign a c) a)
(* (sqrt (- (fabs b_2) t_0)) (sqrt (+ (fabs b_2) t_0)))
(hypot b_2 t_0))))
(if (< b_2 0.0) (/ (- t_1 b_2) a) (/ (- c) (+ b_2 t_1)))))
double code(double a, double b_2, double c) {
double t_0 = sqrt(fabs(a)) * sqrt(fabs(c));
double tmp;
if (copysign(a, c) == a) {
tmp = sqrt((fabs(b_2) - t_0)) * sqrt((fabs(b_2) + t_0));
} else {
tmp = hypot(b_2, t_0);
}
double t_1 = tmp;
double tmp_1;
if (b_2 < 0.0) {
tmp_1 = (t_1 - b_2) / a;
} else {
tmp_1 = -c / (b_2 + t_1);
}
return tmp_1;
}
public static double code(double a, double b_2, double c) {
double t_0 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
double tmp;
if (Math.copySign(a, c) == a) {
tmp = Math.sqrt((Math.abs(b_2) - t_0)) * Math.sqrt((Math.abs(b_2) + t_0));
} else {
tmp = Math.hypot(b_2, t_0);
}
double t_1 = tmp;
double tmp_1;
if (b_2 < 0.0) {
tmp_1 = (t_1 - b_2) / a;
} else {
tmp_1 = -c / (b_2 + t_1);
}
return tmp_1;
}
def code(a, b_2, c): t_0 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c)) tmp = 0 if math.copysign(a, c) == a: tmp = math.sqrt((math.fabs(b_2) - t_0)) * math.sqrt((math.fabs(b_2) + t_0)) else: tmp = math.hypot(b_2, t_0) t_1 = tmp tmp_1 = 0 if b_2 < 0.0: tmp_1 = (t_1 - b_2) / a else: tmp_1 = -c / (b_2 + t_1) return tmp_1
function code(a, b_2, c) t_0 = Float64(sqrt(abs(a)) * sqrt(abs(c))) tmp = 0.0 if (copysign(a, c) == a) tmp = Float64(sqrt(Float64(abs(b_2) - t_0)) * sqrt(Float64(abs(b_2) + t_0))); else tmp = hypot(b_2, t_0); end t_1 = tmp tmp_1 = 0.0 if (b_2 < 0.0) tmp_1 = Float64(Float64(t_1 - b_2) / a); else tmp_1 = Float64(Float64(-c) / Float64(b_2 + t_1)); end return tmp_1 end
function tmp_3 = code(a, b_2, c) t_0 = sqrt(abs(a)) * sqrt(abs(c)); tmp = 0.0; if ((sign(c) * abs(a)) == a) tmp = sqrt((abs(b_2) - t_0)) * sqrt((abs(b_2) + t_0)); else tmp = hypot(b_2, t_0); end t_1 = tmp; tmp_2 = 0.0; if (b_2 < 0.0) tmp_2 = (t_1 - b_2) / a; else tmp_2 = -c / (b_2 + t_1); end tmp_3 = tmp_2; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], N[(N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[b$95$2 ^ 2 + t$95$0 ^ 2], $MachinePrecision]]}, If[Less[b$95$2, 0.0], N[(N[(t$95$1 - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[((-c) / N[(b$95$2 + t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_1 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\sqrt{\left|b_2\right| - t_0} \cdot \sqrt{\left|b_2\right| + t_0}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(b_2, t_0\right)\\
\end{array}\\
\mathbf{if}\;b_2 < 0:\\
\;\;\;\;\frac{t_1 - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b_2 + t_1}\\
\end{array}
\end{array}
herbie shell --seed 2024024
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
:herbie-expected 10
:herbie-target
(if (< b_2 0.0) (/ (- (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c))))) b_2) a) (/ (- c) (+ b_2 (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c))))))))
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))