
(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 11 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 -1.32e+154)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.2e-49)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* c (- (* -0.375 (* a (/ c (pow b 3.0)))) (/ 0.5 b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.32e+154) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.2e-49) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = c * ((-0.375 * (a * (c / pow(b, 3.0)))) - (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.32d+154)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.2d-49) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
else
tmp = c * (((-0.375d0) * (a * (c / (b ** 3.0d0)))) - (0.5d0 / b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.32e+154) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.2e-49) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = c * ((-0.375 * (a * (c / Math.pow(b, 3.0)))) - (0.5 / b));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.32e+154: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.2e-49: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = c * ((-0.375 * (a * (c / math.pow(b, 3.0)))) - (0.5 / b)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.32e+154) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.2e-49) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(c * Float64(Float64(-0.375 * Float64(a * Float64(c / (b ^ 3.0)))) - Float64(0.5 / b))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.32e+154) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.2e-49) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = c * ((-0.375 * (a * (c / (b ^ 3.0)))) - (0.5 / b)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.32e+154], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.2e-49], 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[(c * N[(N[(-0.375 * N[(a * N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-49}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(-0.375 \cdot \left(a \cdot \frac{c}{{b}^{3}}\right) - \frac{0.5}{b}\right)\\
\end{array}
\end{array}
if b < -1.31999999999999998e154Initial program 28.3%
/-rgt-identity28.3%
metadata-eval28.3%
Simplified28.3%
Taylor expanded in b around -inf 97.2%
*-commutative97.2%
Simplified97.2%
if -1.31999999999999998e154 < b < 1.19999999999999996e-49Initial program 78.1%
if 1.19999999999999996e-49 < b Initial program 14.6%
/-rgt-identity14.6%
metadata-eval14.6%
Simplified14.6%
Taylor expanded in c around 0 84.2%
associate-/l*88.1%
associate-*r/88.1%
metadata-eval88.1%
Simplified88.1%
Final simplification84.0%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-75)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 9e-50)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* c (- (* -0.375 (* a (/ c (pow b 3.0)))) (/ 0.5 b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-75) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 9e-50) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = c * ((-0.375 * (a * (c / pow(b, 3.0)))) - (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 <= (-6.5d-75)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 9d-50) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * a)
else
tmp = c * (((-0.375d0) * (a * (c / (b ** 3.0d0)))) - (0.5d0 / b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-75) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 9e-50) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = c * ((-0.375 * (a * (c / Math.pow(b, 3.0)))) - (0.5 / b));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-75: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 9e-50: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = c * ((-0.375 * (a * (c / math.pow(b, 3.0)))) - (0.5 / b)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-75) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 9e-50) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(c * Float64(Float64(-0.375 * Float64(a * Float64(c / (b ^ 3.0)))) - Float64(0.5 / b))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-75) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 9e-50) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = c * ((-0.375 * (a * (c / (b ^ 3.0)))) - (0.5 / b)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-75], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9e-50], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(c * N[(N[(-0.375 * N[(a * N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-75}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(-0.375 \cdot \left(a \cdot \frac{c}{{b}^{3}}\right) - \frac{0.5}{b}\right)\\
\end{array}
\end{array}
if b < -6.5000000000000002e-75Initial program 66.8%
/-rgt-identity66.8%
metadata-eval66.8%
Simplified66.8%
Taylor expanded in b around -inf 89.2%
associate-*r*89.2%
mul-1-neg89.2%
fma-define89.2%
associate-*r/89.3%
metadata-eval89.3%
Simplified89.3%
Taylor expanded in c around 0 89.3%
if -6.5000000000000002e-75 < b < 8.99999999999999924e-50Initial program 68.8%
/-rgt-identity68.8%
metadata-eval68.8%
Simplified68.6%
Taylor expanded in b around 0 61.4%
associate-*r*61.5%
*-commutative61.5%
Simplified61.5%
if 8.99999999999999924e-50 < b Initial program 14.6%
/-rgt-identity14.6%
metadata-eval14.6%
Simplified14.6%
Taylor expanded in c around 0 84.2%
associate-/l*88.1%
associate-*r/88.1%
metadata-eval88.1%
Simplified88.1%
Final simplification79.2%
(FPCore (a b c)
:precision binary64
(if (<= b -2.05e-72)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.8e-50)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e-72) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.8e-50) {
tmp = (sqrt((c * (a * -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 <= (-2.05d-72)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.8d-50) then
tmp = (sqrt((c * (a * (-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 <= -2.05e-72) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.8e-50) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.05e-72: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.8e-50: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.05e-72) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.8e-50) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -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 <= -2.05e-72) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.8e-50) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.05e-72], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-50], N[(N[(N[Sqrt[N[(c * N[(a * -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 -2.05 \cdot 10^{-72}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.05000000000000002e-72Initial program 66.8%
/-rgt-identity66.8%
metadata-eval66.8%
Simplified66.8%
Taylor expanded in b around -inf 89.2%
associate-*r*89.2%
mul-1-neg89.2%
fma-define89.2%
associate-*r/89.3%
metadata-eval89.3%
Simplified89.3%
Taylor expanded in c around 0 89.3%
if -2.05000000000000002e-72 < b < 1.7999999999999999e-50Initial program 69.5%
/-rgt-identity69.5%
metadata-eval69.5%
Simplified69.3%
Taylor expanded in b around 0 62.0%
associate-*r*62.2%
*-commutative62.2%
Simplified62.2%
if 1.7999999999999999e-50 < b Initial program 14.5%
/-rgt-identity14.5%
metadata-eval14.5%
Simplified14.5%
Taylor expanded in b around inf 87.0%
Final simplification79.1%
(FPCore (a b c)
:precision binary64
(if (<= b -9e-219)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 2.85e-152)
(* (sqrt (/ (* c -3.0) a)) (- -0.3333333333333333))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e-219) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.85e-152) {
tmp = sqrt(((c * -3.0) / a)) * -(-0.3333333333333333);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-9d-219)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 2.85d-152) then
tmp = sqrt(((c * (-3.0d0)) / a)) * -(-0.3333333333333333d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9e-219) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.85e-152) {
tmp = Math.sqrt(((c * -3.0) / a)) * -(-0.3333333333333333);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9e-219: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 2.85e-152: tmp = math.sqrt(((c * -3.0) / a)) * -(-0.3333333333333333) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9e-219) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 2.85e-152) tmp = Float64(sqrt(Float64(Float64(c * -3.0) / a)) * Float64(-(-0.3333333333333333))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9e-219) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 2.85e-152) tmp = sqrt(((c * -3.0) / a)) * -(-0.3333333333333333); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9e-219], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.85e-152], N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision] * (--0.3333333333333333)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-219}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 2.85 \cdot 10^{-152}:\\
\;\;\;\;\sqrt{\frac{c \cdot -3}{a}} \cdot \left(--0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -9.00000000000000029e-219Initial program 71.3%
/-rgt-identity71.3%
metadata-eval71.3%
Simplified71.2%
Taylor expanded in b around -inf 72.4%
associate-*r*72.4%
mul-1-neg72.4%
fma-define72.4%
associate-*r/72.5%
metadata-eval72.5%
Simplified72.5%
Taylor expanded in c around 0 74.2%
if -9.00000000000000029e-219 < b < 2.8500000000000002e-152Initial program 59.9%
add-cube-cbrt59.5%
pow359.5%
associate-*l*59.5%
Applied egg-rr59.5%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt32.5%
rem-cube-cbrt32.8%
Simplified32.8%
if 2.8500000000000002e-152 < b Initial program 24.8%
/-rgt-identity24.8%
metadata-eval24.8%
Simplified24.7%
Taylor expanded in b around inf 74.7%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.0%
/-rgt-identity69.0%
metadata-eval69.0%
Simplified68.9%
Taylor expanded in b around -inf 65.4%
associate-*r*65.4%
mul-1-neg65.4%
fma-define65.4%
associate-*r/65.5%
metadata-eval65.5%
Simplified65.5%
Taylor expanded in c around 0 67.2%
if -3.999999999999988e-310 < b Initial program 32.3%
/-rgt-identity32.3%
metadata-eval32.3%
Simplified32.2%
Taylor expanded in b around inf 63.5%
Final simplification65.3%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ (* b -2.0) (* 3.0 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (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 <= (-4d-310)) then
tmp = (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 <= -4e-310) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (b * -2.0) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(b * -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 <= -4e-310) tmp = (b * -2.0) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(b * -2.0), $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 -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.0%
/-rgt-identity69.0%
metadata-eval69.0%
Simplified68.9%
Taylor expanded in b around -inf 66.4%
*-commutative66.4%
Simplified66.4%
if -3.999999999999988e-310 < b Initial program 32.3%
/-rgt-identity32.3%
metadata-eval32.3%
Simplified32.2%
Taylor expanded in b around inf 63.5%
Final simplification64.9%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ 1.0 (* -1.5 (/ a b))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = 1.0 / (-1.5 * (a / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4d-310)) then
tmp = 1.0d0 / ((-1.5d0) * (a / b))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = 1.0 / (-1.5 * (a / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = 1.0 / (-1.5 * (a / b)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(1.0 / Float64(-1.5 * Float64(a / b))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = 1.0 / (-1.5 * (a / b)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(1.0 / N[(-1.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{1}{-1.5 \cdot \frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.0%
/-rgt-identity69.0%
metadata-eval69.0%
Simplified68.9%
Taylor expanded in b around -inf 66.4%
*-commutative66.4%
Simplified66.4%
clear-num66.3%
inv-pow66.3%
*-commutative66.3%
times-frac66.3%
metadata-eval66.3%
Applied egg-rr66.3%
unpow-166.3%
Simplified66.3%
if -3.999999999999988e-310 < b Initial program 32.3%
/-rgt-identity32.3%
metadata-eval32.3%
Simplified32.2%
Taylor expanded in b around inf 63.5%
Final simplification64.9%
(FPCore (a b c) :precision binary64 (if (<= b 4e-309) (* b (/ -2.0 (* 3.0 a))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4e-309) {
tmp = 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 <= 4d-309) then
tmp = 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 <= 4e-309) {
tmp = b * (-2.0 / (3.0 * a));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4e-309: tmp = b * (-2.0 / (3.0 * a)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4e-309) tmp = Float64(b * Float64(-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 <= 4e-309) tmp = b * (-2.0 / (3.0 * a)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4e-309], N[(b * N[(-2.0 / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{-309}:\\
\;\;\;\;b \cdot \frac{-2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.9999999999999977e-309Initial program 69.0%
/-rgt-identity69.0%
metadata-eval69.0%
Simplified68.9%
Taylor expanded in b around -inf 66.4%
*-commutative66.4%
Simplified66.4%
associate-/l*66.3%
*-commutative66.3%
Applied egg-rr66.3%
if 3.9999999999999977e-309 < b Initial program 32.3%
/-rgt-identity32.3%
metadata-eval32.3%
Simplified32.2%
Taylor expanded in b around inf 63.5%
Final simplification64.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.45e-307) (/ (* b -0.6666666666666666) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.45e-307) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.45d-307) then
tmp = (b * (-0.6666666666666666d0)) / a
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.45e-307) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.45e-307: tmp = (b * -0.6666666666666666) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.45e-307) 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 <= 1.45e-307) tmp = (b * -0.6666666666666666) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.45e-307], 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 1.45 \cdot 10^{-307}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.45e-307Initial program 69.0%
add-cube-cbrt68.8%
pow368.8%
associate-*l*68.9%
Applied egg-rr68.9%
Taylor expanded in b around -inf 66.3%
associate-*r/66.3%
*-commutative66.3%
Simplified66.3%
if 1.45e-307 < b Initial program 32.3%
/-rgt-identity32.3%
metadata-eval32.3%
Simplified32.2%
Taylor expanded in b around inf 63.5%
Final simplification64.9%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4d-310)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.0%
/-rgt-identity69.0%
metadata-eval69.0%
Simplified68.9%
Taylor expanded in b around -inf 66.3%
*-commutative66.3%
Simplified66.3%
if -3.999999999999988e-310 < b Initial program 32.3%
/-rgt-identity32.3%
metadata-eval32.3%
Simplified32.2%
Taylor expanded in b around inf 63.5%
Final simplification64.9%
(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 50.8%
/-rgt-identity50.8%
metadata-eval50.8%
Simplified50.7%
Taylor expanded in b around inf 32.7%
Final simplification32.7%
herbie shell --seed 2024149
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))