
(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 10 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 -1.02e-131)
(/ (* -0.5 c) b_2)
(if (<= b_2 2.65e-30)
(-
(* (/ -1.0 (pow (cbrt a) 2.0)) (/ b_2 (cbrt a)))
(/ (hypot b_2 (sqrt (* c (- a)))) a))
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.02e-131) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2.65e-30) {
tmp = ((-1.0 / pow(cbrt(a), 2.0)) * (b_2 / cbrt(a))) - (hypot(b_2, sqrt((c * -a))) / a);
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.02e-131) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2.65e-30) {
tmp = ((-1.0 / Math.pow(Math.cbrt(a), 2.0)) * (b_2 / Math.cbrt(a))) - (Math.hypot(b_2, Math.sqrt((c * -a))) / a);
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.02e-131) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 2.65e-30) tmp = Float64(Float64(Float64(-1.0 / (cbrt(a) ^ 2.0)) * Float64(b_2 / cbrt(a))) - Float64(hypot(b_2, sqrt(Float64(c * Float64(-a)))) / a)); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.02e-131], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 2.65e-30], N[(N[(N[(-1.0 / N[Power[N[Power[a, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(b$95$2 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[b$95$2 ^ 2 + N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.02 \cdot 10^{-131}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 2.65 \cdot 10^{-30}:\\
\;\;\;\;\frac{-1}{{\left(\sqrt[3]{a}\right)}^{2}} \cdot \frac{b\_2}{\sqrt[3]{a}} - \frac{\mathsf{hypot}\left(b\_2, \sqrt{c \cdot \left(-a\right)}\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -1.02000000000000001e-131Initial program 21.6%
Taylor expanded in b_2 around -inf 81.8%
associate-*r/81.8%
Simplified81.8%
if -1.02000000000000001e-131 < b_2 < 2.64999999999999987e-30Initial program 76.9%
div-sub76.9%
neg-mul-176.9%
add-cube-cbrt76.7%
times-frac76.7%
fma-neg76.8%
pow276.8%
sub-neg76.8%
add-sqr-sqrt75.3%
hypot-define81.3%
distribute-rgt-neg-in81.3%
Applied egg-rr81.3%
fma-undefine81.2%
unsub-neg81.2%
Simplified81.2%
if 2.64999999999999987e-30 < b_2 Initial program 64.3%
Taylor expanded in c around 0 93.4%
Final simplification85.4%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -5.2e-131)
(/ (* -0.5 c) b_2)
(if (<= b_2 6e+76)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.2e-131) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 6e+76) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / 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 <= (-5.2d-131)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 6d+76) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.2e-131) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 6e+76) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5.2e-131: tmp = (-0.5 * c) / b_2 elif b_2 <= 6e+76: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5.2e-131) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 6e+76) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5.2e-131) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 6e+76) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5.2e-131], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 6e+76], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.2 \cdot 10^{-131}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 6 \cdot 10^{+76}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -5.19999999999999993e-131Initial program 21.6%
Taylor expanded in b_2 around -inf 81.8%
associate-*r/81.8%
Simplified81.8%
if -5.19999999999999993e-131 < b_2 < 5.9999999999999996e76Initial program 81.6%
if 5.9999999999999996e76 < b_2 Initial program 52.3%
Taylor expanded in c around 0 95.5%
Final simplification85.0%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -5.3e-131)
(/ (* -0.5 c) b_2)
(if (<= b_2 7.5e-77)
(/ (- (- b_2) (sqrt (* c (- a)))) a)
(/ (* b_2 -2.0) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.3e-131) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 7.5e-77) {
tmp = (-b_2 - sqrt((c * -a))) / a;
} else {
tmp = (b_2 * -2.0) / 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 <= (-5.3d-131)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 7.5d-77) then
tmp = (-b_2 - sqrt((c * -a))) / a
else
tmp = (b_2 * (-2.0d0)) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.3e-131) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 7.5e-77) {
tmp = (-b_2 - Math.sqrt((c * -a))) / a;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5.3e-131: tmp = (-0.5 * c) / b_2 elif b_2 <= 7.5e-77: tmp = (-b_2 - math.sqrt((c * -a))) / a else: tmp = (b_2 * -2.0) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5.3e-131) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 7.5e-77) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(c * Float64(-a)))) / a); else tmp = Float64(Float64(b_2 * -2.0) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5.3e-131) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 7.5e-77) tmp = (-b_2 - sqrt((c * -a))) / a; else tmp = (b_2 * -2.0) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5.3e-131], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 7.5e-77], N[(N[((-b$95$2) - N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.3 \cdot 10^{-131}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\mathbf{elif}\;b\_2 \leq 7.5 \cdot 10^{-77}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -5.30000000000000018e-131Initial program 21.6%
Taylor expanded in b_2 around -inf 81.8%
associate-*r/81.8%
Simplified81.8%
if -5.30000000000000018e-131 < b_2 < 7.5000000000000006e-77Initial program 75.8%
Taylor expanded in b_2 around 0 71.8%
mul-1-neg71.8%
distribute-rgt-neg-out71.8%
Simplified71.8%
if 7.5000000000000006e-77 < b_2 Initial program 66.0%
Taylor expanded in b_2 around inf 90.8%
*-commutative90.8%
Simplified90.8%
Final simplification82.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-310) (/ (* -0.5 c) b_2) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / 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 = ((-0.5d0) * c) / b_2
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / 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 = (-0.5 * c) / b_2;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4e-310: tmp = (-0.5 * c) / b_2 else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4e-310) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4e-310) tmp = (-0.5 * c) / b_2; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4e-310], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 34.1%
Taylor expanded in b_2 around -inf 67.9%
associate-*r/67.9%
Simplified67.9%
if -3.999999999999988e-310 < b_2 Initial program 66.9%
Taylor expanded in c around 0 72.8%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.45e-296) (/ (* -0.5 c) b_2) (/ (* b_2 -2.0) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.45e-296) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (b_2 * -2.0) / 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 <= (-1.45d-296)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = (b_2 * (-2.0d0)) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.45e-296) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.45e-296: tmp = (-0.5 * c) / b_2 else: tmp = (b_2 * -2.0) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.45e-296) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(b_2 * -2.0) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.45e-296) tmp = (-0.5 * c) / b_2; else tmp = (b_2 * -2.0) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.45e-296], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.45 \cdot 10^{-296}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -1.44999999999999991e-296Initial program 32.1%
Taylor expanded in b_2 around -inf 70.0%
associate-*r/70.0%
Simplified70.0%
if -1.44999999999999991e-296 < b_2 Initial program 67.9%
Taylor expanded in b_2 around inf 70.7%
*-commutative70.7%
Simplified70.7%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.45e-296) (/ (* -0.5 c) b_2) (/ b_2 (- a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.45e-296) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = 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 <= (-1.45d-296)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = 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 <= -1.45e-296) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = b_2 / -a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.45e-296: tmp = (-0.5 * c) / b_2 else: tmp = b_2 / -a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.45e-296) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(b_2 / Float64(-a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.45e-296) tmp = (-0.5 * c) / b_2; else tmp = b_2 / -a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.45e-296], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(b$95$2 / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.45 \cdot 10^{-296}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{-a}\\
\end{array}
\end{array}
if b_2 < -1.44999999999999991e-296Initial program 32.1%
Taylor expanded in b_2 around -inf 70.0%
associate-*r/70.0%
Simplified70.0%
if -1.44999999999999991e-296 < b_2 Initial program 67.9%
prod-diff67.7%
*-commutative67.7%
fma-neg67.7%
prod-diff67.7%
*-commutative67.7%
fma-neg67.7%
associate-+l+67.7%
pow267.7%
*-commutative67.7%
fma-undefine67.7%
distribute-lft-neg-in67.7%
*-commutative67.7%
distribute-rgt-neg-in67.7%
fma-define67.7%
*-commutative67.7%
fma-undefine67.7%
distribute-lft-neg-in67.7%
*-commutative67.7%
distribute-rgt-neg-in67.7%
Applied egg-rr67.7%
count-267.7%
Simplified67.7%
Taylor expanded in c around inf 24.1%
mul-1-neg24.1%
*-commutative24.1%
distribute-rgt1-in24.1%
metadata-eval24.1%
Simplified24.1%
Taylor expanded in b_2 around inf 25.3%
mul-1-neg25.3%
Simplified25.3%
Final simplification47.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4.5e-292) (/ -0.5 (/ b_2 c)) (/ b_2 (- a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.5e-292) {
tmp = -0.5 / (b_2 / c);
} else {
tmp = 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.5d-292)) then
tmp = (-0.5d0) / (b_2 / c)
else
tmp = 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.5e-292) {
tmp = -0.5 / (b_2 / c);
} else {
tmp = b_2 / -a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4.5e-292: tmp = -0.5 / (b_2 / c) else: tmp = b_2 / -a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4.5e-292) tmp = Float64(-0.5 / Float64(b_2 / c)); else tmp = Float64(b_2 / Float64(-a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4.5e-292) tmp = -0.5 / (b_2 / c); else tmp = b_2 / -a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4.5e-292], N[(-0.5 / N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision], N[(b$95$2 / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4.5 \cdot 10^{-292}:\\
\;\;\;\;\frac{-0.5}{\frac{b\_2}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{-a}\\
\end{array}
\end{array}
if b_2 < -4.49999999999999956e-292Initial program 32.1%
Taylor expanded in b_2 around -inf 70.0%
associate-*r/70.0%
Simplified70.0%
add-cbrt-cube39.7%
pow1/332.6%
pow332.6%
associate-/l*32.6%
Applied egg-rr32.6%
unpow1/339.7%
rem-cbrt-cube70.0%
clear-num69.5%
un-div-inv69.5%
Applied egg-rr69.5%
if -4.49999999999999956e-292 < b_2 Initial program 67.9%
prod-diff67.7%
*-commutative67.7%
fma-neg67.7%
prod-diff67.7%
*-commutative67.7%
fma-neg67.7%
associate-+l+67.7%
pow267.7%
*-commutative67.7%
fma-undefine67.7%
distribute-lft-neg-in67.7%
*-commutative67.7%
distribute-rgt-neg-in67.7%
fma-define67.7%
*-commutative67.7%
fma-undefine67.7%
distribute-lft-neg-in67.7%
*-commutative67.7%
distribute-rgt-neg-in67.7%
Applied egg-rr67.7%
count-267.7%
Simplified67.7%
Taylor expanded in c around inf 24.1%
mul-1-neg24.1%
*-commutative24.1%
distribute-rgt1-in24.1%
metadata-eval24.1%
Simplified24.1%
Taylor expanded in b_2 around inf 25.3%
mul-1-neg25.3%
Simplified25.3%
Final simplification47.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -3.8e+39) (* 0.5 (/ c b_2)) (/ b_2 (- a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.8e+39) {
tmp = 0.5 * (c / b_2);
} else {
tmp = 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 <= (-3.8d+39)) then
tmp = 0.5d0 * (c / b_2)
else
tmp = 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 <= -3.8e+39) {
tmp = 0.5 * (c / b_2);
} else {
tmp = b_2 / -a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.8e+39: tmp = 0.5 * (c / b_2) else: tmp = b_2 / -a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.8e+39) tmp = Float64(0.5 * Float64(c / b_2)); else tmp = Float64(b_2 / Float64(-a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.8e+39) tmp = 0.5 * (c / b_2); else tmp = b_2 / -a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.8e+39], N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(b$95$2 / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -3.8 \cdot 10^{+39}:\\
\;\;\;\;0.5 \cdot \frac{c}{b\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2}{-a}\\
\end{array}
\end{array}
if b_2 < -3.7999999999999998e39Initial program 12.7%
Taylor expanded in c around 0 2.4%
Taylor expanded in b_2 around 0 35.3%
if -3.7999999999999998e39 < b_2 Initial program 65.4%
prod-diff65.2%
*-commutative65.2%
fma-neg65.2%
prod-diff65.2%
*-commutative65.2%
fma-neg65.2%
associate-+l+65.1%
pow265.1%
*-commutative65.1%
fma-undefine65.2%
distribute-lft-neg-in65.2%
*-commutative65.2%
distribute-rgt-neg-in65.2%
fma-define65.1%
*-commutative65.1%
fma-undefine65.2%
distribute-lft-neg-in65.2%
*-commutative65.2%
distribute-rgt-neg-in65.2%
Applied egg-rr65.1%
count-265.1%
Simplified65.1%
Taylor expanded in c around inf 22.3%
mul-1-neg22.3%
*-commutative22.3%
distribute-rgt1-in22.3%
metadata-eval22.3%
Simplified22.3%
Taylor expanded in b_2 around inf 18.8%
mul-1-neg18.8%
Simplified18.8%
Final simplification23.6%
(FPCore (a b_2 c) :precision binary64 (/ b_2 (- a)))
double code(double a, double b_2, double c) {
return b_2 / -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 / -a
end function
public static double code(double a, double b_2, double c) {
return b_2 / -a;
}
def code(a, b_2, c): return b_2 / -a
function code(a, b_2, c) return Float64(b_2 / Float64(-a)) end
function tmp = code(a, b_2, c) tmp = b_2 / -a; end
code[a_, b$95$2_, c_] := N[(b$95$2 / (-a)), $MachinePrecision]
\begin{array}{l}
\\
\frac{b\_2}{-a}
\end{array}
Initial program 50.1%
prod-diff49.9%
*-commutative49.9%
fma-neg49.9%
prod-diff49.9%
*-commutative49.9%
fma-neg49.9%
associate-+l+49.9%
pow249.9%
*-commutative49.9%
fma-undefine49.9%
distribute-lft-neg-in49.9%
*-commutative49.9%
distribute-rgt-neg-in49.9%
fma-define49.9%
*-commutative49.9%
fma-undefine49.9%
distribute-lft-neg-in49.9%
*-commutative49.9%
distribute-rgt-neg-in49.9%
Applied egg-rr49.9%
count-249.9%
Simplified49.9%
Taylor expanded in c around inf 17.1%
mul-1-neg17.1%
*-commutative17.1%
distribute-rgt1-in17.1%
metadata-eval17.1%
Simplified17.1%
Taylor expanded in b_2 around inf 14.1%
mul-1-neg14.1%
Simplified14.1%
Final simplification14.1%
(FPCore (a b_2 c) :precision binary64 (/ b_2 a))
double code(double a, double b_2, double c) {
return b_2 / 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 / a
end function
public static double code(double a, double b_2, double c) {
return b_2 / a;
}
def code(a, b_2, c): return b_2 / a
function code(a, b_2, c) return Float64(b_2 / a) end
function tmp = code(a, b_2, c) tmp = b_2 / a; end
code[a_, b$95$2_, c_] := N[(b$95$2 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{b\_2}{a}
\end{array}
Initial program 50.1%
prod-diff49.9%
*-commutative49.9%
fma-neg49.9%
prod-diff49.9%
*-commutative49.9%
fma-neg49.9%
associate-+l+49.9%
pow249.9%
*-commutative49.9%
fma-undefine49.9%
distribute-lft-neg-in49.9%
*-commutative49.9%
distribute-rgt-neg-in49.9%
fma-define49.9%
*-commutative49.9%
fma-undefine49.9%
distribute-lft-neg-in49.9%
*-commutative49.9%
distribute-rgt-neg-in49.9%
Applied egg-rr49.9%
count-249.9%
Simplified49.9%
Taylor expanded in c around inf 17.1%
mul-1-neg17.1%
*-commutative17.1%
distribute-rgt1-in17.1%
metadata-eval17.1%
Simplified17.1%
Taylor expanded in b_2 around inf 14.1%
mul-1-neg14.1%
Simplified14.1%
add-sqr-sqrt1.4%
sqrt-unprod2.0%
sqr-neg2.0%
sqrt-unprod0.6%
add-sqr-sqrt2.4%
*-un-lft-identity2.4%
Applied egg-rr2.4%
*-lft-identity2.4%
Simplified2.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) (/ c (- t_1 b_2)) (/ (+ b_2 t_1) (- a)))))
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 = c / (t_1 - b_2);
} else {
tmp_1 = (b_2 + t_1) / -a;
}
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 = c / (t_1 - b_2);
} else {
tmp_1 = (b_2 + t_1) / -a;
}
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 = c / (t_1 - b_2) else: tmp_1 = (b_2 + t_1) / -a 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(c / Float64(t_1 - b_2)); else tmp_1 = Float64(Float64(b_2 + t_1) / Float64(-a)); 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 = c / (t_1 - b_2); else tmp_2 = (b_2 + t_1) / -a; 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[(c / N[(t$95$1 - b$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(b$95$2 + t$95$1), $MachinePrecision] / (-a)), $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{c}{t\_1 - b\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2 + t\_1}{-a}\\
\end{array}
\end{array}
herbie shell --seed 2024116
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
:herbie-expected 10
:alt
(! :herbie-platform default (let ((sqtD (let ((x (* (sqrt (fabs a)) (sqrt (fabs c))))) (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) x)) (sqrt (+ (fabs b_2) x))) (hypot b_2 x))))) (if (< b_2 0) (/ c (- sqtD b_2)) (/ (+ b_2 sqtD) (- a)))))
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))