
(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 -6.8e+53)
(+ (/ (* b -0.6666666666666666) a) (* 0.5 (/ c b)))
(if (<= b 5.8e-40)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.8e+53) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 5.8e-40) {
tmp = (sqrt(((b * b) - (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 <= (-6.8d+53)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + (0.5d0 * (c / b))
else if (b <= 5.8d-40) then
tmp = (sqrt(((b * b) - (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 <= -6.8e+53) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 5.8e-40) {
tmp = (Math.sqrt(((b * b) - (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 <= -6.8e+53: tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)) elif b <= 5.8e-40: tmp = (math.sqrt(((b * b) - (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 <= -6.8e+53) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(0.5 * Float64(c / b))); elseif (b <= 5.8e-40) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - 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 <= -6.8e+53) tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)); elseif (b <= 5.8e-40) tmp = (sqrt(((b * b) - (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, -6.8e+53], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e-40], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $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 -6.8 \cdot 10^{+53}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 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 < -6.79999999999999995e53Initial program 63.8%
sqr-neg63.8%
sqr-neg63.8%
associate-*l*63.8%
Simplified63.8%
Taylor expanded in b around -inf 95.0%
associate-*r/95.0%
Applied egg-rr95.0%
if -6.79999999999999995e53 < b < 5.7999999999999998e-40Initial program 86.5%
neg-sub086.5%
sqr-neg86.5%
associate-+l-86.5%
sub0-neg86.5%
neg-mul-186.5%
Simplified86.4%
associate-*r*86.4%
metadata-eval86.4%
distribute-rgt-neg-in86.4%
*-commutative86.4%
fma-neg86.4%
associate-*r*86.4%
*-commutative86.4%
associate-*l*86.4%
Applied egg-rr86.4%
*-commutative86.4%
Simplified86.4%
div-inv86.3%
div-inv86.3%
metadata-eval86.3%
Applied egg-rr86.3%
Taylor expanded in a around 0 86.3%
*-commutative86.3%
*-commutative86.3%
associate-*l*86.4%
Simplified86.4%
un-div-inv86.5%
Applied egg-rr86.5%
if 5.7999999999999998e-40 < b Initial program 13.8%
sqr-neg13.8%
sqr-neg13.8%
associate-*l*13.7%
Simplified13.7%
Taylor expanded in b around inf 89.4%
Final simplification89.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e+51)
(+ (/ (* b -0.6666666666666666) a) (* 0.5 (/ c b)))
(if (<= b 5.8e-40)
(* 0.3333333333333333 (/ (- (sqrt (- (* b b) (* a (* c 3.0)))) b) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e+51) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 5.8e-40) {
tmp = 0.3333333333333333 * ((sqrt(((b * b) - (a * (c * 3.0)))) - b) / 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 <= (-1.5d+51)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + (0.5d0 * (c / b))
else if (b <= 5.8d-40) then
tmp = 0.3333333333333333d0 * ((sqrt(((b * b) - (a * (c * 3.0d0)))) - b) / 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 <= -1.5e+51) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 5.8e-40) {
tmp = 0.3333333333333333 * ((Math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e+51: tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)) elif b <= 5.8e-40: tmp = 0.3333333333333333 * ((math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e+51) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(0.5 * Float64(c / b))); elseif (b <= 5.8e-40) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 3.0)))) - b) / 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 <= -1.5e+51) tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)); elseif (b <= 5.8e-40) tmp = 0.3333333333333333 * ((sqrt(((b * b) - (a * (c * 3.0)))) - b) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e+51], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e-40], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{+51}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-40}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.5e51Initial program 64.4%
sqr-neg64.4%
sqr-neg64.4%
associate-*l*64.4%
Simplified64.4%
Taylor expanded in b around -inf 95.0%
associate-*r/95.1%
Applied egg-rr95.1%
if -1.5e51 < b < 5.7999999999999998e-40Initial program 86.4%
neg-sub086.4%
sqr-neg86.4%
associate-+l-86.4%
sub0-neg86.4%
neg-mul-186.4%
Simplified86.3%
associate-*r*86.3%
metadata-eval86.3%
distribute-rgt-neg-in86.3%
*-commutative86.3%
fma-neg86.3%
associate-*r*86.2%
*-commutative86.2%
associate-*l*86.3%
Applied egg-rr86.3%
*-commutative86.3%
Simplified86.3%
associate-/r/86.1%
Applied egg-rr86.1%
if 5.7999999999999998e-40 < b Initial program 13.8%
sqr-neg13.8%
sqr-neg13.8%
associate-*l*13.7%
Simplified13.7%
Taylor expanded in b around inf 89.4%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e+51)
(+ (/ (* b -0.6666666666666666) a) (* 0.5 (/ c b)))
(if (<= b 5.6e-40)
(/ (- (sqrt (- (* b b) (* a (* c 3.0)))) b) (/ a 0.3333333333333333))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e+51) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 5.6e-40) {
tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333);
} 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 <= (-1.5d+51)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + (0.5d0 * (c / b))
else if (b <= 5.6d-40) then
tmp = (sqrt(((b * b) - (a * (c * 3.0d0)))) - b) / (a / 0.3333333333333333d0)
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 <= -1.5e+51) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 5.6e-40) {
tmp = (Math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e+51: tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)) elif b <= 5.6e-40: tmp = (math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e+51) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(0.5 * Float64(c / b))); elseif (b <= 5.6e-40) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 3.0)))) - b) / Float64(a / 0.3333333333333333)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.5e+51) tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)); elseif (b <= 5.6e-40) tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e+51], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-40], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a / 0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{+51}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{\frac{a}{0.3333333333333333}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.5e51Initial program 64.4%
sqr-neg64.4%
sqr-neg64.4%
associate-*l*64.4%
Simplified64.4%
Taylor expanded in b around -inf 95.0%
associate-*r/95.1%
Applied egg-rr95.1%
if -1.5e51 < b < 5.5999999999999999e-40Initial program 86.4%
neg-sub086.4%
sqr-neg86.4%
associate-+l-86.4%
sub0-neg86.4%
neg-mul-186.4%
Simplified86.3%
associate-*r*86.3%
metadata-eval86.3%
distribute-rgt-neg-in86.3%
*-commutative86.3%
fma-neg86.3%
associate-*r*86.2%
*-commutative86.2%
associate-*l*86.3%
Applied egg-rr86.3%
*-commutative86.3%
Simplified86.3%
if 5.5999999999999999e-40 < b Initial program 13.8%
sqr-neg13.8%
sqr-neg13.8%
associate-*l*13.7%
Simplified13.7%
Taylor expanded in b around inf 89.4%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e-90)
(+ (/ (* b -0.6666666666666666) a) (* 0.5 (/ c b)))
(if (<= b 1.1e-97)
(/ (- (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 <= -4.8e-90) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 1.1e-97) {
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 <= (-4.8d-90)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + (0.5d0 * (c / b))
else if (b <= 1.1d-97) 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 <= -4.8e-90) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 1.1e-97) {
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 <= -4.8e-90: tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)) elif b <= 1.1e-97: 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 <= -4.8e-90) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.1e-97) 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 <= -4.8e-90) tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)); elseif (b <= 1.1e-97) 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, -4.8e-90], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-97], 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 -4.8 \cdot 10^{-90}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-97}:\\
\;\;\;\;\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 < -4.8000000000000003e-90Initial program 76.3%
sqr-neg76.3%
sqr-neg76.3%
associate-*l*76.3%
Simplified76.3%
Taylor expanded in b around -inf 87.2%
associate-*r/87.3%
Applied egg-rr87.3%
if -4.8000000000000003e-90 < b < 1.0999999999999999e-97Initial program 85.1%
sqr-neg85.1%
sqr-neg85.1%
associate-*l*84.9%
Simplified84.9%
Taylor expanded in b around 0 82.1%
associate-*r*82.2%
*-commutative82.2%
associate-*l*82.1%
Simplified82.1%
if 1.0999999999999999e-97 < b Initial program 16.6%
sqr-neg16.6%
sqr-neg16.6%
associate-*l*16.5%
Simplified16.5%
Taylor expanded in b around inf 86.1%
Final simplification85.7%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / 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 <= (-4d-310)) then
tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / 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 <= -4e-310) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / 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 <= -4e-310) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 78.3%
sqr-neg78.3%
sqr-neg78.3%
associate-*l*78.3%
Simplified78.3%
Taylor expanded in b around -inf 72.9%
if -3.999999999999988e-310 < b Initial program 33.0%
sqr-neg33.0%
sqr-neg33.0%
associate-*l*33.0%
Simplified33.0%
Taylor expanded in b around inf 68.6%
Final simplification70.7%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (+ (/ (* b -0.6666666666666666) a) (* 0.5 (/ c b))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} 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 <= (-4d-310)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + (0.5d0 * (c / b))
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 <= -4e-310) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(0.5 * Float64(c / b))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 78.3%
sqr-neg78.3%
sqr-neg78.3%
associate-*l*78.3%
Simplified78.3%
Taylor expanded in b around -inf 72.9%
associate-*r/73.0%
Applied egg-rr73.0%
if -3.999999999999988e-310 < b Initial program 33.0%
sqr-neg33.0%
sqr-neg33.0%
associate-*l*33.0%
Simplified33.0%
Taylor expanded in b around inf 68.6%
Final simplification70.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.5e-308) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.5e-308) {
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 <= 1.5d-308) 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 <= 1.5e-308) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.5e-308: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.5e-308) 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 <= 1.5e-308) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.5e-308], 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 1.5 \cdot 10^{-308}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.4999999999999999e-308Initial program 78.3%
neg-sub078.3%
sqr-neg78.3%
associate-+l-78.3%
sub0-neg78.3%
neg-mul-178.3%
Simplified78.2%
associate-*r*78.3%
metadata-eval78.3%
distribute-rgt-neg-in78.3%
*-commutative78.3%
fma-neg78.3%
associate-*r*78.3%
*-commutative78.3%
associate-*l*78.2%
Applied egg-rr78.2%
*-commutative78.2%
Simplified78.2%
div-inv78.1%
div-inv78.2%
metadata-eval78.2%
Applied egg-rr78.2%
Taylor expanded in b around -inf 72.6%
associate-*r/72.7%
associate-/l*72.7%
associate-/r/72.7%
Simplified72.7%
if 1.4999999999999999e-308 < b Initial program 33.0%
sqr-neg33.0%
sqr-neg33.0%
associate-*l*33.0%
Simplified33.0%
Taylor expanded in b around inf 68.6%
Final simplification70.5%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ -0.6666666666666666 (/ a b)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = -0.6666666666666666 / (a / b);
} 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 <= (-4d-310)) then
tmp = (-0.6666666666666666d0) / (a / b)
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 <= -4e-310) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = -0.6666666666666666 / (a / b) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(-0.6666666666666666 / Float64(a / b)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = -0.6666666666666666 / (a / b); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 78.3%
neg-sub078.3%
sqr-neg78.3%
associate-+l-78.3%
sub0-neg78.3%
neg-mul-178.3%
Simplified78.2%
associate-*r*78.3%
metadata-eval78.3%
distribute-rgt-neg-in78.3%
*-commutative78.3%
fma-neg78.3%
associate-*r*78.3%
*-commutative78.3%
associate-*l*78.2%
Applied egg-rr78.2%
*-commutative78.2%
Simplified78.2%
Taylor expanded in b around -inf 72.6%
associate-*r/72.7%
associate-/l*72.7%
Simplified72.7%
if -3.999999999999988e-310 < b Initial program 33.0%
sqr-neg33.0%
sqr-neg33.0%
associate-*l*33.0%
Simplified33.0%
Taylor expanded in b around inf 68.6%
Final simplification70.6%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ (* b -0.6666666666666666) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-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 <= (-4d-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 <= -4e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (b * -0.6666666666666666) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(b * -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 <= -4e-310) tmp = (b * -0.6666666666666666) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 78.3%
neg-sub078.3%
sqr-neg78.3%
associate-+l-78.3%
sub0-neg78.3%
neg-mul-178.3%
Simplified78.2%
associate-*r*78.3%
metadata-eval78.3%
distribute-rgt-neg-in78.3%
*-commutative78.3%
fma-neg78.3%
associate-*r*78.3%
*-commutative78.3%
associate-*l*78.2%
Applied egg-rr78.2%
*-commutative78.2%
Simplified78.2%
div-inv78.1%
div-inv78.2%
metadata-eval78.2%
Applied egg-rr78.2%
Taylor expanded in b around -inf 72.6%
associate-*r/72.7%
associate-/l*72.7%
associate-/r/72.7%
Simplified72.7%
associate-*l/72.7%
*-commutative72.7%
Applied egg-rr72.7%
if -3.999999999999988e-310 < b Initial program 33.0%
sqr-neg33.0%
sqr-neg33.0%
associate-*l*33.0%
Simplified33.0%
Taylor expanded in b around inf 68.6%
Final simplification70.6%
(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 55.0%
sqr-neg55.0%
sqr-neg55.0%
associate-*l*54.9%
Simplified54.9%
Taylor expanded in b around inf 36.5%
Final simplification36.5%
herbie shell --seed 2023292
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))