
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \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) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -5e+118)
(/ b (* a -1.5))
(if (<= b 4.1e-132)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+118) {
tmp = b / (a * -1.5);
} else if (b <= 4.1e-132) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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+118)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4.1d-132) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+118) {
tmp = b / (a * -1.5);
} else if (b <= 4.1e-132) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+118: tmp = b / (a * -1.5) elif b <= 4.1e-132: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+118) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4.1e-132) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+118) tmp = b / (a * -1.5); elseif (b <= 4.1e-132) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+118], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.1e-132], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+118}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4.1 \cdot 10^{-132}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.99999999999999972e118Initial program 49.3%
sqr-neg49.3%
sqr-neg49.3%
associate-*l*49.3%
Simplified49.3%
Applied egg-rr46.7%
Taylor expanded in b around -inf 96.6%
*-commutative96.6%
associate-*l/96.6%
associate-/l*96.5%
Simplified96.5%
clear-num96.6%
un-div-inv96.7%
div-inv96.7%
metadata-eval96.7%
Applied egg-rr96.7%
if -4.99999999999999972e118 < b < 4.10000000000000007e-132Initial program 87.1%
if 4.10000000000000007e-132 < b Initial program 19.9%
sqr-neg19.9%
sqr-neg19.9%
associate-*l*19.9%
Simplified19.9%
Taylor expanded in b around inf 83.9%
*-commutative83.9%
Simplified83.9%
Final simplification87.5%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+118)
(/ b (* a -1.5))
(if (<= b 3.9e-132)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+118) {
tmp = b / (a * -1.5);
} else if (b <= 3.9e-132) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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+118)) then
tmp = b / (a * (-1.5d0))
else if (b <= 3.9d-132) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+118) {
tmp = b / (a * -1.5);
} else if (b <= 3.9e-132) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+118: tmp = b / (a * -1.5) elif b <= 3.9e-132: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+118) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 3.9e-132) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+118) tmp = b / (a * -1.5); elseif (b <= 3.9e-132) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+118], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.9e-132], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+118}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-132}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.99999999999999972e118Initial program 49.3%
sqr-neg49.3%
sqr-neg49.3%
associate-*l*49.3%
Simplified49.3%
Applied egg-rr46.7%
Taylor expanded in b around -inf 96.6%
*-commutative96.6%
associate-*l/96.6%
associate-/l*96.5%
Simplified96.5%
clear-num96.6%
un-div-inv96.7%
div-inv96.7%
metadata-eval96.7%
Applied egg-rr96.7%
if -4.99999999999999972e118 < b < 3.89999999999999982e-132Initial program 87.1%
sqr-neg87.1%
sqr-neg87.1%
associate-*l*87.0%
Simplified87.0%
if 3.89999999999999982e-132 < b Initial program 19.9%
sqr-neg19.9%
sqr-neg19.9%
associate-*l*19.9%
Simplified19.9%
Taylor expanded in b around inf 83.9%
*-commutative83.9%
Simplified83.9%
Final simplification87.5%
(FPCore (a b c)
:precision binary64
(if (<= b -4.7e-38)
(/ b (* a -1.5))
(if (<= b 7.5e-145)
(* (/ -0.3333333333333333 a) (- b (sqrt (* c (* a -3.0)))))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.7e-38) {
tmp = b / (a * -1.5);
} else if (b <= 7.5e-145) {
tmp = (-0.3333333333333333 / a) * (b - sqrt((c * (a * -3.0))));
} else {
tmp = (c / b) * -0.5;
}
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 <= (-4.7d-38)) then
tmp = b / (a * (-1.5d0))
else if (b <= 7.5d-145) then
tmp = ((-0.3333333333333333d0) / a) * (b - sqrt((c * (a * (-3.0d0)))))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.7e-38) {
tmp = b / (a * -1.5);
} else if (b <= 7.5e-145) {
tmp = (-0.3333333333333333 / a) * (b - Math.sqrt((c * (a * -3.0))));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.7e-38: tmp = b / (a * -1.5) elif b <= 7.5e-145: tmp = (-0.3333333333333333 / a) * (b - math.sqrt((c * (a * -3.0)))) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.7e-38) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 7.5e-145) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(c * Float64(a * -3.0))))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.7e-38) tmp = b / (a * -1.5); elseif (b <= 7.5e-145) tmp = (-0.3333333333333333 / a) * (b - sqrt((c * (a * -3.0)))); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.7e-38], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-145], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.7 \cdot 10^{-38}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-145}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.69999999999999998e-38Initial program 69.9%
sqr-neg69.9%
sqr-neg69.9%
associate-*l*69.9%
Simplified69.9%
Applied egg-rr59.3%
Taylor expanded in b around -inf 87.1%
*-commutative87.1%
associate-*l/87.1%
associate-/l*87.1%
Simplified87.1%
clear-num87.0%
un-div-inv87.1%
div-inv87.2%
metadata-eval87.2%
Applied egg-rr87.2%
if -4.69999999999999998e-38 < b < 7.4999999999999996e-145Initial program 83.9%
Taylor expanded in b around 0 72.9%
*-commutative72.9%
associate-*r*72.9%
Simplified72.9%
frac-2neg72.9%
div-inv72.7%
distribute-neg-in72.7%
add-sqr-sqrt39.8%
sqrt-unprod72.6%
sqr-neg72.6%
sqrt-unprod33.0%
add-sqr-sqrt70.5%
sub-neg70.5%
add-sqr-sqrt37.5%
sqrt-unprod70.4%
sqr-neg70.4%
sqrt-unprod32.9%
add-sqr-sqrt72.7%
*-commutative72.7%
associate-*r*72.8%
distribute-lft-neg-in72.8%
metadata-eval72.8%
Applied egg-rr72.8%
*-commutative72.8%
associate-/r*72.6%
metadata-eval72.6%
*-commutative72.6%
Simplified72.6%
if 7.4999999999999996e-145 < b Initial program 20.6%
sqr-neg20.6%
sqr-neg20.6%
associate-*l*20.6%
Simplified20.6%
Taylor expanded in b around inf 83.4%
*-commutative83.4%
Simplified83.4%
Final simplification81.9%
(FPCore (a b c)
:precision binary64
(if (<= b -14800000000.0)
(/ b (* a -1.5))
(if (<= b 1.35e-144)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -14800000000.0) {
tmp = b / (a * -1.5);
} else if (b <= 1.35e-144) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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 <= (-14800000000.0d0)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.35d-144) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -14800000000.0) {
tmp = b / (a * -1.5);
} else if (b <= 1.35e-144) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -14800000000.0: tmp = b / (a * -1.5) elif b <= 1.35e-144: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -14800000000.0) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.35e-144) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -14800000000.0) tmp = b / (a * -1.5); elseif (b <= 1.35e-144) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -14800000000.0], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-144], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -14800000000:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-144}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.48e10Initial program 65.9%
sqr-neg65.9%
sqr-neg65.9%
associate-*l*65.9%
Simplified65.9%
Applied egg-rr53.4%
Taylor expanded in b around -inf 93.8%
*-commutative93.8%
associate-*l/93.8%
associate-/l*93.7%
Simplified93.7%
clear-num93.6%
un-div-inv93.7%
div-inv93.8%
metadata-eval93.8%
Applied egg-rr93.8%
if -1.48e10 < b < 1.34999999999999988e-144Initial program 85.3%
Taylor expanded in b around 0 69.2%
*-commutative69.2%
associate-*r*69.2%
Simplified69.2%
+-commutative69.2%
unsub-neg69.2%
*-commutative69.2%
associate-*r*69.3%
Applied egg-rr69.3%
associate-*r*69.2%
rem-square-sqrt0.0%
unpow20.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt69.2%
Simplified69.2%
if 1.34999999999999988e-144 < b Initial program 20.6%
sqr-neg20.6%
sqr-neg20.6%
associate-*l*20.6%
Simplified20.6%
Taylor expanded in b around inf 83.4%
*-commutative83.4%
Simplified83.4%
Final simplification81.9%
(FPCore (a b c)
:precision binary64
(if (<= b -14800000000.0)
(/ b (* a -1.5))
(if (<= b 1.18e-144)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -14800000000.0) {
tmp = b / (a * -1.5);
} else if (b <= 1.18e-144) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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 <= (-14800000000.0d0)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.18d-144) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -14800000000.0) {
tmp = b / (a * -1.5);
} else if (b <= 1.18e-144) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -14800000000.0: tmp = b / (a * -1.5) elif b <= 1.18e-144: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -14800000000.0) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.18e-144) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -14800000000.0) tmp = b / (a * -1.5); elseif (b <= 1.18e-144) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -14800000000.0], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.18e-144], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -14800000000:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.18 \cdot 10^{-144}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.48e10Initial program 65.9%
sqr-neg65.9%
sqr-neg65.9%
associate-*l*65.9%
Simplified65.9%
Applied egg-rr53.4%
Taylor expanded in b around -inf 93.8%
*-commutative93.8%
associate-*l/93.8%
associate-/l*93.7%
Simplified93.7%
clear-num93.6%
un-div-inv93.7%
div-inv93.8%
metadata-eval93.8%
Applied egg-rr93.8%
if -1.48e10 < b < 1.18e-144Initial program 85.3%
Taylor expanded in b around 0 69.2%
*-commutative69.2%
associate-*r*69.2%
Simplified69.2%
+-commutative69.2%
unsub-neg69.2%
*-commutative69.2%
associate-*r*69.3%
Applied egg-rr69.3%
*-commutative69.3%
Simplified69.3%
if 1.18e-144 < b Initial program 20.6%
sqr-neg20.6%
sqr-neg20.6%
associate-*l*20.6%
Simplified20.6%
Taylor expanded in b around inf 83.4%
*-commutative83.4%
Simplified83.4%
Final simplification82.0%
(FPCore (a b c) :precision binary64 (if (<= b 4.8e-5) (* b (/ -0.6666666666666666 a)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.8e-5) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
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 <= 4.8d-5) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = (c / b) * 0.5d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 4.8e-5) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.8e-5: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.8e-5) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(c / b) * 0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 4.8e-5) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.8e-5], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.8 \cdot 10^{-5}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 4.8000000000000001e-5Initial program 68.5%
sqr-neg68.5%
sqr-neg68.5%
associate-*l*68.4%
Simplified68.4%
Applied egg-rr61.7%
Taylor expanded in b around -inf 47.7%
*-commutative47.7%
associate-*l/47.7%
associate-/l*47.7%
Simplified47.7%
if 4.8000000000000001e-5 < b Initial program 18.0%
sqr-neg18.0%
sqr-neg18.0%
associate-*l*18.0%
Simplified18.0%
Taylor expanded in b around inf 70.2%
*-commutative70.2%
associate-/l*72.2%
associate-*r*72.3%
*-commutative72.3%
associate-*r/72.2%
Simplified72.2%
expm1-log1p-u62.7%
expm1-undefine35.6%
associate-/l*34.5%
associate-/l*34.5%
*-commutative34.5%
Applied egg-rr34.5%
expm1-define76.1%
associate-*r/62.7%
times-frac80.9%
*-inverses80.9%
*-commutative80.9%
Simplified80.9%
expm1-log1p-u90.5%
*-un-lft-identity90.5%
frac-2neg90.5%
associate-*l/90.3%
distribute-neg-frac290.3%
add-sqr-sqrt0.0%
sqrt-unprod30.7%
sqr-neg30.7%
sqrt-unprod30.2%
add-sqr-sqrt30.2%
metadata-eval30.2%
Applied egg-rr30.2%
associate-/l/30.2%
*-commutative30.2%
times-frac30.2%
metadata-eval30.2%
Simplified30.2%
Final simplification42.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / 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 * ((-0.6666666666666666d0) / a)
else
tmp = c * ((-0.5d0) / 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 * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 75.4%
sqr-neg75.4%
sqr-neg75.4%
associate-*l*75.4%
Simplified75.4%
Applied egg-rr66.4%
Taylor expanded in b around -inf 67.7%
*-commutative67.7%
associate-*l/67.7%
associate-/l*67.7%
Simplified67.7%
if -4.999999999999985e-310 < b Initial program 33.0%
sqr-neg33.0%
sqr-neg33.0%
associate-*l*33.0%
Simplified33.0%
Taylor expanded in b around inf 48.6%
*-commutative48.6%
associate-/l*53.7%
associate-*r*53.8%
*-commutative53.8%
associate-*r/53.7%
Simplified53.7%
expm1-log1p-u46.9%
expm1-undefine23.6%
associate-/l*22.1%
associate-/l*22.1%
*-commutative22.1%
Applied egg-rr22.1%
expm1-define56.5%
associate-*r/47.0%
times-frac60.3%
*-inverses60.3%
*-commutative60.3%
Simplified60.3%
expm1-log1p-u67.2%
*-un-lft-identity67.2%
associate-/l*67.3%
div-inv67.1%
associate-*l*67.1%
metadata-eval67.1%
Applied egg-rr67.1%
associate-*l/67.1%
metadata-eval67.1%
Simplified67.1%
Final simplification67.4%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
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 * ((-0.6666666666666666d0) / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 75.4%
sqr-neg75.4%
sqr-neg75.4%
associate-*l*75.4%
Simplified75.4%
Applied egg-rr66.4%
Taylor expanded in b around -inf 67.7%
*-commutative67.7%
associate-*l/67.7%
associate-/l*67.7%
Simplified67.7%
if -4.999999999999985e-310 < b Initial program 33.0%
sqr-neg33.0%
sqr-neg33.0%
associate-*l*33.0%
Simplified33.0%
Taylor expanded in b around inf 67.3%
*-commutative67.3%
Simplified67.3%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* a -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
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 * (-1.5d0))
else
tmp = (c / b) * (-0.5d0)
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 * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (a * -1.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b / (a * -1.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 75.4%
sqr-neg75.4%
sqr-neg75.4%
associate-*l*75.4%
Simplified75.4%
Applied egg-rr66.4%
Taylor expanded in b around -inf 67.7%
*-commutative67.7%
associate-*l/67.7%
associate-/l*67.7%
Simplified67.7%
clear-num67.6%
un-div-inv67.6%
div-inv67.8%
metadata-eval67.8%
Applied egg-rr67.8%
if -4.999999999999985e-310 < b Initial program 33.0%
sqr-neg33.0%
sqr-neg33.0%
associate-*l*33.0%
Simplified33.0%
Taylor expanded in b around inf 67.3%
*-commutative67.3%
Simplified67.3%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (* (/ c b) 0.5))
double code(double a, double b, double c) {
return (c / b) * 0.5;
}
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) * 0.5d0
end function
public static double code(double a, double b, double c) {
return (c / b) * 0.5;
}
def code(a, b, c): return (c / b) * 0.5
function code(a, b, c) return Float64(Float64(c / b) * 0.5) end
function tmp = code(a, b, c) tmp = (c / b) * 0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot 0.5
\end{array}
Initial program 53.7%
sqr-neg53.7%
sqr-neg53.7%
associate-*l*53.7%
Simplified53.7%
Taylor expanded in b around inf 25.8%
*-commutative25.8%
associate-/l*28.4%
associate-*r*28.5%
*-commutative28.5%
associate-*r/28.4%
Simplified28.4%
expm1-log1p-u24.9%
expm1-undefine13.0%
associate-/l*12.2%
associate-/l*12.2%
*-commutative12.2%
Applied egg-rr12.2%
expm1-define29.8%
associate-*r/24.9%
times-frac31.8%
*-inverses31.8%
*-commutative31.8%
Simplified31.8%
expm1-log1p-u35.3%
*-un-lft-identity35.3%
frac-2neg35.3%
associate-*l/35.3%
distribute-neg-frac235.3%
add-sqr-sqrt1.0%
sqrt-unprod10.2%
sqr-neg10.2%
sqrt-unprod9.2%
add-sqr-sqrt11.2%
metadata-eval11.2%
Applied egg-rr11.2%
associate-/l/11.2%
*-commutative11.2%
times-frac11.2%
metadata-eval11.2%
Simplified11.2%
Final simplification11.2%
herbie shell --seed 2024074
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))