
(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 -9e+79)
(/ (/ (* b -2.0) a) 3.0)
(if (<= b 4.3e-48)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e+79) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 4.3e-48) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} 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 <= (-9d+79)) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
else if (b <= 4.3d-48) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
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 <= -9e+79) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 4.3e-48) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9e+79: tmp = ((b * -2.0) / a) / 3.0 elif b <= 4.3e-48: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9e+79) tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0); elseif (b <= 4.3e-48) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9e+79) tmp = ((b * -2.0) / a) / 3.0; elseif (b <= 4.3e-48) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9e+79], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 4.3e-48], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{+79}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{elif}\;b \leq 4.3 \cdot 10^{-48}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -8.99999999999999987e79Initial program 44.7%
Applied egg-rr39.2%
associate-/r*39.2%
Simplified39.2%
associate-*r/39.2%
frac-2neg39.2%
un-div-inv39.2%
associate-*r*39.2%
metadata-eval39.2%
Applied egg-rr39.2%
distribute-neg-frac39.2%
sub-neg39.2%
+-commutative39.2%
distribute-neg-in39.2%
remove-double-neg39.2%
sub-neg39.2%
associate-*l*39.2%
Simplified39.2%
Taylor expanded in b around -inf 95.0%
*-commutative95.0%
Simplified95.0%
if -8.99999999999999987e79 < b < 4.3e-48Initial program 78.1%
if 4.3e-48 < b Initial program 17.0%
Taylor expanded in b around inf 89.8%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.95e-63)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 3e-61)
(* -0.3333333333333333 (/ (- b (sqrt (* c (* a -3.0)))) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.95e-63) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 3e-61) {
tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / 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 <= (-1.95d-63)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 3d-61) then
tmp = (-0.3333333333333333d0) * ((b - sqrt((c * (a * (-3.0d0))))) / 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 <= -1.95e-63) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 3e-61) {
tmp = -0.3333333333333333 * ((b - Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.95e-63: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 3e-61: tmp = -0.3333333333333333 * ((b - math.sqrt((c * (a * -3.0)))) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.95e-63) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 3e-61) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(c * Float64(a * -3.0)))) / 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 <= -1.95e-63) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 3e-61) tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.95e-63], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3e-61], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.95 \cdot 10^{-63}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-61}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.95000000000000011e-63Initial program 62.9%
Taylor expanded in b around -inf 88.3%
if -1.95000000000000011e-63 < b < 3.00000000000000012e-61Initial program 71.6%
Taylor expanded in b around 0 67.0%
*-commutative67.0%
associate-*l*66.9%
Simplified66.9%
expm1-log1p-u42.3%
expm1-udef19.1%
Applied egg-rr19.1%
expm1-def42.3%
expm1-log1p67.0%
*-lft-identity67.0%
*-commutative67.0%
times-frac66.9%
metadata-eval66.9%
associate-*l*66.9%
Simplified66.9%
if 3.00000000000000012e-61 < b Initial program 17.0%
Taylor expanded in b around inf 89.8%
Final simplification82.3%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e-63)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 8e-54)
(* (- b (sqrt (* c (* a -3.0)))) (/ -0.3333333333333333 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-63) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 8e-54) {
tmp = (b - sqrt((c * (a * -3.0)))) * (-0.3333333333333333 / 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 <= (-3.6d-63)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 8d-54) then
tmp = (b - sqrt((c * (a * (-3.0d0))))) * ((-0.3333333333333333d0) / 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 <= -3.6e-63) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 8e-54) {
tmp = (b - Math.sqrt((c * (a * -3.0)))) * (-0.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.6e-63: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 8e-54: tmp = (b - math.sqrt((c * (a * -3.0)))) * (-0.3333333333333333 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.6e-63) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 8e-54) tmp = Float64(Float64(b - sqrt(Float64(c * Float64(a * -3.0)))) * Float64(-0.3333333333333333 / 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 <= -3.6e-63) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 8e-54) tmp = (b - sqrt((c * (a * -3.0)))) * (-0.3333333333333333 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.6e-63], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-54], N[(N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-63}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-54}:\\
\;\;\;\;\left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.60000000000000008e-63Initial program 62.9%
Taylor expanded in b around -inf 88.3%
if -3.60000000000000008e-63 < b < 8.0000000000000002e-54Initial program 71.6%
Taylor expanded in b around 0 67.0%
*-commutative67.0%
associate-*l*66.9%
Simplified66.9%
frac-2neg66.9%
div-inv66.8%
neg-sub066.8%
add-sqr-sqrt34.6%
sqrt-unprod65.7%
sqr-neg65.7%
sqrt-unprod32.0%
add-sqr-sqrt65.0%
associate--l-65.0%
neg-sub065.0%
add-sqr-sqrt33.0%
sqrt-unprod65.3%
sqr-neg65.3%
sqrt-unprod32.2%
add-sqr-sqrt66.8%
*-commutative66.8%
associate-*r*67.0%
*-commutative67.0%
associate-*r*66.8%
Applied egg-rr66.8%
*-commutative66.8%
associate-*l/66.9%
metadata-eval66.9%
associate-*l*66.9%
Simplified66.9%
if 8.0000000000000002e-54 < b Initial program 17.0%
Taylor expanded in b around inf 89.8%
Final simplification82.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.45e-63)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 2.9e-62)
(/ (* -0.3333333333333333 (- b (sqrt (* c (* a -3.0))))) a)
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.45e-63) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.9e-62) {
tmp = (-0.3333333333333333 * (b - sqrt((c * (a * -3.0))))) / 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 <= (-2.45d-63)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 2.9d-62) then
tmp = ((-0.3333333333333333d0) * (b - sqrt((c * (a * (-3.0d0)))))) / 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 <= -2.45e-63) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.9e-62) {
tmp = (-0.3333333333333333 * (b - Math.sqrt((c * (a * -3.0))))) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.45e-63: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 2.9e-62: tmp = (-0.3333333333333333 * (b - math.sqrt((c * (a * -3.0))))) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.45e-63) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 2.9e-62) tmp = Float64(Float64(-0.3333333333333333 * Float64(b - sqrt(Float64(c * Float64(a * -3.0))))) / 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 <= -2.45e-63) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 2.9e-62) tmp = (-0.3333333333333333 * (b - sqrt((c * (a * -3.0))))) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.45e-63], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.9e-62], N[(N[(-0.3333333333333333 * N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.45 \cdot 10^{-63}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-62}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.45000000000000008e-63Initial program 62.9%
Taylor expanded in b around -inf 88.3%
if -2.45000000000000008e-63 < b < 2.89999999999999986e-62Initial program 71.6%
Taylor expanded in b around 0 67.0%
*-commutative67.0%
associate-*l*66.9%
Simplified66.9%
expm1-log1p-u42.3%
expm1-udef19.1%
Applied egg-rr19.1%
expm1-def42.3%
expm1-log1p67.0%
*-lft-identity67.0%
*-commutative67.0%
times-frac66.9%
metadata-eval66.9%
associate-*l*66.9%
Simplified66.9%
associate-*r/67.0%
Applied egg-rr67.0%
if 2.89999999999999986e-62 < b Initial program 17.0%
Taylor expanded in b around inf 89.8%
Final simplification82.3%
(FPCore (a b c)
:precision binary64
(if (<= b -8.8e-63)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 1.1e-51)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.8e-63) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 1.1e-51) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} 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 <= (-8.8d-63)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 1.1d-51) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
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 <= -8.8e-63) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 1.1e-51) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.8e-63: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 1.1e-51: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.8e-63) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 1.1e-51) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.8e-63) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 1.1e-51) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.8e-63], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-51], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.8 \cdot 10^{-63}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-51}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -8.7999999999999998e-63Initial program 62.9%
Taylor expanded in b around -inf 88.3%
if -8.7999999999999998e-63 < b < 1.1e-51Initial program 71.6%
Taylor expanded in b around 0 67.0%
*-commutative67.0%
associate-*l*66.9%
Simplified66.9%
+-commutative66.9%
unsub-neg66.9%
*-commutative66.9%
associate-*r*67.1%
*-commutative67.1%
associate-*r*67.0%
Applied egg-rr67.0%
associate-*l*67.1%
Simplified67.1%
if 1.1e-51 < b Initial program 17.0%
Taylor expanded in b around inf 89.8%
Final simplification82.3%
(FPCore (a b c) :precision binary64 (if (<= b 1.5e-309) (/ (/ (* b -2.0) a) 3.0) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.5e-309) {
tmp = ((b * -2.0) / a) / 3.0;
} 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 <= 1.5d-309) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
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 <= 1.5e-309) {
tmp = ((b * -2.0) / a) / 3.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.5e-309: tmp = ((b * -2.0) / a) / 3.0 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.5e-309) tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.5e-309) tmp = ((b * -2.0) / a) / 3.0; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.5e-309], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.5 \cdot 10^{-309}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.5e-309Initial program 66.3%
Applied egg-rr56.1%
associate-/r*56.2%
Simplified56.2%
associate-*r/56.2%
frac-2neg56.2%
un-div-inv56.2%
associate-*r*56.2%
metadata-eval56.2%
Applied egg-rr56.2%
distribute-neg-frac56.2%
sub-neg56.2%
+-commutative56.2%
distribute-neg-in56.2%
remove-double-neg56.2%
sub-neg56.2%
associate-*l*56.2%
Simplified56.2%
Taylor expanded in b around -inf 68.2%
*-commutative68.2%
Simplified68.2%
if 1.5e-309 < b Initial program 33.0%
Taylor expanded in b around inf 69.1%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.12e-307) (* b (/ -1.3333333333333333 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.12e-307) {
tmp = b * (-1.3333333333333333 / 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 <= 1.12d-307) then
tmp = b * ((-1.3333333333333333d0) / 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 <= 1.12e-307) {
tmp = b * (-1.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.12e-307: tmp = b * (-1.3333333333333333 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.12e-307) tmp = Float64(b * Float64(-1.3333333333333333 / 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 <= 1.12e-307) tmp = b * (-1.3333333333333333 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.12e-307], N[(b * N[(-1.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.12 \cdot 10^{-307}:\\
\;\;\;\;b \cdot \frac{-1.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.11999999999999994e-307Initial program 66.3%
+-commutative66.3%
sqr-neg66.3%
unsub-neg66.3%
div-sub66.3%
--rgt-identity66.3%
div-sub66.3%
Simplified66.2%
Applied egg-rr23.0%
+-commutative23.0%
associate-+l+23.0%
associate-*r*22.9%
*-commutative22.9%
associate-*l*22.9%
fma-udef22.9%
*-rgt-identity22.9%
Simplified22.9%
Taylor expanded in b around inf 1.4%
*-commutative1.4%
Simplified1.4%
frac-2neg1.4%
div-inv1.4%
distribute-rgt-neg-in1.4%
metadata-eval1.4%
distribute-lft-neg-in1.4%
metadata-eval1.4%
*-commutative1.4%
add-sqr-sqrt0.7%
sqrt-unprod10.0%
swap-sqr10.0%
metadata-eval10.0%
metadata-eval10.0%
swap-sqr10.0%
*-commutative10.0%
*-commutative10.0%
sqrt-unprod11.0%
add-sqr-sqrt25.7%
associate-/r*25.7%
metadata-eval25.7%
Applied egg-rr25.7%
associate-*l*25.7%
associate-*r/25.7%
metadata-eval25.7%
Simplified25.7%
if 1.11999999999999994e-307 < b Initial program 33.0%
Taylor expanded in b around inf 69.1%
Final simplification45.9%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(b * Float64(-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 <= -2e-310) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 66.3%
Taylor expanded in b around -inf 68.2%
*-commutative68.2%
Simplified68.2%
*-commutative68.2%
clear-num68.1%
un-div-inv68.1%
Applied egg-rr68.1%
associate-/r/68.2%
Simplified68.2%
if -1.999999999999994e-310 < b Initial program 33.0%
Taylor expanded in b around inf 69.1%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) 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 <= -2e-310) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], 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 -2 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 66.3%
Taylor expanded in b around -inf 68.2%
*-commutative68.2%
Simplified68.2%
if -1.999999999999994e-310 < b Initial program 33.0%
Taylor expanded in b around inf 69.1%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = b / (a * -1.5);
} 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 <= (-2d-310)) then
tmp = b / (a * (-1.5d0))
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 <= -2e-310) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 66.3%
Applied egg-rr56.1%
associate-/r*56.2%
Simplified56.2%
associate-*r/56.2%
frac-2neg56.2%
un-div-inv56.2%
associate-*r*56.2%
metadata-eval56.2%
Applied egg-rr56.2%
distribute-neg-frac56.2%
sub-neg56.2%
+-commutative56.2%
distribute-neg-in56.2%
remove-double-neg56.2%
sub-neg56.2%
associate-*l*56.2%
Simplified56.2%
Taylor expanded in b around -inf 68.2%
*-commutative68.2%
Simplified68.2%
Taylor expanded in b around 0 68.2%
metadata-eval68.2%
times-frac68.2%
*-commutative68.2%
associate-/r*68.3%
associate-/l*68.3%
metadata-eval68.3%
associate-/l/68.2%
Simplified68.2%
if -1.999999999999994e-310 < b Initial program 33.0%
Taylor expanded in b around inf 69.1%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (* b -0.6666666666666666) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (b * -0.6666666666666666) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) 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 <= -2e-310) tmp = (b * -0.6666666666666666) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], 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 -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 66.3%
Taylor expanded in b around -inf 68.2%
*-commutative68.2%
associate-*l/68.2%
Simplified68.2%
if -1.999999999999994e-310 < b Initial program 33.0%
Taylor expanded in b around inf 69.1%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 50.8%
Taylor expanded in b around inf 33.3%
Final simplification33.3%
herbie shell --seed 2023319
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))