
(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.02e+134)
(/ -1.0 (* (- (/ a b)) -1.5))
(if (<= b 8e-70)
(/ (- (sqrt (fma b b (* c (* a -3.0)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.02e+134) {
tmp = -1.0 / (-(a / b) * -1.5);
} else if (b <= 8e-70) {
tmp = (sqrt(fma(b, b, (c * (a * -3.0)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.02e+134) tmp = Float64(-1.0 / Float64(Float64(-Float64(a / b)) * -1.5)); elseif (b <= 8e-70) tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.02e+134], N[(-1.0 / N[((-N[(a / b), $MachinePrecision]) * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-70], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.02 \cdot 10^{+134}:\\
\;\;\;\;\frac{-1}{\left(-\frac{a}{b}\right) \cdot -1.5}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-70}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.02e134Initial program 43.8%
neg-sub043.8%
associate-+l-43.8%
sub0-neg43.8%
sub0-neg43.8%
associate-+l-43.8%
neg-sub043.8%
associate-*l*43.8%
Simplified43.8%
Taylor expanded in b around -inf 99.5%
*-commutative99.5%
Simplified99.5%
add-sqr-sqrt48.3%
sqrt-unprod36.9%
swap-sqr36.9%
pow136.9%
metadata-eval36.9%
pow136.9%
metadata-eval36.9%
pow-sqr36.9%
metadata-eval36.9%
metadata-eval36.9%
metadata-eval36.9%
Applied egg-rr36.9%
*-commutative36.9%
metadata-eval36.9%
unpow236.9%
swap-sqr36.9%
clear-num36.9%
div-inv36.9%
clear-num36.9%
div-inv36.9%
sqrt-unprod48.3%
add-sqr-sqrt99.5%
clear-num99.4%
metadata-eval99.4%
frac-2neg99.4%
metadata-eval99.4%
metadata-eval99.4%
div-inv99.7%
metadata-eval99.7%
distribute-lft-neg-in99.7%
distribute-neg-frac99.7%
Applied egg-rr99.7%
if -1.02e134 < b < 7.99999999999999997e-70Initial program 86.1%
Simplified86.1%
if 7.99999999999999997e-70 < b Initial program 16.3%
neg-sub016.3%
associate-+l-16.3%
sub0-neg16.3%
sub0-neg16.3%
associate-+l-16.3%
neg-sub016.3%
associate-*l*16.3%
Simplified16.3%
Taylor expanded in b around inf 88.0%
associate-*r/88.0%
Simplified88.0%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.9e+133)
(/ -1.0 (* (- (/ a b)) -1.5))
(if (<= b 4.5e-68)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.9e+133) {
tmp = -1.0 / (-(a / b) * -1.5);
} else if (b <= 4.5e-68) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-3.9d+133)) then
tmp = (-1.0d0) / (-(a / b) * (-1.5d0))
else if (b <= 4.5d-68) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.9e+133) {
tmp = -1.0 / (-(a / b) * -1.5);
} else if (b <= 4.5e-68) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.9e+133: tmp = -1.0 / (-(a / b) * -1.5) elif b <= 4.5e-68: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.9e+133) tmp = Float64(-1.0 / Float64(Float64(-Float64(a / b)) * -1.5)); elseif (b <= 4.5e-68) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.9e+133) tmp = -1.0 / (-(a / b) * -1.5); elseif (b <= 4.5e-68) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.9e+133], N[(-1.0 / N[((-N[(a / b), $MachinePrecision]) * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-68], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.9 \cdot 10^{+133}:\\
\;\;\;\;\frac{-1}{\left(-\frac{a}{b}\right) \cdot -1.5}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-68}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.90000000000000014e133Initial program 43.8%
neg-sub043.8%
associate-+l-43.8%
sub0-neg43.8%
sub0-neg43.8%
associate-+l-43.8%
neg-sub043.8%
associate-*l*43.8%
Simplified43.8%
Taylor expanded in b around -inf 99.5%
*-commutative99.5%
Simplified99.5%
add-sqr-sqrt48.3%
sqrt-unprod36.9%
swap-sqr36.9%
pow136.9%
metadata-eval36.9%
pow136.9%
metadata-eval36.9%
pow-sqr36.9%
metadata-eval36.9%
metadata-eval36.9%
metadata-eval36.9%
Applied egg-rr36.9%
*-commutative36.9%
metadata-eval36.9%
unpow236.9%
swap-sqr36.9%
clear-num36.9%
div-inv36.9%
clear-num36.9%
div-inv36.9%
sqrt-unprod48.3%
add-sqr-sqrt99.5%
clear-num99.4%
metadata-eval99.4%
frac-2neg99.4%
metadata-eval99.4%
metadata-eval99.4%
div-inv99.7%
metadata-eval99.7%
distribute-lft-neg-in99.7%
distribute-neg-frac99.7%
Applied egg-rr99.7%
if -3.90000000000000014e133 < b < 4.49999999999999999e-68Initial program 86.1%
neg-sub086.1%
associate-+l-86.1%
sub0-neg86.1%
sub0-neg86.1%
associate-+l-86.1%
neg-sub086.1%
associate-*l*86.0%
Simplified86.0%
if 4.49999999999999999e-68 < b Initial program 16.3%
neg-sub016.3%
associate-+l-16.3%
sub0-neg16.3%
sub0-neg16.3%
associate-+l-16.3%
neg-sub016.3%
associate-*l*16.3%
Simplified16.3%
Taylor expanded in b around inf 88.0%
associate-*r/88.0%
Simplified88.0%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e+134)
(/ -1.0 (* (- (/ a b)) -1.5))
(if (<= b 4.6e-66)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e+134) {
tmp = -1.0 / (-(a / b) * -1.5);
} else if (b <= 4.6e-66) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.5d+134)) then
tmp = (-1.0d0) / (-(a / b) * (-1.5d0))
else if (b <= 4.6d-66) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e+134) {
tmp = -1.0 / (-(a / b) * -1.5);
} else if (b <= 4.6e-66) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e+134: tmp = -1.0 / (-(a / b) * -1.5) elif b <= 4.6e-66: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e+134) tmp = Float64(-1.0 / Float64(Float64(-Float64(a / b)) * -1.5)); elseif (b <= 4.6e-66) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.5e+134) tmp = -1.0 / (-(a / b) * -1.5); elseif (b <= 4.6e-66) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e+134], N[(-1.0 / N[((-N[(a / b), $MachinePrecision]) * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.6e-66], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{+134}:\\
\;\;\;\;\frac{-1}{\left(-\frac{a}{b}\right) \cdot -1.5}\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.49999999999999998e134Initial program 43.8%
neg-sub043.8%
associate-+l-43.8%
sub0-neg43.8%
sub0-neg43.8%
associate-+l-43.8%
neg-sub043.8%
associate-*l*43.8%
Simplified43.8%
Taylor expanded in b around -inf 99.5%
*-commutative99.5%
Simplified99.5%
add-sqr-sqrt48.3%
sqrt-unprod36.9%
swap-sqr36.9%
pow136.9%
metadata-eval36.9%
pow136.9%
metadata-eval36.9%
pow-sqr36.9%
metadata-eval36.9%
metadata-eval36.9%
metadata-eval36.9%
Applied egg-rr36.9%
*-commutative36.9%
metadata-eval36.9%
unpow236.9%
swap-sqr36.9%
clear-num36.9%
div-inv36.9%
clear-num36.9%
div-inv36.9%
sqrt-unprod48.3%
add-sqr-sqrt99.5%
clear-num99.4%
metadata-eval99.4%
frac-2neg99.4%
metadata-eval99.4%
metadata-eval99.4%
div-inv99.7%
metadata-eval99.7%
distribute-lft-neg-in99.7%
distribute-neg-frac99.7%
Applied egg-rr99.7%
if -1.49999999999999998e134 < b < 4.59999999999999984e-66Initial program 86.1%
if 4.59999999999999984e-66 < b Initial program 16.3%
neg-sub016.3%
associate-+l-16.3%
sub0-neg16.3%
sub0-neg16.3%
associate-+l-16.3%
neg-sub016.3%
associate-*l*16.3%
Simplified16.3%
Taylor expanded in b around inf 88.0%
associate-*r/88.0%
Simplified88.0%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.05e-66)
(/ (- (- (/ (* a 1.5) (/ b c)) b) b) (* a 3.0))
(if (<= b 1.35e-69)
(* (/ 0.3333333333333333 a) (+ b (sqrt (* c (* a -3.0)))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-66) {
tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 1.35e-69) {
tmp = (0.3333333333333333 / a) * (b + sqrt((c * (a * -3.0))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.05d-66)) then
tmp = ((((a * 1.5d0) / (b / c)) - b) - b) / (a * 3.0d0)
else if (b <= 1.35d-69) then
tmp = (0.3333333333333333d0 / a) * (b + sqrt((c * (a * (-3.0d0)))))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-66) {
tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 1.35e-69) {
tmp = (0.3333333333333333 / a) * (b + Math.sqrt((c * (a * -3.0))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-66: tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0) elif b <= 1.35e-69: tmp = (0.3333333333333333 / a) * (b + math.sqrt((c * (a * -3.0)))) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.05e-66) tmp = Float64(Float64(Float64(Float64(Float64(a * 1.5) / Float64(b / c)) - b) - b) / Float64(a * 3.0)); elseif (b <= 1.35e-69) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(b + sqrt(Float64(c * Float64(a * -3.0))))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.05e-66) tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0); elseif (b <= 1.35e-69) tmp = (0.3333333333333333 / a) * (b + sqrt((c * (a * -3.0)))); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-66], N[(N[(N[(N[(N[(a * 1.5), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-69], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-66}:\\
\;\;\;\;\frac{\left(\frac{a \cdot 1.5}{\frac{b}{c}} - b\right) - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-69}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(b + \sqrt{c \cdot \left(a \cdot -3\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.05e-66Initial program 67.5%
neg-sub067.5%
associate-+l-67.5%
sub0-neg67.5%
sub0-neg67.5%
associate-+l-67.5%
neg-sub067.5%
associate-*l*67.5%
Simplified67.5%
Taylor expanded in b around -inf 83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
associate-/l*88.0%
associate-*r/88.0%
Simplified88.0%
if -1.05e-66 < b < 1.3499999999999999e-69Initial program 83.8%
neg-sub083.8%
associate-+l-83.8%
sub0-neg83.8%
sub0-neg83.8%
associate-+l-83.8%
neg-sub083.8%
associate-*l*83.8%
Simplified83.8%
Taylor expanded in b around 0 81.0%
associate-*r*81.0%
*-commutative81.0%
*-commutative81.0%
Simplified81.0%
div-inv81.1%
*-commutative81.1%
metadata-eval81.1%
associate-/r*80.8%
metadata-eval80.8%
metadata-eval80.8%
add-sqr-sqrt41.4%
sqrt-unprod79.3%
sqr-neg79.3%
unpow279.3%
unpow279.3%
sqrt-prod38.5%
add-sqr-sqrt79.1%
Applied egg-rr79.1%
if 1.3499999999999999e-69 < b Initial program 16.3%
neg-sub016.3%
associate-+l-16.3%
sub0-neg16.3%
sub0-neg16.3%
associate-+l-16.3%
neg-sub016.3%
associate-*l*16.3%
Simplified16.3%
Taylor expanded in b around inf 88.0%
associate-*r/88.0%
Simplified88.0%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.05e-23)
(/ (- (- (/ (* a 1.5) (/ b c)) b) b) (* a 3.0))
(if (<= b 1e-67)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-23) {
tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 1e-67) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.05d-23)) then
tmp = ((((a * 1.5d0) / (b / c)) - b) - b) / (a * 3.0d0)
else if (b <= 1d-67) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-23) {
tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 1e-67) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-23: tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0) elif b <= 1e-67: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.05e-23) tmp = Float64(Float64(Float64(Float64(Float64(a * 1.5) / Float64(b / c)) - b) - b) / Float64(a * 3.0)); elseif (b <= 1e-67) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.05e-23) tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0); elseif (b <= 1e-67) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-23], N[(N[(N[(N[(N[(a * 1.5), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-67], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-23}:\\
\;\;\;\;\frac{\left(\frac{a \cdot 1.5}{\frac{b}{c}} - b\right) - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 10^{-67}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.05e-23Initial program 66.7%
neg-sub066.7%
associate-+l-66.7%
sub0-neg66.7%
sub0-neg66.7%
associate-+l-66.7%
neg-sub066.7%
associate-*l*66.6%
Simplified66.6%
Taylor expanded in b around -inf 85.7%
+-commutative85.7%
mul-1-neg85.7%
unsub-neg85.7%
associate-/l*90.9%
associate-*r/90.9%
Simplified90.9%
if -1.05e-23 < b < 9.99999999999999943e-68Initial program 83.6%
neg-sub083.6%
associate-+l-83.6%
sub0-neg83.6%
sub0-neg83.6%
associate-+l-83.6%
neg-sub083.6%
associate-*l*83.5%
Simplified83.5%
Applied egg-rr82.6%
+-commutative82.6%
fma-udef82.6%
associate-+l+82.6%
*-commutative82.6%
associate-*l*82.6%
*-commutative82.6%
*-commutative82.6%
associate-*l*82.5%
*-commutative82.5%
+-commutative82.5%
Simplified82.5%
Taylor expanded in b around 0 78.5%
distribute-rgt-out78.8%
metadata-eval78.8%
*-commutative78.8%
associate-*r*78.8%
mul-1-neg78.8%
sub-neg78.8%
Simplified78.8%
if 9.99999999999999943e-68 < b Initial program 16.3%
neg-sub016.3%
associate-+l-16.3%
sub0-neg16.3%
sub0-neg16.3%
associate-+l-16.3%
neg-sub016.3%
associate-*l*16.3%
Simplified16.3%
Taylor expanded in b around inf 88.0%
associate-*r/88.0%
Simplified88.0%
Final simplification86.1%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (/ (* c -0.5) b)))
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 * -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 <= (-4d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c * -0.5) / b;
}
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 * -0.5) / b 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 * -0.5) / b); 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 * -0.5) / b; 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 * -0.5), $MachinePrecision] / b), $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 \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.0%
neg-sub072.0%
associate-+l-72.0%
sub0-neg72.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
associate-*l*72.0%
Simplified72.0%
Taylor expanded in b around -inf 63.6%
if -3.999999999999988e-310 < b Initial program 33.4%
neg-sub033.4%
associate-+l-33.4%
sub0-neg33.4%
sub0-neg33.4%
associate-+l-33.4%
neg-sub033.4%
associate-*l*33.4%
Simplified33.4%
Taylor expanded in b around inf 70.0%
associate-*r/70.0%
Simplified70.0%
Final simplification67.0%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (* b (/ -0.6666666666666666 a)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4d-310)) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.0%
neg-sub072.0%
associate-+l-72.0%
sub0-neg72.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
associate-*l*72.0%
Simplified72.0%
Taylor expanded in b around -inf 63.2%
*-commutative63.2%
Simplified63.2%
*-commutative63.2%
clear-num63.1%
un-div-inv63.2%
Applied egg-rr63.2%
associate-/r/63.2%
Applied egg-rr63.2%
if -3.999999999999988e-310 < b Initial program 33.4%
neg-sub033.4%
associate-+l-33.4%
sub0-neg33.4%
sub0-neg33.4%
associate-+l-33.4%
neg-sub033.4%
associate-*l*33.4%
Simplified33.4%
Taylor expanded in b around inf 70.0%
associate-*r/70.0%
associate-/l*68.8%
Simplified68.8%
Final simplification66.2%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ b (* a -1.5)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 / (b / c);
}
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 / (a * (-1.5d0))
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = b / (a * -1.5) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = b / (a * -1.5); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.0%
neg-sub072.0%
associate-+l-72.0%
sub0-neg72.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
associate-*l*72.0%
Simplified72.0%
Taylor expanded in b around -inf 63.2%
*-commutative63.2%
Simplified63.2%
*-commutative63.2%
clear-num63.1%
un-div-inv63.2%
Applied egg-rr63.2%
associate-/r/63.2%
Applied egg-rr63.2%
clear-num63.1%
associate-*l/63.2%
*-un-lft-identity63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr63.2%
if -3.999999999999988e-310 < b Initial program 33.4%
neg-sub033.4%
associate-+l-33.4%
sub0-neg33.4%
sub0-neg33.4%
associate-+l-33.4%
neg-sub033.4%
associate-*l*33.4%
Simplified33.4%
Taylor expanded in b around inf 70.0%
associate-*r/70.0%
associate-/l*68.8%
Simplified68.8%
Final simplification66.2%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4d-310)) then
tmp = b / (a * (-1.5d0))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.0%
neg-sub072.0%
associate-+l-72.0%
sub0-neg72.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
associate-*l*72.0%
Simplified72.0%
Taylor expanded in b around -inf 63.2%
*-commutative63.2%
Simplified63.2%
*-commutative63.2%
clear-num63.1%
un-div-inv63.2%
Applied egg-rr63.2%
associate-/r/63.2%
Applied egg-rr63.2%
clear-num63.1%
associate-*l/63.2%
*-un-lft-identity63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr63.2%
if -3.999999999999988e-310 < b Initial program 33.4%
neg-sub033.4%
associate-+l-33.4%
sub0-neg33.4%
sub0-neg33.4%
associate-+l-33.4%
neg-sub033.4%
associate-*l*33.4%
Simplified33.4%
Taylor expanded in b around inf 70.0%
associate-*r/70.0%
Simplified70.0%
Final simplification66.9%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4d-310)) then
tmp = (b * (-0.6666666666666666d0)) / a
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (b * -0.6666666666666666) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.0%
neg-sub072.0%
associate-+l-72.0%
sub0-neg72.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
associate-*l*72.0%
Simplified72.0%
Taylor expanded in b around -inf 63.2%
associate-*r/63.3%
*-commutative63.3%
Simplified63.3%
if -3.999999999999988e-310 < b Initial program 33.4%
neg-sub033.4%
associate-+l-33.4%
sub0-neg33.4%
sub0-neg33.4%
associate-+l-33.4%
neg-sub033.4%
associate-*l*33.4%
Simplified33.4%
Taylor expanded in b around inf 70.0%
associate-*r/70.0%
Simplified70.0%
Final simplification66.9%
(FPCore (a b c) :precision binary64 (* b (/ -0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (-0.6666666666666666 / 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 * ((-0.6666666666666666d0) / a)
end function
public static double code(double a, double b, double c) {
return b * (-0.6666666666666666 / a);
}
def code(a, b, c): return b * (-0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(-0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (-0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{-0.6666666666666666}{a}
\end{array}
Initial program 51.0%
neg-sub051.0%
associate-+l-51.0%
sub0-neg51.0%
sub0-neg51.0%
associate-+l-51.0%
neg-sub051.0%
associate-*l*51.0%
Simplified51.0%
Taylor expanded in b around -inf 30.4%
*-commutative30.4%
Simplified30.4%
*-commutative30.4%
clear-num30.4%
un-div-inv30.4%
Applied egg-rr30.4%
associate-/r/30.4%
Applied egg-rr30.4%
Final simplification30.4%
herbie shell --seed 2023336
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))