
(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 9 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 -2.15e-32)
(/ (* -0.5 c) b_2)
(if (<= b_2 1.2e+20)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (/ (* c 0.5) (* (cbrt b_2) (cbrt (* b_2 b_2))))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.15e-32) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.2e+20) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + ((c * 0.5) / (cbrt(b_2) * cbrt((b_2 * b_2))));
}
return tmp;
}
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.15e-32) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.2e+20) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + ((c * 0.5) / (Math.cbrt(b_2) * Math.cbrt((b_2 * b_2))));
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.15e-32) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 1.2e+20) 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(Float64(c * 0.5) / Float64(cbrt(b_2) * cbrt(Float64(b_2 * b_2))))); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.15e-32], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1.2e+20], 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[(N[(c * 0.5), $MachinePrecision] / N[(N[Power[b$95$2, 1/3], $MachinePrecision] * N[Power[N[(b$95$2 * b$95$2), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.15 \cdot 10^{-32}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.2 \cdot 10^{+20}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c \cdot 0.5}{\sqrt[3]{b_2} \cdot \sqrt[3]{b_2 \cdot b_2}}\\
\end{array}
\end{array}
if b_2 < -2.14999999999999995e-32Initial program 12.8%
Taylor expanded in b_2 around -inf 87.2%
associate-*r/87.2%
Simplified87.2%
if -2.14999999999999995e-32 < b_2 < 1.2e20Initial program 79.0%
if 1.2e20 < b_2 Initial program 63.4%
Taylor expanded in b_2 around inf 97.3%
associate-*r/97.3%
add-cube-cbrt97.3%
associate-/r*97.3%
*-commutative97.3%
cbrt-unprod97.3%
Applied egg-rr97.3%
associate-/l/97.3%
Simplified97.3%
Final simplification86.9%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -8e-32)
(/ (* -0.5 c) b_2)
(if (<= b_2 1.26e+20)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(* -2.0 (/ b_2 a)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8e-32) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.26e+20) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = -2.0 * (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 <= (-8d-32)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 1.26d+20) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = (-2.0d0) * (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 <= -8e-32) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.26e+20) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -8e-32: tmp = (-0.5 * c) / b_2 elif b_2 <= 1.26e+20: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -8e-32) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 1.26e+20) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -8e-32) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 1.26e+20) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8e-32], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1.26e+20], 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[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -8 \cdot 10^{-32}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.26 \cdot 10^{+20}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\end{array}
\end{array}
if b_2 < -8.00000000000000045e-32Initial program 12.8%
Taylor expanded in b_2 around -inf 87.2%
associate-*r/87.2%
Simplified87.2%
if -8.00000000000000045e-32 < b_2 < 1.26e20Initial program 79.0%
if 1.26e20 < b_2 Initial program 63.4%
Taylor expanded in b_2 around inf 97.3%
Final simplification86.9%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -2.9e-32)
(/ (* -0.5 c) b_2)
(if (<= b_2 3.3e-37)
(/ (- (- b_2) (sqrt (* c (- a)))) a)
(/ (- (- b_2) (+ b_2 (* -0.5 (/ c (/ b_2 a))))) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.9e-32) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 3.3e-37) {
tmp = (-b_2 - sqrt((c * -a))) / a;
} else {
tmp = (-b_2 - (b_2 + (-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 <= (-2.9d-32)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 3.3d-37) then
tmp = (-b_2 - sqrt((c * -a))) / a
else
tmp = (-b_2 - (b_2 + ((-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 <= -2.9e-32) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 3.3e-37) {
tmp = (-b_2 - Math.sqrt((c * -a))) / a;
} else {
tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.9e-32: tmp = (-0.5 * c) / b_2 elif b_2 <= 3.3e-37: tmp = (-b_2 - math.sqrt((c * -a))) / a else: tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.9e-32) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 3.3e-37) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(c * Float64(-a)))) / a); else tmp = Float64(Float64(Float64(-b_2) - Float64(b_2 + 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 <= -2.9e-32) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 3.3e-37) tmp = (-b_2 - sqrt((c * -a))) / a; else tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.9e-32], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 3.3e-37], N[(N[((-b$95$2) - N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[((-b$95$2) - N[(b$95$2 + N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.9 \cdot 10^{-32}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 3.3 \cdot 10^{-37}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \frac{c}{\frac{b_2}{a}}\right)}{a}\\
\end{array}
\end{array}
if b_2 < -2.89999999999999996e-32Initial program 12.8%
Taylor expanded in b_2 around -inf 87.2%
associate-*r/87.2%
Simplified87.2%
if -2.89999999999999996e-32 < b_2 < 3.29999999999999982e-37Initial program 76.3%
Taylor expanded in b_2 around 0 69.6%
mul-1-neg69.6%
distribute-rgt-neg-out69.6%
Simplified69.6%
if 3.29999999999999982e-37 < b_2 Initial program 68.3%
Taylor expanded in b_2 around inf 90.5%
associate-/l*93.0%
Simplified93.0%
Final simplification83.1%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -7e-31)
(/ (* -0.5 c) b_2)
(if (<= b_2 1.15e-36)
(/ (- (sqrt (* c (- a)))) a)
(/ (- (- b_2) (+ b_2 (* -0.5 (/ c (/ b_2 a))))) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7e-31) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.15e-36) {
tmp = -sqrt((c * -a)) / a;
} else {
tmp = (-b_2 - (b_2 + (-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 <= (-7d-31)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 1.15d-36) then
tmp = -sqrt((c * -a)) / a
else
tmp = (-b_2 - (b_2 + ((-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 <= -7e-31) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.15e-36) {
tmp = -Math.sqrt((c * -a)) / a;
} else {
tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -7e-31: tmp = (-0.5 * c) / b_2 elif b_2 <= 1.15e-36: tmp = -math.sqrt((c * -a)) / a else: tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -7e-31) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 1.15e-36) tmp = Float64(Float64(-sqrt(Float64(c * Float64(-a)))) / a); else tmp = Float64(Float64(Float64(-b_2) - Float64(b_2 + 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 <= -7e-31) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 1.15e-36) tmp = -sqrt((c * -a)) / a; else tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7e-31], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1.15e-36], N[((-N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision]) / a), $MachinePrecision], N[(N[((-b$95$2) - N[(b$95$2 + N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -7 \cdot 10^{-31}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.15 \cdot 10^{-36}:\\
\;\;\;\;\frac{-\sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \frac{c}{\frac{b_2}{a}}\right)}{a}\\
\end{array}
\end{array}
if b_2 < -6.99999999999999971e-31Initial program 12.8%
Taylor expanded in b_2 around -inf 87.2%
associate-*r/87.2%
Simplified87.2%
if -6.99999999999999971e-31 < b_2 < 1.14999999999999998e-36Initial program 76.3%
prod-diff76.0%
*-commutative76.0%
fma-neg76.0%
prod-diff76.0%
*-commutative76.0%
fma-neg76.0%
associate-+l+75.9%
*-commutative75.9%
fma-udef76.0%
distribute-lft-neg-in76.0%
*-commutative76.0%
distribute-rgt-neg-in76.0%
fma-def75.9%
*-commutative75.9%
fma-udef76.0%
distribute-lft-neg-in76.0%
*-commutative76.0%
distribute-rgt-neg-in76.0%
fma-def75.9%
Applied egg-rr75.9%
*-commutative75.9%
count-275.9%
*-commutative75.9%
Simplified75.9%
Taylor expanded in b_2 around 0 69.2%
mul-1-neg69.2%
distribute-lft1-in69.2%
metadata-eval69.2%
mul0-lft69.5%
metadata-eval69.5%
neg-sub069.5%
*-commutative69.5%
distribute-rgt-neg-in69.5%
Simplified69.5%
if 1.14999999999999998e-36 < b_2 Initial program 68.3%
Taylor expanded in b_2 around inf 90.5%
associate-/l*93.0%
Simplified93.0%
Final simplification83.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-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 <= -5e-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 <= (-5d-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 <= -5e-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 <= -5e-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 <= -5e-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 <= -5e-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, -5e-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 -5 \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 < -4.999999999999985e-310Initial program 31.7%
Taylor expanded in b_2 around -inf 66.4%
associate-*r/66.4%
Simplified66.4%
if -4.999999999999985e-310 < b_2 Initial program 74.1%
Taylor expanded in b_2 around inf 68.6%
Final simplification67.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.4e-308) (/ 0.0 a) (* -2.0 (/ b_2 a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.4e-308) {
tmp = 0.0 / a;
} else {
tmp = -2.0 * (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 <= (-2.4d-308)) then
tmp = 0.0d0 / a
else
tmp = (-2.0d0) * (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 <= -2.4e-308) {
tmp = 0.0 / a;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.4e-308: tmp = 0.0 / a else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.4e-308) tmp = Float64(0.0 / a); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2.4e-308) tmp = 0.0 / a; else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.4e-308], N[(0.0 / a), $MachinePrecision], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.4 \cdot 10^{-308}:\\
\;\;\;\;\frac{0}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\end{array}
\end{array}
if b_2 < -2.40000000000000008e-308Initial program 31.2%
add-sqr-sqrt30.1%
pow230.1%
pow1/230.1%
sqrt-pow130.2%
metadata-eval30.2%
Applied egg-rr30.2%
Taylor expanded in b_2 around -inf 22.5%
distribute-lft1-in22.5%
metadata-eval22.5%
mul0-lft22.5%
Simplified22.5%
if -2.40000000000000008e-308 < b_2 Initial program 74.3%
Taylor expanded in b_2 around inf 68.0%
Final simplification44.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -3.2e-308) (/ (* -0.5 c) b_2) (* -2.0 (/ b_2 a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-308) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -2.0 * (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.2d-308)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = (-2.0d0) * (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.2e-308) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.2e-308: tmp = (-0.5 * c) / b_2 else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.2e-308) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.2e-308) tmp = (-0.5 * c) / b_2; else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.2e-308], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-308}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\end{array}
\end{array}
if b_2 < -3.2000000000000001e-308Initial program 31.2%
Taylor expanded in b_2 around -inf 66.8%
associate-*r/66.9%
Simplified66.9%
if -3.2000000000000001e-308 < b_2 Initial program 74.3%
Taylor expanded in b_2 around inf 68.0%
Final simplification67.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.4e-308) (/ 0.0 a) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.4e-308) {
tmp = 0.0 / a;
} 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 <= (-2.4d-308)) then
tmp = 0.0d0 / a
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 <= -2.4e-308) {
tmp = 0.0 / a;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.4e-308: tmp = 0.0 / a else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.4e-308) tmp = Float64(0.0 / a); else tmp = Float64(Float64(-b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2.4e-308) tmp = 0.0 / a; else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.4e-308], N[(0.0 / a), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.4 \cdot 10^{-308}:\\
\;\;\;\;\frac{0}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -2.40000000000000008e-308Initial program 31.2%
add-sqr-sqrt30.1%
pow230.1%
pow1/230.1%
sqrt-pow130.2%
metadata-eval30.2%
Applied egg-rr30.2%
Taylor expanded in b_2 around -inf 22.5%
distribute-lft1-in22.5%
metadata-eval22.5%
mul0-lft22.5%
Simplified22.5%
if -2.40000000000000008e-308 < b_2 Initial program 74.3%
Taylor expanded in b_2 around 0 47.6%
mul-1-neg47.6%
distribute-rgt-neg-out47.6%
Simplified47.6%
Taylor expanded in b_2 around inf 26.8%
associate-*r/26.8%
mul-1-neg26.8%
Simplified26.8%
Final simplification24.6%
(FPCore (a b_2 c) :precision binary64 (/ 0.0 a))
double code(double a, double b_2, double c) {
return 0.0 / 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 = 0.0d0 / a
end function
public static double code(double a, double b_2, double c) {
return 0.0 / a;
}
def code(a, b_2, c): return 0.0 / a
function code(a, b_2, c) return Float64(0.0 / a) end
function tmp = code(a, b_2, c) tmp = 0.0 / a; end
code[a_, b$95$2_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 51.7%
add-sqr-sqrt51.0%
pow251.0%
pow1/251.0%
sqrt-pow151.1%
metadata-eval51.1%
Applied egg-rr51.1%
Taylor expanded in b_2 around -inf 13.1%
distribute-lft1-in13.1%
metadata-eval13.1%
mul0-lft13.1%
Simplified13.1%
Final simplification13.1%
herbie shell --seed 2023214
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))