
(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 11 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 -6.6e+160)
(/ c (- b))
(if (<= b 4.6e-232)
(/ (* c -2.0) (- b (sqrt (+ (* a (* c -4.0)) (pow b 2.0)))))
(if (<= b 5e+126)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0))
(/ b (- a))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e+160) {
tmp = c / -b;
} else if (b <= 4.6e-232) {
tmp = (c * -2.0) / (b - sqrt(((a * (c * -4.0)) + pow(b, 2.0))));
} else if (b <= 5e+126) {
tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = 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 <= (-6.6d+160)) then
tmp = c / -b
else if (b <= 4.6d-232) then
tmp = (c * (-2.0d0)) / (b - sqrt(((a * (c * (-4.0d0))) + (b ** 2.0d0))))
else if (b <= 5d+126) then
tmp = (-b - sqrt(((b * b) - (4.0d0 * (c * a))))) / (a * 2.0d0)
else
tmp = b / -a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e+160) {
tmp = c / -b;
} else if (b <= 4.6e-232) {
tmp = (c * -2.0) / (b - Math.sqrt(((a * (c * -4.0)) + Math.pow(b, 2.0))));
} else if (b <= 5e+126) {
tmp = (-b - Math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.6e+160: tmp = c / -b elif b <= 4.6e-232: tmp = (c * -2.0) / (b - math.sqrt(((a * (c * -4.0)) + math.pow(b, 2.0)))) elif b <= 5e+126: tmp = (-b - math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0) else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.6e+160) tmp = Float64(c / Float64(-b)); elseif (b <= 4.6e-232) tmp = Float64(Float64(c * -2.0) / Float64(b - sqrt(Float64(Float64(a * Float64(c * -4.0)) + (b ^ 2.0))))); elseif (b <= 5e+126) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a))))) / Float64(a * 2.0)); else tmp = Float64(b / Float64(-a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.6e+160) tmp = c / -b; elseif (b <= 4.6e-232) tmp = (c * -2.0) / (b - sqrt(((a * (c * -4.0)) + (b ^ 2.0)))); elseif (b <= 5e+126) tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0); else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.6e+160], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 4.6e-232], N[(N[(c * -2.0), $MachinePrecision] / N[(b - N[Sqrt[N[(N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e+126], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{+160}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{-232}:\\
\;\;\;\;\frac{c \cdot -2}{b - \sqrt{a \cdot \left(c \cdot -4\right) + {b}^{2}}}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+126}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
if b < -6.5999999999999994e160Initial program 1.7%
div-sub1.3%
sub-neg1.3%
neg-mul-11.3%
*-commutative1.3%
associate-/l*1.3%
distribute-neg-frac1.3%
neg-mul-11.3%
*-commutative1.3%
associate-/l*1.3%
distribute-rgt-out1.7%
associate-/r*1.7%
metadata-eval1.7%
sub-neg1.7%
+-commutative1.7%
Simplified1.8%
Taylor expanded in b around -inf 95.6%
mul-1-neg95.6%
distribute-neg-frac295.6%
Simplified95.6%
if -6.5999999999999994e160 < b < 4.6e-232Initial program 48.2%
div-sub46.9%
sub-neg46.9%
neg-mul-146.9%
*-commutative46.9%
associate-/l*46.4%
distribute-neg-frac46.4%
neg-mul-146.4%
*-commutative46.4%
associate-/l*46.9%
distribute-rgt-out48.1%
associate-/r*48.1%
metadata-eval48.1%
sub-neg48.1%
+-commutative48.1%
Simplified48.1%
clear-num48.1%
flip-+47.6%
frac-times41.7%
add-sqr-sqrt41.8%
*-un-lft-identity41.8%
pow241.8%
pow241.8%
div-inv41.8%
metadata-eval41.8%
pow241.8%
Applied egg-rr41.8%
associate-/r*47.9%
*-commutative47.9%
Simplified47.9%
Taylor expanded in b around 0 86.5%
*-commutative86.5%
Simplified86.5%
fma-undefine86.5%
Applied egg-rr86.5%
if 4.6e-232 < b < 4.99999999999999977e126Initial program 91.7%
if 4.99999999999999977e126 < b Initial program 38.6%
div-sub38.6%
sub-neg38.6%
neg-mul-138.6%
*-commutative38.6%
associate-/l*38.6%
distribute-neg-frac38.6%
neg-mul-138.6%
*-commutative38.6%
associate-/l*38.5%
distribute-rgt-out38.5%
associate-/r*38.5%
metadata-eval38.5%
sub-neg38.5%
+-commutative38.5%
Simplified38.7%
Taylor expanded in a around 0 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification92.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (/ -0.5 a) (+ b (sqrt (* -4.0 (* c a)))))))
(if (<= b -3.8e-119)
(/ (* c -2.0) (+ b (- b (* (* a (/ c b)) 2.0))))
(if (<= b 1e-88)
t_0
(if (<= b 1100.0)
(/ (+ (* b -2.0) (* (/ (* c a) b) 2.0)) (* a 2.0))
(if (<= b 13000000.0) t_0 (- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = (-0.5 / a) * (b + sqrt((-4.0 * (c * a))));
double tmp;
if (b <= -3.8e-119) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else if (b <= 1e-88) {
tmp = t_0;
} else if (b <= 1100.0) {
tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0);
} else if (b <= 13000000.0) {
tmp = t_0;
} else {
tmp = (c / b) - (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) :: t_0
real(8) :: tmp
t_0 = ((-0.5d0) / a) * (b + sqrt(((-4.0d0) * (c * a))))
if (b <= (-3.8d-119)) then
tmp = (c * (-2.0d0)) / (b + (b - ((a * (c / b)) * 2.0d0)))
else if (b <= 1d-88) then
tmp = t_0
else if (b <= 1100.0d0) then
tmp = ((b * (-2.0d0)) + (((c * a) / b) * 2.0d0)) / (a * 2.0d0)
else if (b <= 13000000.0d0) then
tmp = t_0
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (-0.5 / a) * (b + Math.sqrt((-4.0 * (c * a))));
double tmp;
if (b <= -3.8e-119) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else if (b <= 1e-88) {
tmp = t_0;
} else if (b <= 1100.0) {
tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0);
} else if (b <= 13000000.0) {
tmp = t_0;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): t_0 = (-0.5 / a) * (b + math.sqrt((-4.0 * (c * a)))) tmp = 0 if b <= -3.8e-119: tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))) elif b <= 1e-88: tmp = t_0 elif b <= 1100.0: tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0) elif b <= 13000000.0: tmp = t_0 else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) t_0 = Float64(Float64(-0.5 / a) * Float64(b + sqrt(Float64(-4.0 * Float64(c * a))))) tmp = 0.0 if (b <= -3.8e-119) tmp = Float64(Float64(c * -2.0) / Float64(b + Float64(b - Float64(Float64(a * Float64(c / b)) * 2.0)))); elseif (b <= 1e-88) tmp = t_0; elseif (b <= 1100.0) tmp = Float64(Float64(Float64(b * -2.0) + Float64(Float64(Float64(c * a) / b) * 2.0)) / Float64(a * 2.0)); elseif (b <= 13000000.0) tmp = t_0; else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (-0.5 / a) * (b + sqrt((-4.0 * (c * a)))); tmp = 0.0; if (b <= -3.8e-119) tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))); elseif (b <= 1e-88) tmp = t_0; elseif (b <= 1100.0) tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0); elseif (b <= 13000000.0) tmp = t_0; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.8e-119], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[(b - N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-88], t$95$0, If[LessEqual[b, 1100.0], N[(N[(N[(b * -2.0), $MachinePrecision] + N[(N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 13000000.0], t$95$0, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-0.5}{a} \cdot \left(b + \sqrt{-4 \cdot \left(c \cdot a\right)}\right)\\
\mathbf{if}\;b \leq -3.8 \cdot 10^{-119}:\\
\;\;\;\;\frac{c \cdot -2}{b + \left(b - \left(a \cdot \frac{c}{b}\right) \cdot 2\right)}\\
\mathbf{elif}\;b \leq 10^{-88}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 1100:\\
\;\;\;\;\frac{b \cdot -2 + \frac{c \cdot a}{b} \cdot 2}{a \cdot 2}\\
\mathbf{elif}\;b \leq 13000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -3.79999999999999975e-119Initial program 18.4%
div-sub17.1%
sub-neg17.1%
neg-mul-117.1%
*-commutative17.1%
associate-/l*16.5%
distribute-neg-frac16.5%
neg-mul-116.5%
*-commutative16.5%
associate-/l*17.0%
distribute-rgt-out18.4%
associate-/r*18.4%
metadata-eval18.4%
sub-neg18.4%
+-commutative18.4%
Simplified18.4%
clear-num18.4%
flip-+17.5%
frac-times13.9%
add-sqr-sqrt13.9%
*-un-lft-identity13.9%
pow213.9%
pow213.9%
div-inv13.9%
metadata-eval13.9%
pow213.9%
Applied egg-rr13.9%
associate-/r*17.6%
*-commutative17.6%
Simplified17.6%
Taylor expanded in b around 0 70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in b around -inf 83.4%
neg-mul-183.4%
+-commutative83.4%
unsub-neg83.4%
*-commutative83.4%
associate-/l*87.5%
Simplified87.5%
if -3.79999999999999975e-119 < b < 9.99999999999999934e-89 or 1100 < b < 1.3e7Initial program 81.2%
div-sub81.2%
sub-neg81.2%
neg-mul-181.2%
*-commutative81.2%
associate-/l*81.2%
distribute-neg-frac81.2%
neg-mul-181.2%
*-commutative81.2%
associate-/l*81.0%
distribute-rgt-out81.0%
associate-/r*81.0%
metadata-eval81.0%
sub-neg81.0%
+-commutative81.0%
Simplified81.0%
Taylor expanded in a around inf 78.3%
*-commutative78.3%
Simplified78.3%
if 9.99999999999999934e-89 < b < 1100Initial program 90.6%
*-commutative90.6%
*-commutative90.6%
sqr-neg90.6%
*-commutative90.6%
sqr-neg90.6%
*-commutative90.6%
associate-*r*90.6%
Simplified90.6%
Taylor expanded in b around inf 64.5%
if 1.3e7 < b Initial program 56.9%
div-sub56.9%
sub-neg56.9%
neg-mul-156.9%
*-commutative56.9%
associate-/l*56.8%
distribute-neg-frac56.8%
neg-mul-156.8%
*-commutative56.8%
associate-/l*56.7%
distribute-rgt-out56.7%
associate-/r*56.7%
metadata-eval56.7%
sub-neg56.7%
+-commutative56.7%
Simplified56.9%
Taylor expanded in a around 0 95.8%
+-commutative95.8%
mul-1-neg95.8%
unsub-neg95.8%
Simplified95.8%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.65e-94)
(/ (* c -2.0) (+ b (- b (* (* a (/ c b)) 2.0))))
(if (<= b 7e-127)
(/ (* c -2.0) (- b (sqrt (* a (* c -4.0)))))
(if (<= b 1100.0)
(/ (+ (* b -2.0) (* (/ (* c a) b) 2.0)) (* a 2.0))
(if (<= b 40000000.0)
(* (/ -0.5 a) (+ b (sqrt (* -4.0 (* c a)))))
(- (/ c b) (/ b a)))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.65e-94) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else if (b <= 7e-127) {
tmp = (c * -2.0) / (b - sqrt((a * (c * -4.0))));
} else if (b <= 1100.0) {
tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0);
} else if (b <= 40000000.0) {
tmp = (-0.5 / a) * (b + sqrt((-4.0 * (c * a))));
} else {
tmp = (c / b) - (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 <= (-1.65d-94)) then
tmp = (c * (-2.0d0)) / (b + (b - ((a * (c / b)) * 2.0d0)))
else if (b <= 7d-127) then
tmp = (c * (-2.0d0)) / (b - sqrt((a * (c * (-4.0d0)))))
else if (b <= 1100.0d0) then
tmp = ((b * (-2.0d0)) + (((c * a) / b) * 2.0d0)) / (a * 2.0d0)
else if (b <= 40000000.0d0) then
tmp = ((-0.5d0) / a) * (b + sqrt(((-4.0d0) * (c * a))))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.65e-94) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else if (b <= 7e-127) {
tmp = (c * -2.0) / (b - Math.sqrt((a * (c * -4.0))));
} else if (b <= 1100.0) {
tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0);
} else if (b <= 40000000.0) {
tmp = (-0.5 / a) * (b + Math.sqrt((-4.0 * (c * a))));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.65e-94: tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))) elif b <= 7e-127: tmp = (c * -2.0) / (b - math.sqrt((a * (c * -4.0)))) elif b <= 1100.0: tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0) elif b <= 40000000.0: tmp = (-0.5 / a) * (b + math.sqrt((-4.0 * (c * a)))) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.65e-94) tmp = Float64(Float64(c * -2.0) / Float64(b + Float64(b - Float64(Float64(a * Float64(c / b)) * 2.0)))); elseif (b <= 7e-127) tmp = Float64(Float64(c * -2.0) / Float64(b - sqrt(Float64(a * Float64(c * -4.0))))); elseif (b <= 1100.0) tmp = Float64(Float64(Float64(b * -2.0) + Float64(Float64(Float64(c * a) / b) * 2.0)) / Float64(a * 2.0)); elseif (b <= 40000000.0) tmp = Float64(Float64(-0.5 / a) * Float64(b + sqrt(Float64(-4.0 * Float64(c * a))))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.65e-94) tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))); elseif (b <= 7e-127) tmp = (c * -2.0) / (b - sqrt((a * (c * -4.0)))); elseif (b <= 1100.0) tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0); elseif (b <= 40000000.0) tmp = (-0.5 / a) * (b + sqrt((-4.0 * (c * a)))); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.65e-94], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[(b - N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7e-127], N[(N[(c * -2.0), $MachinePrecision] / N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1100.0], N[(N[(N[(b * -2.0), $MachinePrecision] + N[(N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 40000000.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65 \cdot 10^{-94}:\\
\;\;\;\;\frac{c \cdot -2}{b + \left(b - \left(a \cdot \frac{c}{b}\right) \cdot 2\right)}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-127}:\\
\;\;\;\;\frac{c \cdot -2}{b - \sqrt{a \cdot \left(c \cdot -4\right)}}\\
\mathbf{elif}\;b \leq 1100:\\
\;\;\;\;\frac{b \cdot -2 + \frac{c \cdot a}{b} \cdot 2}{a \cdot 2}\\
\mathbf{elif}\;b \leq 40000000:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{-4 \cdot \left(c \cdot a\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.6500000000000001e-94Initial program 17.9%
div-sub16.5%
sub-neg16.5%
neg-mul-116.5%
*-commutative16.5%
associate-/l*15.9%
distribute-neg-frac15.9%
neg-mul-115.9%
*-commutative15.9%
associate-/l*16.5%
distribute-rgt-out17.9%
associate-/r*17.9%
metadata-eval17.9%
sub-neg17.9%
+-commutative17.9%
Simplified17.9%
clear-num17.9%
flip-+17.0%
frac-times14.2%
add-sqr-sqrt14.3%
*-un-lft-identity14.3%
pow214.3%
pow214.3%
div-inv14.3%
metadata-eval14.3%
pow214.3%
Applied egg-rr14.3%
associate-/r*17.1%
*-commutative17.1%
Simplified17.1%
Taylor expanded in b around 0 70.9%
*-commutative70.9%
Simplified70.9%
Taylor expanded in b around -inf 84.9%
neg-mul-184.9%
+-commutative84.9%
unsub-neg84.9%
*-commutative84.9%
associate-/l*89.1%
Simplified89.1%
if -1.6500000000000001e-94 < b < 6.99999999999999979e-127Initial program 75.6%
div-sub75.6%
sub-neg75.6%
neg-mul-175.6%
*-commutative75.6%
associate-/l*75.6%
distribute-neg-frac75.6%
neg-mul-175.6%
*-commutative75.6%
associate-/l*75.5%
distribute-rgt-out75.5%
associate-/r*75.5%
metadata-eval75.5%
sub-neg75.5%
+-commutative75.5%
Simplified75.5%
clear-num75.5%
flip-+74.5%
frac-times64.4%
add-sqr-sqrt64.5%
*-un-lft-identity64.5%
pow264.5%
pow264.5%
div-inv64.5%
metadata-eval64.5%
pow264.5%
Applied egg-rr64.5%
associate-/r*74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 78.4%
*-commutative78.4%
Simplified78.4%
Taylor expanded in a around inf 76.3%
*-commutative76.3%
*-commutative76.3%
*-commutative76.3%
associate-*r*76.3%
Simplified76.3%
if 6.99999999999999979e-127 < b < 1100Initial program 92.1%
*-commutative92.1%
*-commutative92.1%
sqr-neg92.1%
*-commutative92.1%
sqr-neg92.1%
*-commutative92.1%
associate-*r*92.1%
Simplified92.1%
Taylor expanded in b around inf 62.6%
if 1100 < b < 4e7Initial program 100.0%
div-sub100.0%
sub-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
distribute-neg-frac100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*99.7%
distribute-rgt-out99.7%
associate-/r*99.7%
metadata-eval99.7%
sub-neg99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in a around inf 99.7%
*-commutative99.7%
Simplified99.7%
if 4e7 < b Initial program 56.9%
div-sub56.9%
sub-neg56.9%
neg-mul-156.9%
*-commutative56.9%
associate-/l*56.8%
distribute-neg-frac56.8%
neg-mul-156.8%
*-commutative56.8%
associate-/l*56.7%
distribute-rgt-out56.7%
associate-/r*56.7%
metadata-eval56.7%
sub-neg56.7%
+-commutative56.7%
Simplified56.9%
Taylor expanded in a around 0 95.8%
+-commutative95.8%
mul-1-neg95.8%
unsub-neg95.8%
Simplified95.8%
Final simplification85.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* -0.5 (/ (pow (* a (* c -4.0)) 0.5) a))))
(if (<= b -1.65e-94)
(/ (* c -2.0) (+ b (- b (* (* a (/ c b)) 2.0))))
(if (<= b 8.5e-130)
t_0
(if (<= b 820.0)
(/ (+ (* b -2.0) (* (/ (* c a) b) 2.0)) (* a 2.0))
(if (<= b 11000000.0) t_0 (- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = -0.5 * (pow((a * (c * -4.0)), 0.5) / a);
double tmp;
if (b <= -1.65e-94) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else if (b <= 8.5e-130) {
tmp = t_0;
} else if (b <= 820.0) {
tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0);
} else if (b <= 11000000.0) {
tmp = t_0;
} else {
tmp = (c / b) - (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) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * (((a * (c * (-4.0d0))) ** 0.5d0) / a)
if (b <= (-1.65d-94)) then
tmp = (c * (-2.0d0)) / (b + (b - ((a * (c / b)) * 2.0d0)))
else if (b <= 8.5d-130) then
tmp = t_0
else if (b <= 820.0d0) then
tmp = ((b * (-2.0d0)) + (((c * a) / b) * 2.0d0)) / (a * 2.0d0)
else if (b <= 11000000.0d0) then
tmp = t_0
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -0.5 * (Math.pow((a * (c * -4.0)), 0.5) / a);
double tmp;
if (b <= -1.65e-94) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else if (b <= 8.5e-130) {
tmp = t_0;
} else if (b <= 820.0) {
tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0);
} else if (b <= 11000000.0) {
tmp = t_0;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): t_0 = -0.5 * (math.pow((a * (c * -4.0)), 0.5) / a) tmp = 0 if b <= -1.65e-94: tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))) elif b <= 8.5e-130: tmp = t_0 elif b <= 820.0: tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0) elif b <= 11000000.0: tmp = t_0 else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) t_0 = Float64(-0.5 * Float64((Float64(a * Float64(c * -4.0)) ^ 0.5) / a)) tmp = 0.0 if (b <= -1.65e-94) tmp = Float64(Float64(c * -2.0) / Float64(b + Float64(b - Float64(Float64(a * Float64(c / b)) * 2.0)))); elseif (b <= 8.5e-130) tmp = t_0; elseif (b <= 820.0) tmp = Float64(Float64(Float64(b * -2.0) + Float64(Float64(Float64(c * a) / b) * 2.0)) / Float64(a * 2.0)); elseif (b <= 11000000.0) tmp = t_0; else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = -0.5 * (((a * (c * -4.0)) ^ 0.5) / a); tmp = 0.0; if (b <= -1.65e-94) tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))); elseif (b <= 8.5e-130) tmp = t_0; elseif (b <= 820.0) tmp = ((b * -2.0) + (((c * a) / b) * 2.0)) / (a * 2.0); elseif (b <= 11000000.0) tmp = t_0; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(-0.5 * N[(N[Power[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.65e-94], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[(b - N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-130], t$95$0, If[LessEqual[b, 820.0], N[(N[(N[(b * -2.0), $MachinePrecision] + N[(N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 11000000.0], t$95$0, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{{\left(a \cdot \left(c \cdot -4\right)\right)}^{0.5}}{a}\\
\mathbf{if}\;b \leq -1.65 \cdot 10^{-94}:\\
\;\;\;\;\frac{c \cdot -2}{b + \left(b - \left(a \cdot \frac{c}{b}\right) \cdot 2\right)}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-130}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 820:\\
\;\;\;\;\frac{b \cdot -2 + \frac{c \cdot a}{b} \cdot 2}{a \cdot 2}\\
\mathbf{elif}\;b \leq 11000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.6500000000000001e-94Initial program 17.9%
div-sub16.5%
sub-neg16.5%
neg-mul-116.5%
*-commutative16.5%
associate-/l*15.9%
distribute-neg-frac15.9%
neg-mul-115.9%
*-commutative15.9%
associate-/l*16.5%
distribute-rgt-out17.9%
associate-/r*17.9%
metadata-eval17.9%
sub-neg17.9%
+-commutative17.9%
Simplified17.9%
clear-num17.9%
flip-+17.0%
frac-times14.2%
add-sqr-sqrt14.3%
*-un-lft-identity14.3%
pow214.3%
pow214.3%
div-inv14.3%
metadata-eval14.3%
pow214.3%
Applied egg-rr14.3%
associate-/r*17.1%
*-commutative17.1%
Simplified17.1%
Taylor expanded in b around 0 70.9%
*-commutative70.9%
Simplified70.9%
Taylor expanded in b around -inf 84.9%
neg-mul-184.9%
+-commutative84.9%
unsub-neg84.9%
*-commutative84.9%
associate-/l*89.1%
Simplified89.1%
if -1.6500000000000001e-94 < b < 8.50000000000000033e-130 or 820 < b < 1.1e7Initial program 78.9%
div-sub78.9%
sub-neg78.9%
neg-mul-178.9%
*-commutative78.9%
associate-/l*78.9%
distribute-neg-frac78.9%
neg-mul-178.9%
*-commutative78.9%
associate-/l*78.8%
distribute-rgt-out78.8%
associate-/r*78.8%
metadata-eval78.8%
sub-neg78.8%
+-commutative78.8%
Simplified78.8%
add-sqr-sqrt78.5%
pow278.5%
pow1/278.5%
sqrt-pow178.7%
pow278.7%
metadata-eval78.7%
Applied egg-rr78.7%
Taylor expanded in c around inf 53.8%
unpow253.8%
exp-prod52.7%
exp-prod51.7%
pow-sqr51.7%
*-commutative51.7%
mul-1-neg51.7%
log-rec51.7%
remove-double-neg51.7%
Simplified51.7%
Taylor expanded in b around 0 54.0%
*-commutative54.0%
*-commutative54.0%
log-prod73.4%
associate-*r*73.4%
*-commutative73.4%
associate-*r*73.4%
exp-to-pow78.4%
Simplified78.4%
if 8.50000000000000033e-130 < b < 820Initial program 88.7%
*-commutative88.7%
*-commutative88.7%
sqr-neg88.7%
*-commutative88.7%
sqr-neg88.7%
*-commutative88.7%
associate-*r*88.7%
Simplified88.7%
Taylor expanded in b around inf 60.3%
if 1.1e7 < b Initial program 56.9%
div-sub56.9%
sub-neg56.9%
neg-mul-156.9%
*-commutative56.9%
associate-/l*56.8%
distribute-neg-frac56.8%
neg-mul-156.8%
*-commutative56.8%
associate-/l*56.7%
distribute-rgt-out56.7%
associate-/r*56.7%
metadata-eval56.7%
sub-neg56.7%
+-commutative56.7%
Simplified56.9%
Taylor expanded in a around 0 95.8%
+-commutative95.8%
mul-1-neg95.8%
unsub-neg95.8%
Simplified95.8%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.7e-93)
(/ (* c -2.0) (+ b (- b (* (* a (/ c b)) 2.0))))
(if (<= b 4e+129)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0))
(/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e-93) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else if (b <= 4e+129) {
tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = -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 <= (-1.7d-93)) then
tmp = (c * (-2.0d0)) / (b + (b - ((a * (c / b)) * 2.0d0)))
else if (b <= 4d+129) then
tmp = (-b - sqrt(((b * b) - (4.0d0 * (c * a))))) / (a * 2.0d0)
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e-93) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else if (b <= 4e+129) {
tmp = (-b - Math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.7e-93: tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))) elif b <= 4e+129: tmp = (-b - math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.7e-93) tmp = Float64(Float64(c * -2.0) / Float64(b + Float64(b - Float64(Float64(a * Float64(c / b)) * 2.0)))); elseif (b <= 4e+129) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a))))) / Float64(a * 2.0)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.7e-93) tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))); elseif (b <= 4e+129) tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.7e-93], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[(b - N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e+129], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.7 \cdot 10^{-93}:\\
\;\;\;\;\frac{c \cdot -2}{b + \left(b - \left(a \cdot \frac{c}{b}\right) \cdot 2\right)}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{+129}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -1.70000000000000001e-93Initial program 17.2%
div-sub15.8%
sub-neg15.8%
neg-mul-115.8%
*-commutative15.8%
associate-/l*15.3%
distribute-neg-frac15.3%
neg-mul-115.3%
*-commutative15.3%
associate-/l*15.8%
distribute-rgt-out17.2%
associate-/r*17.2%
metadata-eval17.2%
sub-neg17.2%
+-commutative17.2%
Simplified17.2%
clear-num17.2%
flip-+16.3%
frac-times14.3%
add-sqr-sqrt14.3%
*-un-lft-identity14.3%
pow214.3%
pow214.3%
div-inv14.3%
metadata-eval14.3%
pow214.3%
Applied egg-rr14.3%
associate-/r*16.4%
*-commutative16.4%
Simplified16.4%
Taylor expanded in b around 0 70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in b around -inf 85.2%
neg-mul-185.2%
+-commutative85.2%
unsub-neg85.2%
*-commutative85.2%
associate-/l*89.4%
Simplified89.4%
if -1.70000000000000001e-93 < b < 4e129Initial program 85.0%
if 4e129 < b Initial program 38.6%
div-sub38.6%
sub-neg38.6%
neg-mul-138.6%
*-commutative38.6%
associate-/l*38.6%
distribute-neg-frac38.6%
neg-mul-138.6%
*-commutative38.6%
associate-/l*38.5%
distribute-rgt-out38.5%
associate-/r*38.5%
metadata-eval38.5%
sub-neg38.5%
+-commutative38.5%
Simplified38.7%
Taylor expanded in a around 0 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification89.6%
(FPCore (a b c) :precision binary64 (if (<= b 5e-292) (/ (* c -2.0) (+ b (- b (* (* a (/ c b)) 2.0)))) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5e-292) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else {
tmp = (c / b) - (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-292) then
tmp = (c * (-2.0d0)) / (b + (b - ((a * (c / b)) * 2.0d0)))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 5e-292) {
tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0)));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5e-292: tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5e-292) tmp = Float64(Float64(c * -2.0) / Float64(b + Float64(b - Float64(Float64(a * Float64(c / b)) * 2.0)))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5e-292) tmp = (c * -2.0) / (b + (b - ((a * (c / b)) * 2.0))); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5e-292], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[(b - N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{-292}:\\
\;\;\;\;\frac{c \cdot -2}{b + \left(b - \left(a \cdot \frac{c}{b}\right) \cdot 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < 4.99999999999999981e-292Initial program 31.4%
div-sub30.4%
sub-neg30.4%
neg-mul-130.4%
*-commutative30.4%
associate-/l*30.0%
distribute-neg-frac30.0%
neg-mul-130.0%
*-commutative30.0%
associate-/l*30.3%
distribute-rgt-out31.3%
associate-/r*31.3%
metadata-eval31.3%
sub-neg31.3%
+-commutative31.3%
Simplified31.4%
clear-num31.4%
flip-+30.5%
frac-times26.9%
add-sqr-sqrt26.9%
*-un-lft-identity26.9%
pow226.9%
pow226.9%
div-inv26.9%
metadata-eval26.9%
pow226.9%
Applied egg-rr26.9%
associate-/r*30.6%
*-commutative30.6%
Simplified30.6%
Taylor expanded in b around 0 72.2%
*-commutative72.2%
Simplified72.2%
Taylor expanded in b around -inf 66.2%
neg-mul-166.2%
+-commutative66.2%
unsub-neg66.2%
*-commutative66.2%
associate-/l*69.3%
Simplified69.3%
if 4.99999999999999981e-292 < b Initial program 70.1%
div-sub70.0%
sub-neg70.0%
neg-mul-170.0%
*-commutative70.0%
associate-/l*70.0%
distribute-neg-frac70.0%
neg-mul-170.0%
*-commutative70.0%
associate-/l*69.8%
distribute-rgt-out69.9%
associate-/r*69.9%
metadata-eval69.9%
sub-neg69.9%
+-commutative69.9%
Simplified69.9%
Taylor expanded in a around 0 70.7%
+-commutative70.7%
mul-1-neg70.7%
unsub-neg70.7%
Simplified70.7%
Final simplification70.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ c (- b)) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = c / -b;
} else {
tmp = (c / b) - (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-310)) then
tmp = c / -b
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = c / -b;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = c / -b else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(c / Float64(-b)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = c / -b; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(c / (-b)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 31.6%
div-sub30.6%
sub-neg30.6%
neg-mul-130.6%
*-commutative30.6%
associate-/l*30.2%
distribute-neg-frac30.2%
neg-mul-130.2%
*-commutative30.2%
associate-/l*30.5%
distribute-rgt-out31.6%
associate-/r*31.6%
metadata-eval31.6%
sub-neg31.6%
+-commutative31.6%
Simplified31.6%
Taylor expanded in b around -inf 69.3%
mul-1-neg69.3%
distribute-neg-frac269.3%
Simplified69.3%
if -4.999999999999985e-310 < b Initial program 69.5%
div-sub69.5%
sub-neg69.5%
neg-mul-169.5%
*-commutative69.5%
associate-/l*69.4%
distribute-neg-frac69.4%
neg-mul-169.4%
*-commutative69.4%
associate-/l*69.3%
distribute-rgt-out69.3%
associate-/r*69.3%
metadata-eval69.3%
sub-neg69.3%
+-commutative69.3%
Simplified69.4%
Taylor expanded in a around 0 70.2%
+-commutative70.2%
mul-1-neg70.2%
unsub-neg70.2%
Simplified70.2%
Final simplification69.8%
(FPCore (a b c) :precision binary64 (if (<= b -1.1e-308) (/ c (- b)) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-308) {
tmp = c / -b;
} else {
tmp = 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 <= (-1.1d-308)) then
tmp = c / -b
else
tmp = b / -a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-308) {
tmp = c / -b;
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.1e-308: tmp = c / -b else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.1e-308) tmp = Float64(c / Float64(-b)); else tmp = Float64(b / Float64(-a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.1e-308) tmp = c / -b; else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.1e-308], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.1 \cdot 10^{-308}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
if b < -1.1000000000000001e-308Initial program 31.6%
div-sub30.6%
sub-neg30.6%
neg-mul-130.6%
*-commutative30.6%
associate-/l*30.2%
distribute-neg-frac30.2%
neg-mul-130.2%
*-commutative30.2%
associate-/l*30.5%
distribute-rgt-out31.6%
associate-/r*31.6%
metadata-eval31.6%
sub-neg31.6%
+-commutative31.6%
Simplified31.6%
Taylor expanded in b around -inf 69.3%
mul-1-neg69.3%
distribute-neg-frac269.3%
Simplified69.3%
if -1.1000000000000001e-308 < b Initial program 69.5%
div-sub69.5%
sub-neg69.5%
neg-mul-169.5%
*-commutative69.5%
associate-/l*69.4%
distribute-neg-frac69.4%
neg-mul-169.4%
*-commutative69.4%
associate-/l*69.3%
distribute-rgt-out69.3%
associate-/r*69.3%
metadata-eval69.3%
sub-neg69.3%
+-commutative69.3%
Simplified69.4%
Taylor expanded in a around 0 69.4%
associate-*r/69.4%
mul-1-neg69.4%
Simplified69.4%
Final simplification69.3%
(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 / Float64(-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 50.6%
div-sub50.0%
sub-neg50.0%
neg-mul-150.0%
*-commutative50.0%
associate-/l*49.8%
distribute-neg-frac49.8%
neg-mul-149.8%
*-commutative49.8%
associate-/l*49.9%
distribute-rgt-out50.5%
associate-/r*50.5%
metadata-eval50.5%
sub-neg50.5%
+-commutative50.5%
Simplified50.5%
Taylor expanded in b around -inf 35.8%
mul-1-neg35.8%
distribute-neg-frac235.8%
Simplified35.8%
Final simplification35.8%
(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 50.6%
div-sub50.0%
sub-neg50.0%
neg-mul-150.0%
*-commutative50.0%
associate-/l*49.8%
distribute-neg-frac49.8%
neg-mul-149.8%
*-commutative49.8%
associate-/l*49.9%
distribute-rgt-out50.5%
associate-/r*50.5%
metadata-eval50.5%
sub-neg50.5%
+-commutative50.5%
Simplified50.5%
Applied egg-rr30.3%
Taylor expanded in b around -inf 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 50.6%
div-sub50.0%
sub-neg50.0%
neg-mul-150.0%
*-commutative50.0%
associate-/l*49.8%
distribute-neg-frac49.8%
neg-mul-149.8%
*-commutative49.8%
associate-/l*49.9%
distribute-rgt-out50.5%
associate-/r*50.5%
metadata-eval50.5%
sub-neg50.5%
+-commutative50.5%
Simplified50.5%
Taylor expanded in a around 0 35.3%
associate-/l*36.1%
Simplified36.1%
Taylor expanded in a around inf 12.5%
Final simplification12.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (< b 0.0)
(/ c (* a (/ (+ (- b) t_0) (* 2.0 a))))
(/ (- (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.0 * a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
if (b < 0.0d0) then
tmp = c / (a * ((-b + t_0) / (2.0d0 * a)))
else
tmp = (-b - t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (a * c)))) tmp = 0 if b < 0.0: tmp = c / (a * ((-b + t_0) / (2.0 * a))) else: tmp = (-b - t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) tmp = 0.0 if (b < 0.0) tmp = Float64(c / Float64(a * Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)))); else tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (a * c)))); tmp = 0.0; if (b < 0.0) tmp = c / (a * ((-b + t_0) / (2.0 * a))); else tmp = (-b - t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(c / N[(a * N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t\_0}{2 \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\end{array}
\end{array}
herbie shell --seed 2024040
(FPCore (a b c)
:name "The quadratic formula (r2)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))