
(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 12 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 -2.6e+94)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 3e-65)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e+94) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3e-65) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * 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 <= (-2.6d+94)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 3d-65) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * 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 <= -2.6e+94) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3e-65) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.6e+94: tmp = (b * -2.0) / (3.0 * a) elif b <= 3e-65: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.6e+94) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 3e-65) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * 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 <= -2.6e+94) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 3e-65) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.6e+94], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3e-65], 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 / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.6 \cdot 10^{+94}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-65}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.5999999999999999e94Initial program 52.8%
Simplified52.8%
Taylor expanded in b around -inf 93.1%
*-commutative93.1%
Simplified93.1%
if -2.5999999999999999e94 < b < 2.99999999999999998e-65Initial program 83.4%
if 2.99999999999999998e-65 < b Initial program 11.4%
sqr-neg11.4%
sqr-neg11.4%
associate-*l*11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(if (<= b -5.4e+94)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.1e-64)
(/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.4e+94) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.1e-64) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (3.0 * 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 <= (-5.4d+94)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.1d-64) then
tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (3.0d0 * 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 <= -5.4e+94) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.1e-64) {
tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.4e+94: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.1e-64: tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.4e+94) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.1e-64) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(3.0 * 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 <= -5.4e+94) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.1e-64) tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.4e+94], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-64], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.4 \cdot 10^{+94}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-64}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.4000000000000003e94Initial program 52.8%
Simplified52.8%
Taylor expanded in b around -inf 93.1%
*-commutative93.1%
Simplified93.1%
if -5.4000000000000003e94 < b < 1.1e-64Initial program 83.4%
Taylor expanded in a around 0 83.3%
metadata-eval83.3%
distribute-lft-neg-in83.3%
*-commutative83.3%
associate-*r*83.4%
distribute-rgt-neg-in83.4%
distribute-rgt-neg-in83.4%
metadata-eval83.4%
Simplified83.4%
if 1.1e-64 < b Initial program 11.4%
sqr-neg11.4%
sqr-neg11.4%
associate-*l*11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.7e+94)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1e-65)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e+94) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1e-65) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * 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 <= (-2.7d+94)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1d-65) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (3.0d0 * 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 <= -2.7e+94) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1e-65) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.7e+94: tmp = (b * -2.0) / (3.0 * a) elif b <= 1e-65: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.7e+94) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1e-65) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(3.0 * 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 <= -2.7e+94) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1e-65) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.7e+94], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-65], 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 / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{+94}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 10^{-65}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.7000000000000001e94Initial program 52.8%
Simplified52.8%
Taylor expanded in b around -inf 93.1%
*-commutative93.1%
Simplified93.1%
if -2.7000000000000001e94 < b < 9.99999999999999923e-66Initial program 83.4%
sqr-neg83.4%
sqr-neg83.4%
associate-*l*83.3%
Simplified83.3%
if 9.99999999999999923e-66 < b Initial program 11.4%
sqr-neg11.4%
sqr-neg11.4%
associate-*l*11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.8e-52)
(/ (* b -0.6666666666666666) a)
(if (<= b 2.1e-66)
(/ (- (sqrt (* a (* c -3.0))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.8e-52) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.1e-66) {
tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * 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.8d-52)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 2.1d-66) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (3.0d0 * 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.8e-52) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.1e-66) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.8e-52: tmp = (b * -0.6666666666666666) / a elif b <= 2.1e-66: tmp = (math.sqrt((a * (c * -3.0))) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.8e-52) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 2.1e-66) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(3.0 * 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.8e-52) tmp = (b * -0.6666666666666666) / a; elseif (b <= 2.1e-66) tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.8e-52], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.1e-66], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.8 \cdot 10^{-52}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.79999999999999994e-52Initial program 66.8%
sqr-neg66.8%
sqr-neg66.8%
associate-*l*66.8%
Simplified66.8%
Taylor expanded in b around -inf 86.1%
*-commutative86.1%
Simplified86.1%
associate-*l/86.2%
Applied egg-rr86.2%
if -1.79999999999999994e-52 < b < 2.1e-66Initial program 79.2%
sqr-neg79.2%
sqr-neg79.2%
associate-*l*79.1%
Simplified79.1%
Taylor expanded in b around 0 77.8%
*-commutative77.8%
associate-*r*77.9%
Simplified77.9%
if 2.1e-66 < b Initial program 11.4%
sqr-neg11.4%
sqr-neg11.4%
associate-*l*11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification83.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.7e-53)
(/ (* b -0.6666666666666666) a)
(if (<= b 2.9e-70)
(/ (- (sqrt (* (* a c) -3.0)) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e-53) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.9e-70) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * 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.7d-53)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 2.9d-70) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (3.0d0 * 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.7e-53) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.9e-70) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.7e-53: tmp = (b * -0.6666666666666666) / a elif b <= 2.9e-70: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.7e-53) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 2.9e-70) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(3.0 * 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.7e-53) tmp = (b * -0.6666666666666666) / a; elseif (b <= 2.9e-70) tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.7e-53], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.9e-70], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.7 \cdot 10^{-53}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-70}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.7e-53Initial program 66.8%
sqr-neg66.8%
sqr-neg66.8%
associate-*l*66.8%
Simplified66.8%
Taylor expanded in b around -inf 86.1%
*-commutative86.1%
Simplified86.1%
associate-*l/86.2%
Applied egg-rr86.2%
if -1.7e-53 < b < 2.89999999999999971e-70Initial program 79.2%
sqr-neg79.2%
sqr-neg79.2%
associate-*l*79.1%
Simplified79.1%
Taylor expanded in b around 0 77.8%
if 2.89999999999999971e-70 < b Initial program 11.4%
sqr-neg11.4%
sqr-neg11.4%
associate-*l*11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification83.6%
(FPCore (a b c)
:precision binary64
(if (<= b -3e-66)
(/ (* b -0.6666666666666666) a)
(if (<= b 3.5e-67)
(/ (+ b (sqrt (* c (* a -3.0)))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e-66) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.5e-67) {
tmp = (b + sqrt((c * (a * -3.0)))) / (3.0 * 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 <= (-3d-66)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 3.5d-67) then
tmp = (b + sqrt((c * (a * (-3.0d0))))) / (3.0d0 * 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 <= -3e-66) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.5e-67) {
tmp = (b + Math.sqrt((c * (a * -3.0)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e-66: tmp = (b * -0.6666666666666666) / a elif b <= 3.5e-67: tmp = (b + math.sqrt((c * (a * -3.0)))) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e-66) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 3.5e-67) tmp = Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / Float64(3.0 * 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 <= -3e-66) tmp = (b * -0.6666666666666666) / a; elseif (b <= 3.5e-67) tmp = (b + sqrt((c * (a * -3.0)))) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e-66], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.5e-67], N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{-66}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.0000000000000002e-66Initial program 66.8%
sqr-neg66.8%
sqr-neg66.8%
associate-*l*66.8%
Simplified66.8%
Taylor expanded in b around -inf 86.1%
*-commutative86.1%
Simplified86.1%
associate-*l/86.2%
Applied egg-rr86.2%
if -3.0000000000000002e-66 < b < 3.5e-67Initial program 79.2%
sqr-neg79.2%
sqr-neg79.2%
associate-*l*79.1%
Simplified79.1%
Taylor expanded in b around 0 77.8%
div-inv77.7%
add-sqr-sqrt49.6%
sqrt-unprod76.8%
sqr-neg76.8%
sqrt-prod28.4%
add-sqr-sqrt76.6%
associate-*r*76.8%
*-commutative76.8%
Applied egg-rr76.8%
associate-*r/76.9%
*-rgt-identity76.9%
*-commutative76.9%
*-commutative76.9%
Simplified76.9%
if 3.5e-67 < b Initial program 11.4%
sqr-neg11.4%
sqr-neg11.4%
associate-*l*11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification83.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.24e-60)
(/ (* b -0.6666666666666666) a)
(if (<= b 2.4e-70)
(* 0.3333333333333333 (/ (+ b (sqrt (* c (* a -3.0)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.24e-60) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.4e-70) {
tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / 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.24d-60)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 2.4d-70) then
tmp = 0.3333333333333333d0 * ((b + sqrt((c * (a * (-3.0d0))))) / 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.24e-60) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.4e-70) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.24e-60: tmp = (b * -0.6666666666666666) / a elif b <= 2.4e-70: tmp = 0.3333333333333333 * ((b + math.sqrt((c * (a * -3.0)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.24e-60) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 2.4e-70) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / 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.24e-60) tmp = (b * -0.6666666666666666) / a; elseif (b <= 2.4e-70) tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.24e-60], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.4e-70], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.24 \cdot 10^{-60}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-70}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.23999999999999998e-60Initial program 66.8%
sqr-neg66.8%
sqr-neg66.8%
associate-*l*66.8%
Simplified66.8%
Taylor expanded in b around -inf 86.1%
*-commutative86.1%
Simplified86.1%
associate-*l/86.2%
Applied egg-rr86.2%
if -1.23999999999999998e-60 < b < 2.4000000000000001e-70Initial program 79.2%
sqr-neg79.2%
sqr-neg79.2%
associate-*l*79.1%
Simplified79.1%
Taylor expanded in b around 0 77.8%
*-un-lft-identity77.8%
times-frac77.7%
metadata-eval77.7%
add-sqr-sqrt49.6%
sqrt-unprod76.9%
sqr-neg76.9%
sqrt-prod28.4%
add-sqr-sqrt76.6%
associate-*r*76.8%
Applied egg-rr76.8%
if 2.4000000000000001e-70 < b Initial program 11.4%
sqr-neg11.4%
sqr-neg11.4%
associate-*l*11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification83.4%
(FPCore (a b c) :precision binary64 (if (<= b 5.8e-205) (/ (fabs (* b -2.0)) (* 3.0 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.8e-205) {
tmp = fabs((b * -2.0)) / (3.0 * 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 <= 5.8d-205) then
tmp = abs((b * (-2.0d0))) / (3.0d0 * 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 <= 5.8e-205) {
tmp = Math.abs((b * -2.0)) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.8e-205: tmp = math.fabs((b * -2.0)) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.8e-205) tmp = Float64(abs(Float64(b * -2.0)) / Float64(3.0 * 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 <= 5.8e-205) tmp = abs((b * -2.0)) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.8e-205], N[(N[Abs[N[(b * -2.0), $MachinePrecision]], $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.8 \cdot 10^{-205}:\\
\;\;\;\;\frac{\left|b \cdot -2\right|}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 5.80000000000000036e-205Initial program 71.9%
Simplified71.9%
Taylor expanded in b around -inf 59.5%
*-commutative59.5%
Simplified59.5%
add-sqr-sqrt59.0%
sqrt-unprod41.2%
pow241.2%
Applied egg-rr41.2%
unpow241.2%
rem-sqrt-square59.6%
Simplified59.6%
if 5.80000000000000036e-205 < b Initial program 18.4%
sqr-neg18.4%
sqr-neg18.4%
associate-*l*18.4%
Simplified18.4%
Taylor expanded in b around inf 78.1%
*-commutative78.1%
Simplified78.1%
(FPCore (a b c) :precision binary64 (if (<= b 4e-303) (/ (* b -0.6666666666666666) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4e-303) {
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-303) 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-303) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4e-303: tmp = (b * -0.6666666666666666) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4e-303) 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-303) tmp = (b * -0.6666666666666666) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4e-303], 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^{-303}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.99999999999999972e-303Initial program 71.8%
sqr-neg71.8%
sqr-neg71.8%
associate-*l*71.8%
Simplified71.8%
Taylor expanded in b around -inf 64.0%
*-commutative64.0%
Simplified64.0%
associate-*l/64.1%
Applied egg-rr64.1%
if 3.99999999999999972e-303 < b Initial program 23.4%
sqr-neg23.4%
sqr-neg23.4%
associate-*l*23.3%
Simplified23.3%
Taylor expanded in b around inf 71.3%
*-commutative71.3%
Simplified71.3%
(FPCore (a b c) :precision binary64 (if (<= b 4.2e-303) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.2e-303) {
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.2d-303) 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.2e-303) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.2e-303: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.2e-303) 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.2e-303) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.2e-303], 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.2 \cdot 10^{-303}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 4.2e-303Initial program 71.8%
sqr-neg71.8%
sqr-neg71.8%
associate-*l*71.8%
Simplified71.8%
Applied egg-rr64.1%
Taylor expanded in b around -inf 64.0%
*-commutative64.0%
associate-*l/64.1%
associate-/l*64.0%
Simplified64.0%
if 4.2e-303 < b Initial program 23.4%
sqr-neg23.4%
sqr-neg23.4%
associate-*l*23.3%
Simplified23.3%
Taylor expanded in b around inf 71.3%
*-commutative71.3%
Simplified71.3%
(FPCore (a b c) :precision binary64 (if (<= b 7e+45) (* b (/ -0.6666666666666666 a)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7e+45) {
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 <= 7d+45) 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 <= 7e+45) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7e+45: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7e+45) 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 <= 7e+45) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7e+45], 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 7 \cdot 10^{+45}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 7.00000000000000046e45Initial program 64.9%
sqr-neg64.9%
sqr-neg64.9%
associate-*l*64.9%
Simplified64.9%
Applied egg-rr59.1%
Taylor expanded in b around -inf 47.8%
*-commutative47.8%
associate-*l/47.9%
associate-/l*47.9%
Simplified47.9%
if 7.00000000000000046e45 < b Initial program 7.8%
sqr-neg7.8%
sqr-neg7.8%
associate-*l*7.8%
Simplified7.8%
Applied egg-rr3.2%
*-commutative3.2%
associate-*l/3.3%
associate-*r/3.3%
Simplified3.3%
Taylor expanded in b around -inf 0.0%
*-commutative0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt36.4%
Simplified36.4%
Taylor expanded in c around 0 36.4%
Final simplification44.7%
(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 49.1%
sqr-neg49.1%
sqr-neg49.1%
associate-*l*49.1%
Simplified49.1%
Applied egg-rr24.4%
*-commutative24.4%
associate-*l/24.5%
associate-*r/24.5%
Simplified24.5%
Taylor expanded in b around -inf 0.0%
*-commutative0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt12.5%
Simplified12.5%
Taylor expanded in c around 0 12.5%
Final simplification12.5%
herbie shell --seed 2024139
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))