
(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 13 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+139)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.4e-92)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+139) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.4e-92) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * 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+139)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.4d-92) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * 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+139) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.4e-92) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+139: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.4e-92: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+139) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.4e-92) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+139) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.4e-92) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+139], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-92], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+139}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.0000000000000003e139Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Taylor expanded in b around -inf 90.5%
*-commutative90.5%
Simplified90.5%
if -5.0000000000000003e139 < b < 1.4e-92Initial program 88.5%
if 1.4e-92 < b Initial program 18.7%
sqr-neg18.7%
sqr-neg18.7%
associate-*l*18.7%
Simplified18.7%
frac-2neg18.7%
div-inv18.7%
Applied egg-rr18.7%
Taylor expanded in b around inf 86.2%
associate-*r/86.2%
*-commutative86.2%
Simplified86.2%
Final simplification87.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+140)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.85e-92)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+140) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.85e-92) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * 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 <= (-2d+140)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.85d-92) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (3.0d0 * 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 <= -2e+140) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.85e-92) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e+140: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.85e-92: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e+140) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.85e-92) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e+140) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.85e-92) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e+140], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.85e-92], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+140}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.85 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.00000000000000012e140Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Taylor expanded in b around -inf 90.5%
*-commutative90.5%
Simplified90.5%
if -2.00000000000000012e140 < b < 2.85000000000000004e-92Initial program 88.5%
sqr-neg88.5%
sqr-neg88.5%
associate-*l*88.3%
Simplified88.3%
if 2.85000000000000004e-92 < b Initial program 18.7%
sqr-neg18.7%
sqr-neg18.7%
associate-*l*18.7%
Simplified18.7%
frac-2neg18.7%
div-inv18.7%
Applied egg-rr18.7%
Taylor expanded in b around inf 86.2%
associate-*r/86.2%
*-commutative86.2%
Simplified86.2%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-62)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 3e-92)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-62) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3e-92) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * 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-62)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 3d-92) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * 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-62) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3e-92) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-62: tmp = (b * -2.0) / (3.0 * a) elif b <= 3e-92: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-62) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 3e-92) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-62) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 3e-92) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-62], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3e-92], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-62}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.0000000000000002e-62Initial program 62.1%
sqr-neg62.1%
sqr-neg62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in b around -inf 85.1%
*-commutative85.1%
Simplified85.1%
if -5.0000000000000002e-62 < b < 3.00000000000000013e-92Initial program 85.5%
sqr-neg85.5%
sqr-neg85.5%
associate-*l*85.2%
Simplified85.2%
Taylor expanded in b around 0 78.5%
+-commutative78.5%
unsub-neg78.5%
associate-*r*78.8%
*-commutative78.8%
*-commutative78.8%
Applied egg-rr78.8%
if 3.00000000000000013e-92 < b Initial program 18.7%
sqr-neg18.7%
sqr-neg18.7%
associate-*l*18.7%
Simplified18.7%
frac-2neg18.7%
div-inv18.7%
Applied egg-rr18.7%
Taylor expanded in b around inf 86.2%
associate-*r/86.2%
*-commutative86.2%
Simplified86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.95e-65)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.4e-92)
(* (/ -0.3333333333333333 a) (- b (sqrt (* c (* a -3.0)))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.95e-65) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.4e-92) {
tmp = (-0.3333333333333333 / a) * (b - sqrt((c * (a * -3.0))));
} 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 <= (-1.95d-65)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.4d-92) then
tmp = ((-0.3333333333333333d0) / a) * (b - sqrt((c * (a * (-3.0d0)))))
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 <= -1.95e-65) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.4e-92) {
tmp = (-0.3333333333333333 / a) * (b - Math.sqrt((c * (a * -3.0))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.95e-65: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.4e-92: tmp = (-0.3333333333333333 / a) * (b - math.sqrt((c * (a * -3.0)))) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.95e-65) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.4e-92) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(c * Float64(a * -3.0))))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.95e-65) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.4e-92) tmp = (-0.3333333333333333 / a) * (b - sqrt((c * (a * -3.0)))); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.95e-65], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-92], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.95 \cdot 10^{-65}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-92}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.9500000000000002e-65Initial program 62.1%
sqr-neg62.1%
sqr-neg62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in b around -inf 85.1%
*-commutative85.1%
Simplified85.1%
if -1.9500000000000002e-65 < b < 1.4e-92Initial program 85.5%
sqr-neg85.5%
sqr-neg85.5%
associate-*l*85.2%
Simplified85.2%
Taylor expanded in b around 0 78.5%
frac-2neg78.5%
div-inv78.4%
distribute-neg-in78.4%
add-sqr-sqrt31.1%
sqrt-unprod77.7%
sqr-neg77.7%
sqrt-unprod47.2%
add-sqr-sqrt76.4%
sub-neg76.4%
add-sqr-sqrt29.3%
sqrt-unprod76.7%
sqr-neg76.7%
sqrt-unprod47.3%
add-sqr-sqrt78.4%
associate-*r*78.8%
*-commutative78.8%
*-commutative78.8%
distribute-lft-neg-in78.8%
metadata-eval78.8%
*-commutative78.8%
associate-/r*78.5%
Applied egg-rr78.5%
*-commutative78.5%
associate-*l/78.6%
metadata-eval78.6%
Simplified78.6%
if 1.4e-92 < b Initial program 18.7%
sqr-neg18.7%
sqr-neg18.7%
associate-*l*18.7%
Simplified18.7%
frac-2neg18.7%
div-inv18.7%
Applied egg-rr18.7%
Taylor expanded in b around inf 86.2%
associate-*r/86.2%
*-commutative86.2%
Simplified86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -3e-120)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.4e-95)
(* 0.3333333333333333 (/ (+ b (sqrt (* c (* a -3.0)))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e-120) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.4e-95) {
tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / 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 <= (-3d-120)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.4d-95) then
tmp = 0.3333333333333333d0 * ((b + sqrt((c * (a * (-3.0d0))))) / 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 <= -3e-120) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.4e-95) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e-120: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.4e-95: tmp = 0.3333333333333333 * ((b + math.sqrt((c * (a * -3.0)))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e-120) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.4e-95) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3e-120) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.4e-95) tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e-120], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-95], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{-120}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-95}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.00000000000000011e-120Initial program 64.9%
sqr-neg64.9%
sqr-neg64.9%
associate-*l*64.9%
Simplified64.9%
Taylor expanded in b around -inf 81.2%
*-commutative81.2%
Simplified81.2%
if -3.00000000000000011e-120 < b < 2.4e-95Initial program 85.0%
sqr-neg85.0%
sqr-neg85.0%
associate-*l*84.6%
Simplified84.6%
Taylor expanded in b around 0 82.1%
*-un-lft-identity82.1%
times-frac82.1%
metadata-eval82.1%
add-sqr-sqrt27.9%
sqrt-unprod81.3%
sqr-neg81.3%
sqrt-unprod54.0%
add-sqr-sqrt80.9%
associate-*r*81.0%
*-commutative81.0%
*-commutative81.0%
Applied egg-rr81.0%
if 2.4e-95 < b Initial program 18.7%
sqr-neg18.7%
sqr-neg18.7%
associate-*l*18.7%
Simplified18.7%
frac-2neg18.7%
div-inv18.7%
Applied egg-rr18.7%
Taylor expanded in b around inf 86.2%
associate-*r/86.2%
*-commutative86.2%
Simplified86.2%
(FPCore (a b c) :precision binary64 (if (<= b 2e-309) (/ (* b -2.0) (* 3.0 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2e-309) {
tmp = (b * -2.0) / (3.0 * 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 <= 2d-309) then
tmp = (b * (-2.0d0)) / (3.0d0 * 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 <= 2e-309) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2e-309: tmp = (b * -2.0) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2e-309) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2e-309) tmp = (b * -2.0) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2e-309], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{-309}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.9999999999999988e-309Initial program 68.2%
sqr-neg68.2%
sqr-neg68.2%
associate-*l*68.1%
Simplified68.1%
Taylor expanded in b around -inf 67.2%
*-commutative67.2%
Simplified67.2%
if 1.9999999999999988e-309 < b Initial program 37.3%
sqr-neg37.3%
sqr-neg37.3%
associate-*l*37.2%
Simplified37.2%
frac-2neg37.2%
div-inv37.2%
Applied egg-rr37.3%
Taylor expanded in b around inf 65.1%
associate-*r/65.1%
*-commutative65.1%
Simplified65.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-311) (* (* b (/ 1.0 a)) -0.6666666666666666) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-311) {
tmp = (b * (1.0 / a)) * -0.6666666666666666;
} 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-311)) then
tmp = (b * (1.0d0 / a)) * (-0.6666666666666666d0)
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-311) {
tmp = (b * (1.0 / a)) * -0.6666666666666666;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-311: tmp = (b * (1.0 / a)) * -0.6666666666666666 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-311) tmp = Float64(Float64(b * Float64(1.0 / a)) * -0.6666666666666666); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-311) tmp = (b * (1.0 / a)) * -0.6666666666666666; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-311], N[(N[(b * N[(1.0 / a), $MachinePrecision]), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\left(b \cdot \frac{1}{a}\right) \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.00000000000023e-311Initial program 68.2%
sqr-neg68.2%
sqr-neg68.2%
associate-*l*68.1%
Simplified68.1%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
div-inv67.1%
Applied egg-rr67.1%
if -5.00000000000023e-311 < b Initial program 37.3%
sqr-neg37.3%
sqr-neg37.3%
associate-*l*37.2%
Simplified37.2%
frac-2neg37.2%
div-inv37.2%
Applied egg-rr37.3%
Taylor expanded in b around inf 65.1%
associate-*r/65.1%
*-commutative65.1%
Simplified65.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-311) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-311) {
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-311)) 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-311) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-311: tmp = (b * -0.6666666666666666) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-311) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-311) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-311], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.00000000000023e-311Initial program 68.2%
sqr-neg68.2%
sqr-neg68.2%
associate-*l*68.1%
Simplified68.1%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
associate-*l/67.1%
Applied egg-rr67.1%
if -5.00000000000023e-311 < b Initial program 37.3%
sqr-neg37.3%
sqr-neg37.3%
associate-*l*37.2%
Simplified37.2%
frac-2neg37.2%
div-inv37.2%
Applied egg-rr37.3%
Taylor expanded in b around inf 65.1%
associate-*r/65.1%
*-commutative65.1%
Simplified65.1%
(FPCore (a b c) :precision binary64 (if (<= b 6.5e-309) (/ (* b -0.6666666666666666) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e-309) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (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 <= 6.5d-309) then
tmp = (b * (-0.6666666666666666d0)) / a
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e-309) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.5e-309: tmp = (b * -0.6666666666666666) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.5e-309) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.5e-309) tmp = (b * -0.6666666666666666) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.5e-309], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5 \cdot 10^{-309}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.4999999999999999e-309Initial program 68.2%
sqr-neg68.2%
sqr-neg68.2%
associate-*l*68.1%
Simplified68.1%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
associate-*l/67.1%
Applied egg-rr67.1%
if 6.4999999999999999e-309 < b Initial program 37.3%
sqr-neg37.3%
sqr-neg37.3%
associate-*l*37.2%
Simplified37.2%
Taylor expanded in b around inf 65.1%
*-commutative65.1%
Simplified65.1%
Final simplification65.9%
(FPCore (a b c) :precision binary64 (if (<= b 4.5e-309) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.5e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (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 <= 4.5d-309) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 4.5e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.5e-309: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.5e-309) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 4.5e-309) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.5e-309], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.5 \cdot 10^{-309}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 4.5000000000000011e-309Initial program 68.2%
sqr-neg68.2%
sqr-neg68.2%
associate-*l*68.1%
Simplified68.1%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
if 4.5000000000000011e-309 < b Initial program 37.3%
sqr-neg37.3%
sqr-neg37.3%
associate-*l*37.2%
Simplified37.2%
Taylor expanded in b around inf 65.1%
*-commutative65.1%
Simplified65.1%
Final simplification65.9%
(FPCore (a b c) :precision binary64 (if (<= b -2.5e-299) (* -0.6666666666666666 (/ b a)) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e-299) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.5d-299)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e-299) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.5e-299: tmp = -0.6666666666666666 * (b / a) else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.5e-299) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.5e-299) tmp = -0.6666666666666666 * (b / a); else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.5e-299], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{-299}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -2.49999999999999978e-299Initial program 67.9%
sqr-neg67.9%
sqr-neg67.9%
associate-*l*67.8%
Simplified67.8%
Taylor expanded in b around -inf 67.6%
*-commutative67.6%
Simplified67.6%
if -2.49999999999999978e-299 < b Initial program 37.7%
sqr-neg37.7%
sqr-neg37.7%
associate-*l*37.6%
Simplified37.6%
frac-2neg37.6%
div-inv37.6%
Applied egg-rr37.7%
*-commutative37.7%
sub-neg37.7%
distribute-lft-in37.4%
associate-/r*35.5%
div-inv34.6%
metadata-eval34.6%
associate-/r*35.1%
div-inv37.3%
metadata-eval37.3%
fma-undefine37.3%
*-commutative37.3%
*-commutative37.3%
associate-*r*37.3%
add-sqr-sqrt33.6%
hypot-define35.4%
associate-*r*35.4%
*-commutative35.4%
*-commutative35.4%
Applied egg-rr35.4%
Taylor expanded in c around 0 11.4%
distribute-rgt-out11.4%
metadata-eval11.4%
mul0-rgt16.2%
Simplified16.2%
Final simplification37.7%
(FPCore (a b c) :precision binary64 (if (<= b -2.5e-299) (* b (/ -0.6666666666666666 a)) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e-299) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.5d-299)) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e-299) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.5e-299: tmp = b * (-0.6666666666666666 / a) else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.5e-299) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.5e-299) tmp = b * (-0.6666666666666666 / a); else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.5e-299], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{-299}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -2.49999999999999978e-299Initial program 67.9%
sqr-neg67.9%
sqr-neg67.9%
associate-*l*67.8%
Simplified67.8%
Taylor expanded in b around -inf 67.6%
*-commutative67.6%
Simplified67.6%
*-commutative67.6%
clear-num67.6%
un-div-inv67.6%
Applied egg-rr67.6%
associate-/r/67.6%
Simplified67.6%
if -2.49999999999999978e-299 < b Initial program 37.7%
sqr-neg37.7%
sqr-neg37.7%
associate-*l*37.6%
Simplified37.6%
frac-2neg37.6%
div-inv37.6%
Applied egg-rr37.7%
*-commutative37.7%
sub-neg37.7%
distribute-lft-in37.4%
associate-/r*35.5%
div-inv34.6%
metadata-eval34.6%
associate-/r*35.1%
div-inv37.3%
metadata-eval37.3%
fma-undefine37.3%
*-commutative37.3%
*-commutative37.3%
associate-*r*37.3%
add-sqr-sqrt33.6%
hypot-define35.4%
associate-*r*35.4%
*-commutative35.4%
*-commutative35.4%
Applied egg-rr35.4%
Taylor expanded in c around 0 11.4%
distribute-rgt-out11.4%
metadata-eval11.4%
mul0-rgt16.2%
Simplified16.2%
Final simplification37.7%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 50.3%
sqr-neg50.3%
sqr-neg50.3%
associate-*l*50.2%
Simplified50.2%
frac-2neg50.2%
div-inv50.2%
Applied egg-rr50.3%
*-commutative50.3%
sub-neg50.3%
distribute-lft-in50.2%
associate-/r*49.0%
div-inv48.5%
metadata-eval48.5%
associate-/r*48.8%
div-inv50.0%
metadata-eval50.0%
fma-undefine50.0%
*-commutative50.0%
*-commutative50.0%
associate-*r*50.0%
add-sqr-sqrt43.1%
hypot-define50.1%
associate-*r*50.1%
*-commutative50.1%
*-commutative50.1%
Applied egg-rr50.1%
Taylor expanded in c around 0 7.7%
distribute-rgt-out7.7%
metadata-eval7.7%
mul0-rgt10.6%
Simplified10.6%
herbie shell --seed 2024137
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))