
(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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{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) (* 4.0 (* c a)))) b) (* a 2.0))
(/ (* -2.0 (/ c (/ b a))) (* 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) - (4.0 * (c * a)))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (c / (b / a))) / (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) - (4.0d0 * (c * a)))) - b) / (a * 2.0d0)
else
tmp = ((-2.0d0) * (c / (b / a))) / (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) - (4.0 * (c * a)))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (c / (b / a))) / (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) - (4.0 * (c * a)))) - b) / (a * 2.0) else: tmp = (-2.0 * (c / (b / a))) / (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(4.0 * Float64(c * a)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-2.0 * Float64(c / Float64(b / a))) / 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) - (4.0 * (c * a)))) - b) / (a * 2.0); else tmp = (-2.0 * (c / (b / a))) / (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[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(c / N[(b / a), $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 - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{c}{\frac{b}{a}}}{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%
Final simplification80.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.1e-57)
(- (/ c b) (/ b a))
(if (<= b 7.6e-20)
(* (/ -0.5 a) (- b (sqrt (* c (* a -4.0)))))
(/ (* -2.0 (/ c (/ b a))) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.1e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-20) {
tmp = (-0.5 / a) * (b - sqrt((c * (a * -4.0))));
} else {
tmp = (-2.0 * (c / (b / a))) / (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.1d-57)) then
tmp = (c / b) - (b / a)
else if (b <= 7.6d-20) then
tmp = ((-0.5d0) / a) * (b - sqrt((c * (a * (-4.0d0)))))
else
tmp = ((-2.0d0) * (c / (b / a))) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.1e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-20) {
tmp = (-0.5 / a) * (b - Math.sqrt((c * (a * -4.0))));
} else {
tmp = (-2.0 * (c / (b / a))) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.1e-57: tmp = (c / b) - (b / a) elif b <= 7.6e-20: tmp = (-0.5 / a) * (b - math.sqrt((c * (a * -4.0)))) else: tmp = (-2.0 * (c / (b / a))) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.1e-57) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.6e-20) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(c * Float64(a * -4.0))))); else tmp = Float64(Float64(-2.0 * Float64(c / Float64(b / a))) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.1e-57) tmp = (c / b) - (b / a); elseif (b <= 7.6e-20) tmp = (-0.5 / a) * (b - sqrt((c * (a * -4.0)))); else tmp = (-2.0 * (c / (b / a))) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.1e-57], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-20], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.1 \cdot 10^{-57}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-20}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{c}{\frac{b}{a}}}{a \cdot 2}\\
\end{array}
\end{array}
if b < -2.0999999999999999e-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 -2.0999999999999999e-57 < b < 7.5999999999999995e-20Initial program 72.0%
*-commutative72.0%
Simplified72.0%
add-sqr-sqrt69.3%
pow269.3%
pow1/269.3%
sqrt-pow169.3%
fma-neg69.3%
distribute-lft-neg-in69.3%
*-commutative69.3%
associate-*r*69.3%
metadata-eval69.3%
metadata-eval69.3%
Applied egg-rr69.3%
Taylor expanded in b around 0 63.1%
*-commutative63.1%
associate-*r*63.1%
Simplified63.1%
frac-2neg63.1%
div-inv63.0%
Applied egg-rr63.3%
*-commutative63.3%
associate-*l/63.3%
metadata-eval63.3%
*-commutative63.3%
*-commutative63.3%
Simplified63.3%
if 7.5999999999999995e-20 < b Initial program 39.4%
*-commutative39.4%
Simplified39.4%
Taylor expanded in b around inf 61.6%
*-commutative61.6%
associate-/l*67.1%
Simplified67.1%
Final simplification74.2%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-54)
(- (/ c b) (/ b a))
(if (<= b 5.3e-23)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (* -2.0 (/ c (/ b a))) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-54) {
tmp = (c / b) - (b / a);
} else if (b <= 5.3e-23) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (c / (b / a))) / (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 <= (-6.5d-54)) then
tmp = (c / b) - (b / a)
else if (b <= 5.3d-23) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = ((-2.0d0) * (c / (b / a))) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-54) {
tmp = (c / b) - (b / a);
} else if (b <= 5.3e-23) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (c / (b / a))) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-54: tmp = (c / b) - (b / a) elif b <= 5.3e-23: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = (-2.0 * (c / (b / a))) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-54) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.3e-23) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-2.0 * Float64(c / Float64(b / a))) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-54) tmp = (c / b) - (b / a); elseif (b <= 5.3e-23) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = (-2.0 * (c / (b / a))) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-54], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.3e-23], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-54}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.3 \cdot 10^{-23}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{c}{\frac{b}{a}}}{a \cdot 2}\\
\end{array}
\end{array}
if b < -6.49999999999999991e-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 -6.49999999999999991e-54 < b < 5.30000000000000042e-23Initial program 72.0%
*-commutative72.0%
Simplified72.0%
add-sqr-sqrt69.3%
pow269.3%
pow1/269.3%
sqrt-pow169.3%
fma-neg69.3%
distribute-lft-neg-in69.3%
*-commutative69.3%
associate-*r*69.3%
metadata-eval69.3%
metadata-eval69.3%
Applied egg-rr69.3%
Taylor expanded in c around inf 33.9%
unpow233.9%
fma-neg33.9%
Simplified63.3%
if 5.30000000000000042e-23 < b Initial program 39.4%
*-commutative39.4%
Simplified39.4%
Taylor expanded in b around inf 61.6%
*-commutative61.6%
associate-/l*67.1%
Simplified67.1%
Final simplification74.2%
(FPCore (a b c)
:precision binary64
(if (<= b 8e-309)
(/ (- b) a)
(if (<= b 1.1e+87)
(/ (- (+ b (* a (/ (* c -2.0) b))) b) (* a 2.0))
(/ (* -2.0 (/ c (/ b a))) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e-309) {
tmp = -b / a;
} else if (b <= 1.1e+87) {
tmp = ((b + (a * ((c * -2.0) / b))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (c / (b / a))) / (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 <= 8d-309) then
tmp = -b / a
else if (b <= 1.1d+87) then
tmp = ((b + (a * ((c * (-2.0d0)) / b))) - b) / (a * 2.0d0)
else
tmp = ((-2.0d0) * (c / (b / a))) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 8e-309) {
tmp = -b / a;
} else if (b <= 1.1e+87) {
tmp = ((b + (a * ((c * -2.0) / b))) - b) / (a * 2.0);
} else {
tmp = (-2.0 * (c / (b / a))) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e-309: tmp = -b / a elif b <= 1.1e+87: tmp = ((b + (a * ((c * -2.0) / b))) - b) / (a * 2.0) else: tmp = (-2.0 * (c / (b / a))) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e-309) tmp = Float64(Float64(-b) / a); elseif (b <= 1.1e+87) tmp = Float64(Float64(Float64(b + Float64(a * Float64(Float64(c * -2.0) / b))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-2.0 * Float64(c / Float64(b / a))) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8e-309) tmp = -b / a; elseif (b <= 1.1e+87) tmp = ((b + (a * ((c * -2.0) / b))) - b) / (a * 2.0); else tmp = (-2.0 * (c / (b / a))) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e-309], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 1.1e+87], N[(N[(N[(b + N[(a * N[(N[(c * -2.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{-309}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+87}:\\
\;\;\;\;\frac{\left(b + a \cdot \frac{c \cdot -2}{b}\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{c}{\frac{b}{a}}}{a \cdot 2}\\
\end{array}
\end{array}
if b < 8.0000000000000003e-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 8.0000000000000003e-309 < b < 1.1e87Initial program 68.4%
*-commutative68.4%
Simplified68.4%
add-sqr-sqrt55.6%
pow255.6%
pow1/255.6%
sqrt-pow155.8%
fma-neg55.8%
distribute-lft-neg-in55.8%
*-commutative55.8%
associate-*r*55.8%
metadata-eval55.8%
metadata-eval55.8%
Applied egg-rr55.8%
Taylor expanded in b around inf 33.2%
mul-1-neg33.2%
associate-+r+33.2%
unsub-neg33.2%
associate-*r/33.5%
*-commutative33.5%
associate-*r*33.5%
associate-*l/33.5%
Simplified33.5%
if 1.1e87 < 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%
Final simplification59.9%
(FPCore (a b c)
:precision binary64
(if (<= b -7.4e-300)
(/ (- b) a)
(if (or (<= b 1e+87) (not (<= b 2.15e+222)))
(/ 0.0 (* a 2.0))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.4e-300) {
tmp = -b / a;
} else if ((b <= 1e+87) || !(b <= 2.15e+222)) {
tmp = 0.0 / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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 if ((b <= 1d+87) .or. (.not. (b <= 2.15d+222))) then
tmp = 0.0d0 / (a * 2.0d0)
else
tmp = 1.0d0 / ((a / b) - (b / c))
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 if ((b <= 1e+87) || !(b <= 2.15e+222)) {
tmp = 0.0 / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.4e-300: tmp = -b / a elif (b <= 1e+87) or not (b <= 2.15e+222): tmp = 0.0 / (a * 2.0) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.4e-300) tmp = Float64(Float64(-b) / a); elseif ((b <= 1e+87) || !(b <= 2.15e+222)) tmp = Float64(0.0 / Float64(a * 2.0)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.4e-300) tmp = -b / a; elseif ((b <= 1e+87) || ~((b <= 2.15e+222))) tmp = 0.0 / (a * 2.0); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.4e-300], N[((-b) / a), $MachinePrecision], If[Or[LessEqual[b, 1e+87], N[Not[LessEqual[b, 2.15e+222]], $MachinePrecision]], N[(0.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.4 \cdot 10^{-300}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 10^{+87} \lor \neg \left(b \leq 2.15 \cdot 10^{+222}\right):\\
\;\;\;\;\frac{0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\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 < 9.9999999999999996e86 or 2.1499999999999999e222 < b Initial program 51.3%
*-commutative51.3%
Simplified51.3%
add-sqr-sqrt42.2%
pow242.2%
pow1/242.2%
sqrt-pow142.3%
fma-neg42.3%
distribute-lft-neg-in42.3%
*-commutative42.3%
associate-*r*42.3%
metadata-eval42.3%
metadata-eval42.3%
Applied egg-rr42.3%
Taylor expanded in b around inf 43.0%
distribute-rgt1-in43.0%
metadata-eval43.0%
mul0-lft43.0%
Simplified43.0%
if 9.9999999999999996e86 < b < 2.1499999999999999e222Initial program 43.0%
*-commutative43.0%
Simplified43.0%
add-sqr-sqrt25.5%
pow225.5%
pow1/225.5%
sqrt-pow125.7%
fma-neg25.8%
distribute-lft-neg-in25.8%
*-commutative25.8%
associate-*r*25.8%
metadata-eval25.8%
metadata-eval25.8%
Applied egg-rr25.8%
Applied egg-rr40.3%
unpow-140.3%
*-commutative40.3%
Simplified40.3%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt68.7%
metadata-eval68.7%
neg-mul-168.7%
distribute-neg-frac68.7%
Simplified68.7%
Final simplification58.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (- b) a) (/ (* -2.0 (/ c (/ b a))) (* a 2.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -b / a;
} else {
tmp = (-2.0 * (c / (b / a))) / (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 <= (-5d-310)) then
tmp = -b / a
else
tmp = ((-2.0d0) * (c / (b / a))) / (a * 2.0d0)
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 = (-2.0 * (c / (b / a))) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -b / a else: tmp = (-2.0 * (c / (b / a))) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(-2.0 * Float64(c / Float64(b / a))) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -b / a; else tmp = (-2.0 * (c / (b / a))) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[((-b) / a), $MachinePrecision], N[(N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{c}{\frac{b}{a}}}{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%
Final simplification58.2%
(FPCore (a b c) :precision binary64 (if (<= b 5e-308) (/ (- b) a) (/ 1.0 (/ (- a) (* (/ c b) a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5e-308) {
tmp = -b / a;
} else {
tmp = 1.0 / (-a / ((c / b) * 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-308) then
tmp = -b / a
else
tmp = 1.0d0 / (-a / ((c / b) * a))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 5e-308) {
tmp = -b / a;
} else {
tmp = 1.0 / (-a / ((c / b) * a));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5e-308: tmp = -b / a else: tmp = 1.0 / (-a / ((c / b) * a)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5e-308) tmp = Float64(Float64(-b) / a); else tmp = Float64(1.0 / Float64(Float64(-a) / Float64(Float64(c / b) * a))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5e-308) tmp = -b / a; else tmp = 1.0 / (-a / ((c / b) * a)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5e-308], N[((-b) / a), $MachinePrecision], N[(1.0 / N[((-a) / N[(N[(c / b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{-308}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{-a}{\frac{c}{b} \cdot a}}\\
\end{array}
\end{array}
if b < 4.99999999999999955e-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 4.99999999999999955e-308 < b Initial program 48.4%
*-commutative48.4%
Simplified48.4%
Taylor expanded in b around inf 45.5%
associate-/l*48.5%
Simplified48.5%
clear-num48.5%
inv-pow48.5%
*-commutative48.5%
times-frac48.5%
metadata-eval48.5%
div-inv48.5%
clear-num48.5%
Applied egg-rr48.5%
unpow-148.5%
associate-*r/48.5%
neg-mul-148.5%
Simplified48.5%
Final simplification57.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (- b) a) (/ -1.0 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -b / a;
} else {
tmp = -1.0 / (b / c);
}
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 = (-1.0d0) / (b / c)
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 = -1.0 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -b / a else: tmp = -1.0 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-b) / a); else tmp = Float64(-1.0 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -b / a; else tmp = -1.0 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[((-b) / a), $MachinePrecision], N[(-1.0 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{b}{c}}\\
\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%
associate-/l*48.5%
Simplified48.5%
add-exp-log34.4%
*-commutative34.4%
times-frac34.4%
metadata-eval34.4%
div-inv34.4%
clear-num33.8%
Applied egg-rr33.8%
Taylor expanded in a around 0 24.9%
associate-*r/24.9%
mul-1-neg24.9%
Simplified24.9%
rem-exp-log39.7%
clear-num40.5%
frac-2neg40.5%
metadata-eval40.5%
add-sqr-sqrt16.0%
sqrt-unprod29.4%
sqr-neg29.4%
sqrt-unprod11.8%
add-sqr-sqrt20.2%
distribute-frac-neg20.2%
add-sqr-sqrt0.0%
sqrt-unprod43.0%
sqr-neg43.0%
sqrt-unprod40.4%
add-sqr-sqrt40.5%
Applied egg-rr40.5%
Final simplification53.7%
(FPCore (a b c) :precision binary64 (if (<= b -7.4e-300) (/ (- b) a) (/ 0.0 (* a 2.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.4e-300) {
tmp = -b / a;
} else {
tmp = 0.0 / (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 = 0.0d0 / (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 = 0.0 / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.4e-300: tmp = -b / a else: tmp = 0.0 / (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(0.0 / 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 = 0.0 / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.4e-300], N[((-b) / a), $MachinePrecision], N[(0.0 / 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{0}{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%
add-sqr-sqrt38.0%
pow238.0%
pow1/238.0%
sqrt-pow138.1%
fma-neg38.1%
distribute-lft-neg-in38.1%
*-commutative38.1%
associate-*r*38.1%
metadata-eval38.1%
metadata-eval38.1%
Applied egg-rr38.1%
Taylor expanded in b around inf 46.3%
distribute-rgt1-in46.3%
metadata-eval46.3%
mul0-lft46.3%
Simplified46.3%
Final simplification56.9%
(FPCore (a b c) :precision binary64 (if (<= b 9.5e+14) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 9.5e+14) {
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 <= 9.5d+14) 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 <= 9.5e+14) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 9.5e+14: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 9.5e+14) 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 <= 9.5e+14) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 9.5e+14], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{+14}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 9.5e14Initial 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 9.5e14 < b Initial program 40.9%
*-commutative40.9%
Simplified40.9%
Taylor expanded in b around inf 60.0%
associate-/l*64.5%
Simplified64.5%
frac-2neg64.5%
div-inv64.5%
*-commutative64.5%
distribute-lft-neg-in64.5%
add-sqr-sqrt64.3%
sqrt-unprod63.1%
sqr-neg63.1%
sqrt-unprod0.0%
add-sqr-sqrt40.5%
distribute-neg-frac40.5%
distribute-frac-neg40.5%
frac-2neg40.5%
div-inv40.5%
clear-num39.6%
associate-*l*39.6%
distribute-rgt-neg-in39.6%
metadata-eval39.6%
Applied egg-rr39.6%
Taylor expanded in a around 0 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%
associate-*r/39.7%
neg-mul-139.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%
add-sqr-sqrt54.7%
pow254.7%
pow1/254.7%
sqrt-pow154.7%
fma-neg54.8%
distribute-lft-neg-in54.8%
*-commutative54.8%
associate-*r*54.8%
metadata-eval54.8%
metadata-eval54.8%
Applied egg-rr54.8%
Applied egg-rr57.0%
unpow-157.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt22.2%
metadata-eval22.2%
neg-mul-122.2%
distribute-neg-frac22.2%
Simplified22.2%
Taylor expanded in b 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%
Taylor expanded in b around inf 24.0%
associate-/l*25.5%
Simplified25.5%
frac-2neg25.5%
div-inv25.5%
*-commutative25.5%
distribute-lft-neg-in25.5%
add-sqr-sqrt24.4%
sqrt-unprod25.5%
sqr-neg25.5%
sqrt-unprod1.7%
add-sqr-sqrt15.9%
distribute-neg-frac15.9%
distribute-frac-neg15.9%
frac-2neg15.9%
div-inv15.9%
clear-num15.7%
associate-*l*15.7%
distribute-rgt-neg-in15.7%
metadata-eval15.7%
Applied egg-rr15.7%
Taylor expanded in a around 0 11.5%
Final simplification11.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fabs (/ b 2.0)))
(t_1 (* (sqrt (fabs a)) (sqrt (fabs c))))
(t_2
(if (== (copysign a c) a)
(* (sqrt (- t_0 t_1)) (sqrt (+ t_0 t_1)))
(hypot (/ b 2.0) t_1))))
(if (< b 0.0) (/ (- t_2 (/ b 2.0)) a) (/ (- c) (+ (/ b 2.0) t_2)))))
double code(double a, double b, double c) {
double t_0 = fabs((b / 2.0));
double t_1 = sqrt(fabs(a)) * sqrt(fabs(c));
double tmp;
if (copysign(a, c) == a) {
tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1));
} else {
tmp = hypot((b / 2.0), t_1);
}
double t_2 = tmp;
double tmp_1;
if (b < 0.0) {
tmp_1 = (t_2 - (b / 2.0)) / a;
} else {
tmp_1 = -c / ((b / 2.0) + t_2);
}
return tmp_1;
}
public static double code(double a, double b, double c) {
double t_0 = Math.abs((b / 2.0));
double t_1 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
double tmp;
if (Math.copySign(a, c) == a) {
tmp = Math.sqrt((t_0 - t_1)) * Math.sqrt((t_0 + t_1));
} else {
tmp = Math.hypot((b / 2.0), t_1);
}
double t_2 = tmp;
double tmp_1;
if (b < 0.0) {
tmp_1 = (t_2 - (b / 2.0)) / a;
} else {
tmp_1 = -c / ((b / 2.0) + t_2);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.fabs((b / 2.0)) t_1 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c)) tmp = 0 if math.copysign(a, c) == a: tmp = math.sqrt((t_0 - t_1)) * math.sqrt((t_0 + t_1)) else: tmp = math.hypot((b / 2.0), t_1) t_2 = tmp tmp_1 = 0 if b < 0.0: tmp_1 = (t_2 - (b / 2.0)) / a else: tmp_1 = -c / ((b / 2.0) + t_2) return tmp_1
function code(a, b, c) t_0 = abs(Float64(b / 2.0)) t_1 = Float64(sqrt(abs(a)) * sqrt(abs(c))) tmp = 0.0 if (copysign(a, c) == a) tmp = Float64(sqrt(Float64(t_0 - t_1)) * sqrt(Float64(t_0 + t_1))); else tmp = hypot(Float64(b / 2.0), t_1); end t_2 = tmp tmp_1 = 0.0 if (b < 0.0) tmp_1 = Float64(Float64(t_2 - Float64(b / 2.0)) / a); else tmp_1 = Float64(Float64(-c) / Float64(Float64(b / 2.0) + t_2)); end return tmp_1 end
function tmp_3 = code(a, b, c) t_0 = abs((b / 2.0)); t_1 = sqrt(abs(a)) * sqrt(abs(c)); tmp = 0.0; if ((sign(c) * abs(a)) == a) tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1)); else tmp = hypot((b / 2.0), t_1); end t_2 = tmp; tmp_2 = 0.0; if (b < 0.0) tmp_2 = (t_2 - (b / 2.0)) / a; else tmp_2 = -c / ((b / 2.0) + t_2); end tmp_3 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Abs[N[(b / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], N[(N[Sqrt[N[(t$95$0 - t$95$1), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(b / 2.0), $MachinePrecision] ^ 2 + t$95$1 ^ 2], $MachinePrecision]]}, If[Less[b, 0.0], N[(N[(t$95$2 - N[(b / 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / N[(N[(b / 2.0), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{b}{2}\right|\\
t_1 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_2 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\sqrt{t\_0 - t\_1} \cdot \sqrt{t\_0 + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\frac{b}{2}, t\_1\right)\\
\end{array}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{t\_2 - \frac{b}{2}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{\frac{b}{2} + t\_2}\\
\end{array}
\end{array}
herbie shell --seed 2024031
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
:herbie-expected 10
:herbie-target
(if (< b 0.0) (/ (- (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c))))) (/ b 2.0)) a) (/ (- c) (+ (/ b 2.0) (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c))))))))
(/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))