
(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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* a (* c (cbrt 64.0)))))
(if (<= b -5e+150)
(/ b (- a))
(if (<= b 1.7e-157)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(if (<= b 6.8e+46)
(/
(/
(- (- (pow b 2.0) (pow (- b) 2.0)) t_0)
(+ b (sqrt (- (pow b 2.0) t_0))))
(* a 2.0))
(/ c (- b)))))))
double code(double a, double b, double c) {
double t_0 = a * (c * cbrt(64.0));
double tmp;
if (b <= -5e+150) {
tmp = b / -a;
} else if (b <= 1.7e-157) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else if (b <= 6.8e+46) {
tmp = (((pow(b, 2.0) - pow(-b, 2.0)) - t_0) / (b + sqrt((pow(b, 2.0) - t_0)))) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
public static double code(double a, double b, double c) {
double t_0 = a * (c * Math.cbrt(64.0));
double tmp;
if (b <= -5e+150) {
tmp = b / -a;
} else if (b <= 1.7e-157) {
tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else if (b <= 6.8e+46) {
tmp = (((Math.pow(b, 2.0) - Math.pow(-b, 2.0)) - t_0) / (b + Math.sqrt((Math.pow(b, 2.0) - t_0)))) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(a * Float64(c * cbrt(64.0))) tmp = 0.0 if (b <= -5e+150) tmp = Float64(b / Float64(-a)); elseif (b <= 1.7e-157) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); elseif (b <= 6.8e+46) tmp = Float64(Float64(Float64(Float64((b ^ 2.0) - (Float64(-b) ^ 2.0)) - t_0) / Float64(b + sqrt(Float64((b ^ 2.0) - t_0)))) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * N[Power[64.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5e+150], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.7e-157], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.8e+46], N[(N[(N[(N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[(-b), 2.0], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(b + N[Sqrt[N[(N[Power[b, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot \sqrt[3]{64}\right)\\
\mathbf{if}\;b \leq -5 \cdot 10^{+150}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{-157}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{+46}:\\
\;\;\;\;\frac{\frac{\left({b}^{2} - {\left(-b\right)}^{2}\right) - t\_0}{b + \sqrt{{b}^{2} - t\_0}}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -5.00000000000000009e150Initial program 47.4%
*-commutative47.4%
Simplified47.4%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -5.00000000000000009e150 < b < 1.69999999999999989e-157Initial program 91.0%
if 1.69999999999999989e-157 < b < 6.7999999999999996e46Initial program 52.0%
*-commutative52.0%
Simplified52.0%
add-cbrt-cube20.5%
pow1/31.6%
pow31.6%
associate-*l*1.6%
unpow-prod-down1.6%
metadata-eval1.6%
Applied egg-rr1.6%
unpow1/320.4%
cube-prod9.4%
*-commutative9.4%
cube-prod20.4%
Simplified20.4%
flip-+19.5%
pow219.5%
pow219.5%
pow219.5%
add-sqr-sqrt19.6%
cbrt-prod19.6%
rem-cbrt-cube22.1%
Applied egg-rr51.9%
associate--r-83.0%
associate-*r*83.0%
associate-*r*83.0%
Simplified83.0%
if 6.7999999999999996e46 < b Initial program 13.5%
*-commutative13.5%
Simplified13.5%
Taylor expanded in a around 0 91.2%
associate-*r/91.2%
mul-1-neg91.2%
Simplified91.2%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+157)
(/ b (- a))
(if (<= b 3.5e-50)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+157) {
tmp = b / -a;
} else if (b <= 3.5e-50) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} 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+157)) then
tmp = b / -a
else if (b <= 3.5d-50) then
tmp = (sqrt(((b * b) - ((a * 4.0d0) * c))) - b) / (a * 2.0d0)
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+157) {
tmp = b / -a;
} else if (b <= 3.5e-50) {
tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+157: tmp = b / -a elif b <= 3.5e-50: tmp = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+157) tmp = Float64(b / Float64(-a)); elseif (b <= 3.5e-50) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+157) tmp = b / -a; elseif (b <= 3.5e-50) tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+157], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 3.5e-50], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+157}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.99999999999999976e157Initial program 47.4%
*-commutative47.4%
Simplified47.4%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -4.99999999999999976e157 < b < 3.49999999999999997e-50Initial program 88.0%
if 3.49999999999999997e-50 < b Initial program 18.4%
*-commutative18.4%
Simplified18.4%
Taylor expanded in a around 0 84.3%
associate-*r/84.3%
mul-1-neg84.3%
Simplified84.3%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -3.3e+138)
(/ b (- a))
(if (<= b 7e-46)
(* (/ 0.5 a) (- (sqrt (+ (* b b) (* a (* c -4.0)))) b))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.3e+138) {
tmp = b / -a;
} else if (b <= 7e-46) {
tmp = (0.5 / a) * (sqrt(((b * b) + (a * (c * -4.0)))) - b);
} 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 <= (-3.3d+138)) then
tmp = b / -a
else if (b <= 7d-46) then
tmp = (0.5d0 / a) * (sqrt(((b * b) + (a * (c * (-4.0d0))))) - b)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.3e+138) {
tmp = b / -a;
} else if (b <= 7e-46) {
tmp = (0.5 / a) * (Math.sqrt(((b * b) + (a * (c * -4.0)))) - b);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.3e+138: tmp = b / -a elif b <= 7e-46: tmp = (0.5 / a) * (math.sqrt(((b * b) + (a * (c * -4.0)))) - b) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.3e+138) tmp = Float64(b / Float64(-a)); elseif (b <= 7e-46) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(Float64(b * b) + Float64(a * Float64(c * -4.0)))) - b)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.3e+138) tmp = b / -a; elseif (b <= 7e-46) tmp = (0.5 / a) * (sqrt(((b * b) + (a * (c * -4.0)))) - b); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.3e+138], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 7e-46], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.3 \cdot 10^{+138}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-46}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -3.29999999999999978e138Initial program 50.4%
*-commutative50.4%
Simplified50.5%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -3.29999999999999978e138 < b < 7.0000000000000004e-46Initial program 87.7%
*-commutative87.7%
Simplified87.7%
div-sub87.7%
sub-neg87.7%
div-inv87.5%
pow287.5%
*-commutative87.5%
associate-/r*87.5%
metadata-eval87.5%
div-inv87.5%
*-commutative87.5%
associate-/r*87.5%
metadata-eval87.5%
Applied egg-rr87.5%
sub-neg87.5%
distribute-rgt-out--87.5%
Simplified87.5%
fma-undefine87.5%
Applied egg-rr87.5%
unpow287.5%
Applied egg-rr87.5%
if 7.0000000000000004e-46 < b Initial program 18.4%
*-commutative18.4%
Simplified18.4%
Taylor expanded in a around 0 84.3%
associate-*r/84.3%
mul-1-neg84.3%
Simplified84.3%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-29)
(- (/ c b) (/ b a))
(if (<= b 1.55e-46)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-29) {
tmp = (c / b) - (b / a);
} else if (b <= 1.55e-46) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} 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 <= (-1.25d-29)) then
tmp = (c / b) - (b / a)
else if (b <= 1.55d-46) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-29) {
tmp = (c / b) - (b / a);
} else if (b <= 1.55e-46) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e-29: tmp = (c / b) - (b / a) elif b <= 1.55e-46: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e-29) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.55e-46) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.25e-29) tmp = (c / b) - (b / a); elseif (b <= 1.55e-46) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e-29], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.55e-46], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-29}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{-46}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.24999999999999996e-29Initial program 67.8%
*-commutative67.8%
Simplified67.8%
Taylor expanded in b around -inf 96.6%
mul-1-neg96.6%
*-commutative96.6%
distribute-rgt-neg-in96.6%
+-commutative96.6%
mul-1-neg96.6%
unsub-neg96.6%
Simplified96.6%
Taylor expanded in a around inf 96.9%
neg-mul-196.9%
distribute-frac-neg96.9%
+-commutative96.9%
distribute-frac-neg96.9%
unsub-neg96.9%
Simplified96.9%
if -1.24999999999999996e-29 < b < 1.55e-46Initial program 83.8%
*-commutative83.8%
Simplified83.8%
Taylor expanded in a around inf 74.9%
*-commutative74.9%
associate-*r*74.9%
Simplified74.9%
if 1.55e-46 < b Initial program 18.4%
*-commutative18.4%
Simplified18.4%
Taylor expanded in a around 0 84.3%
associate-*r/84.3%
mul-1-neg84.3%
Simplified84.3%
Final simplification85.0%
(FPCore (a b c)
:precision binary64
(if (<= b -7.8e-28)
(- (/ c b) (/ b a))
(if (<= b 3.5e-50)
(* (/ 0.5 a) (- (sqrt (* c (* a -4.0))) b))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.8e-28) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-50) {
tmp = (0.5 / a) * (sqrt((c * (a * -4.0))) - b);
} 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 <= (-7.8d-28)) then
tmp = (c / b) - (b / a)
else if (b <= 3.5d-50) then
tmp = (0.5d0 / a) * (sqrt((c * (a * (-4.0d0)))) - b)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7.8e-28) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-50) {
tmp = (0.5 / a) * (Math.sqrt((c * (a * -4.0))) - b);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.8e-28: tmp = (c / b) - (b / a) elif b <= 3.5e-50: tmp = (0.5 / a) * (math.sqrt((c * (a * -4.0))) - b) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.8e-28) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.5e-50) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(c * Float64(a * -4.0))) - b)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.8e-28) tmp = (c / b) - (b / a); elseif (b <= 3.5e-50) tmp = (0.5 / a) * (sqrt((c * (a * -4.0))) - b); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.8e-28], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-50], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.8 \cdot 10^{-28}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-50}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{c \cdot \left(a \cdot -4\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -7.79999999999999998e-28Initial program 67.8%
*-commutative67.8%
Simplified67.8%
Taylor expanded in b around -inf 96.6%
mul-1-neg96.6%
*-commutative96.6%
distribute-rgt-neg-in96.6%
+-commutative96.6%
mul-1-neg96.6%
unsub-neg96.6%
Simplified96.6%
Taylor expanded in a around inf 96.9%
neg-mul-196.9%
distribute-frac-neg96.9%
+-commutative96.9%
distribute-frac-neg96.9%
unsub-neg96.9%
Simplified96.9%
if -7.79999999999999998e-28 < b < 3.49999999999999997e-50Initial program 83.8%
*-commutative83.8%
Simplified83.8%
div-sub83.8%
sub-neg83.8%
div-inv83.6%
pow283.6%
*-commutative83.6%
associate-/r*83.6%
metadata-eval83.6%
div-inv83.6%
*-commutative83.6%
associate-/r*83.6%
metadata-eval83.6%
Applied egg-rr83.6%
sub-neg83.6%
distribute-rgt-out--83.6%
Simplified83.6%
Taylor expanded in a around inf 74.7%
associate-*r*74.7%
*-commutative74.7%
Simplified74.7%
if 3.49999999999999997e-50 < b Initial program 18.4%
*-commutative18.4%
Simplified18.4%
Taylor expanded in a around 0 84.3%
associate-*r/84.3%
mul-1-neg84.3%
Simplified84.3%
Final simplification84.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (- (/ c b) (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (c / b) - (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 = (c / b) - (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 = (c / b) - (b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (c / b) - (b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (c / b) - (b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.4%
*-commutative74.4%
Simplified74.4%
Taylor expanded in b around -inf 66.4%
mul-1-neg66.4%
*-commutative66.4%
distribute-rgt-neg-in66.4%
+-commutative66.4%
mul-1-neg66.4%
unsub-neg66.4%
Simplified66.4%
Taylor expanded in a around inf 68.1%
neg-mul-168.1%
distribute-frac-neg68.1%
+-commutative68.1%
distribute-frac-neg68.1%
unsub-neg68.1%
Simplified68.1%
if -4.999999999999985e-310 < b Initial program 37.9%
*-commutative37.9%
Simplified37.9%
Taylor expanded in a around 0 64.0%
associate-*r/64.0%
mul-1-neg64.0%
Simplified64.0%
Final simplification66.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-289) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-289) {
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 <= 2.7d-289) 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 <= 2.7e-289) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-289: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-289) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.7e-289) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-289], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-289}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 2.7e-289Initial program 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in b around -inf 66.5%
associate-*r/66.5%
mul-1-neg66.5%
Simplified66.5%
if 2.7e-289 < b Initial program 36.9%
*-commutative36.9%
Simplified36.9%
Taylor expanded in a around 0 64.9%
associate-*r/64.9%
mul-1-neg64.9%
Simplified64.9%
Final simplification65.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.1e+46) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.1e+46) {
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 <= 1.1d+46) 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 <= 1.1e+46) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.1e+46: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.1e+46) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.1e+46) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.1e+46], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{+46}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.1e46Initial program 72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in b around -inf 47.6%
associate-*r/47.6%
mul-1-neg47.6%
Simplified47.6%
if 1.1e46 < b Initial program 13.5%
*-commutative13.5%
Simplified13.5%
Taylor expanded in b around -inf 2.8%
mul-1-neg2.8%
*-commutative2.8%
distribute-rgt-neg-in2.8%
+-commutative2.8%
mul-1-neg2.8%
unsub-neg2.8%
Simplified2.8%
Taylor expanded in a around inf 40.0%
Final simplification45.5%
(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 56.3%
*-commutative56.3%
Simplified56.3%
Taylor expanded in b around -inf 34.6%
mul-1-neg34.6%
*-commutative34.6%
distribute-rgt-neg-in34.6%
+-commutative34.6%
mul-1-neg34.6%
unsub-neg34.6%
Simplified34.6%
Taylor expanded in a around inf 13.1%
(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 56.3%
*-commutative56.3%
Simplified56.3%
Taylor expanded in b around -inf 35.5%
associate-*r/35.5%
mul-1-neg35.5%
Simplified35.5%
add-sqr-sqrt33.9%
sqrt-unprod24.9%
sqr-neg24.9%
sqrt-prod1.8%
add-exp-log1.8%
add-sqr-sqrt1.8%
Applied egg-rr1.8%
Taylor expanded in b around 0 2.4%
herbie shell --seed 2024158
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))