
(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 10 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.4e+56)
(* (/ 1.0 a) (* b -0.6666666666666666))
(if (<= b 1.5e-154)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.4e+56) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else if (b <= 1.5e-154) {
tmp = (sqrt(((b * b) - ((a * 3.0) * 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 <= (-1.4d+56)) then
tmp = (1.0d0 / a) * (b * (-0.6666666666666666d0))
else if (b <= 1.5d-154) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * 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 <= -1.4e+56) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else if (b <= 1.5e-154) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.4e+56: tmp = (1.0 / a) * (b * -0.6666666666666666) elif b <= 1.5e-154: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.4e+56) tmp = Float64(Float64(1.0 / a) * Float64(b * -0.6666666666666666)); elseif (b <= 1.5e-154) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * 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 <= -1.4e+56) tmp = (1.0 / a) * (b * -0.6666666666666666); elseif (b <= 1.5e-154) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.4e+56], N[(N[(1.0 / a), $MachinePrecision] * N[(b * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-154], 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[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4 \cdot 10^{+56}:\\
\;\;\;\;\frac{1}{a} \cdot \left(b \cdot -0.6666666666666666\right)\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-154}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.40000000000000004e56Initial program 57.2%
/-rgt-identity57.2%
metadata-eval57.2%
Simplified57.2%
div-sub57.2%
sub-neg57.2%
div-inv57.3%
fma-undefine57.3%
add-sqr-sqrt32.4%
hypot-define52.6%
associate-/r*52.6%
metadata-eval52.6%
div-inv52.6%
associate-/r*52.6%
metadata-eval52.6%
Applied egg-rr52.6%
distribute-lft-neg-in52.6%
distribute-rgt-in52.6%
sub-neg52.6%
associate-*r*52.6%
*-commutative52.6%
associate-*r*52.6%
*-commutative52.6%
Simplified52.6%
associate-*l/52.6%
clear-num52.7%
associate-*l*52.7%
Applied egg-rr52.7%
associate-/r/52.7%
*-commutative52.7%
*-commutative52.7%
Simplified52.7%
Taylor expanded in b around -inf 96.7%
*-commutative96.7%
Simplified96.7%
if -1.40000000000000004e56 < b < 1.5000000000000001e-154Initial program 82.0%
if 1.5000000000000001e-154 < b Initial program 21.0%
/-rgt-identity21.0%
metadata-eval21.0%
Simplified21.0%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
Applied egg-rr83.8%
Final simplification86.4%
(FPCore (a b c)
:precision binary64
(if (<= b -3.5e-58)
(* b (- (* 0.6666666666666666 (/ -1.0 a)) (* -0.5 (/ c (pow b 2.0)))))
(if (<= b 1.48e-154)
(/ (- (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 <= -3.5e-58) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / pow(b, 2.0))));
} else if (b <= 1.48e-154) {
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 <= (-3.5d-58)) then
tmp = b * ((0.6666666666666666d0 * ((-1.0d0) / a)) - ((-0.5d0) * (c / (b ** 2.0d0))))
else if (b <= 1.48d-154) 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 <= -3.5e-58) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / Math.pow(b, 2.0))));
} else if (b <= 1.48e-154) {
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 <= -3.5e-58: tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / math.pow(b, 2.0)))) elif b <= 1.48e-154: 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 <= -3.5e-58) tmp = Float64(b * Float64(Float64(0.6666666666666666 * Float64(-1.0 / a)) - Float64(-0.5 * Float64(c / (b ^ 2.0))))); elseif (b <= 1.48e-154) 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 <= -3.5e-58) tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / (b ^ 2.0)))); elseif (b <= 1.48e-154) 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, -3.5e-58], N[(b * N[(N[(0.6666666666666666 * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.48e-154], 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 -3.5 \cdot 10^{-58}:\\
\;\;\;\;b \cdot \left(0.6666666666666666 \cdot \frac{-1}{a} - -0.5 \cdot \frac{c}{{b}^{2}}\right)\\
\mathbf{elif}\;b \leq 1.48 \cdot 10^{-154}:\\
\;\;\;\;\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 < -3.4999999999999999e-58Initial program 62.9%
/-rgt-identity62.9%
metadata-eval62.9%
Simplified62.9%
Taylor expanded in b around -inf 87.3%
if -3.4999999999999999e-58 < b < 1.48e-154Initial program 82.8%
/-rgt-identity82.8%
metadata-eval82.8%
Simplified82.6%
Taylor expanded in b around 0 78.1%
associate-*r*78.3%
*-commutative78.3%
Simplified78.3%
if 1.48e-154 < b Initial program 21.0%
/-rgt-identity21.0%
metadata-eval21.0%
Simplified21.0%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
Applied egg-rr83.8%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4.2e-57)
(* (/ 1.0 a) (* b -0.6666666666666666))
(if (<= b 1.5e-154)
(/ (- (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 <= -4.2e-57) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else if (b <= 1.5e-154) {
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 <= (-4.2d-57)) then
tmp = (1.0d0 / a) * (b * (-0.6666666666666666d0))
else if (b <= 1.5d-154) 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 <= -4.2e-57) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else if (b <= 1.5e-154) {
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 <= -4.2e-57: tmp = (1.0 / a) * (b * -0.6666666666666666) elif b <= 1.5e-154: 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 <= -4.2e-57) tmp = Float64(Float64(1.0 / a) * Float64(b * -0.6666666666666666)); elseif (b <= 1.5e-154) 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 <= -4.2e-57) tmp = (1.0 / a) * (b * -0.6666666666666666); elseif (b <= 1.5e-154) 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, -4.2e-57], N[(N[(1.0 / a), $MachinePrecision] * N[(b * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-154], 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 -4.2 \cdot 10^{-57}:\\
\;\;\;\;\frac{1}{a} \cdot \left(b \cdot -0.6666666666666666\right)\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-154}:\\
\;\;\;\;\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 < -4.1999999999999999e-57Initial program 62.9%
/-rgt-identity62.9%
metadata-eval62.9%
Simplified62.9%
div-sub62.9%
sub-neg62.9%
div-inv62.9%
fma-undefine62.9%
add-sqr-sqrt36.8%
hypot-define52.0%
associate-/r*52.1%
metadata-eval52.1%
div-inv52.1%
associate-/r*52.0%
metadata-eval52.0%
Applied egg-rr52.0%
distribute-lft-neg-in52.0%
distribute-rgt-in52.0%
sub-neg52.0%
associate-*r*52.0%
*-commutative52.0%
associate-*r*52.0%
*-commutative52.0%
Simplified52.0%
associate-*l/52.1%
clear-num52.1%
associate-*l*52.1%
Applied egg-rr52.1%
associate-/r/52.1%
*-commutative52.1%
*-commutative52.1%
Simplified52.1%
Taylor expanded in b around -inf 87.2%
*-commutative87.2%
Simplified87.2%
if -4.1999999999999999e-57 < b < 1.5000000000000001e-154Initial program 82.8%
/-rgt-identity82.8%
metadata-eval82.8%
Simplified82.6%
Taylor expanded in b around 0 78.1%
associate-*r*78.3%
*-commutative78.3%
Simplified78.3%
if 1.5000000000000001e-154 < b Initial program 21.0%
/-rgt-identity21.0%
metadata-eval21.0%
Simplified21.0%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
Applied egg-rr83.8%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.4e-57)
(* (/ 1.0 a) (* b -0.6666666666666666))
(if (<= b 1.5e-154)
(* (/ 0.3333333333333333 a) (- (sqrt (* a (* c -3.0))) b))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.4e-57) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else if (b <= 1.5e-154) {
tmp = (0.3333333333333333 / a) * (sqrt((a * (c * -3.0))) - 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 <= (-1.4d-57)) then
tmp = (1.0d0 / a) * (b * (-0.6666666666666666d0))
else if (b <= 1.5d-154) then
tmp = (0.3333333333333333d0 / a) * (sqrt((a * (c * (-3.0d0)))) - 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 <= -1.4e-57) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else if (b <= 1.5e-154) {
tmp = (0.3333333333333333 / a) * (Math.sqrt((a * (c * -3.0))) - b);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.4e-57: tmp = (1.0 / a) * (b * -0.6666666666666666) elif b <= 1.5e-154: tmp = (0.3333333333333333 / a) * (math.sqrt((a * (c * -3.0))) - b) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.4e-57) tmp = Float64(Float64(1.0 / a) * Float64(b * -0.6666666666666666)); elseif (b <= 1.5e-154) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(a * Float64(c * -3.0))) - 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 <= -1.4e-57) tmp = (1.0 / a) * (b * -0.6666666666666666); elseif (b <= 1.5e-154) tmp = (0.3333333333333333 / a) * (sqrt((a * (c * -3.0))) - b); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.4e-57], N[(N[(1.0 / a), $MachinePrecision] * N[(b * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-154], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4 \cdot 10^{-57}:\\
\;\;\;\;\frac{1}{a} \cdot \left(b \cdot -0.6666666666666666\right)\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-154}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{a \cdot \left(c \cdot -3\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.4e-57Initial program 62.9%
/-rgt-identity62.9%
metadata-eval62.9%
Simplified62.9%
div-sub62.9%
sub-neg62.9%
div-inv62.9%
fma-undefine62.9%
add-sqr-sqrt36.8%
hypot-define52.0%
associate-/r*52.1%
metadata-eval52.1%
div-inv52.1%
associate-/r*52.0%
metadata-eval52.0%
Applied egg-rr52.0%
distribute-lft-neg-in52.0%
distribute-rgt-in52.0%
sub-neg52.0%
associate-*r*52.0%
*-commutative52.0%
associate-*r*52.0%
*-commutative52.0%
Simplified52.0%
associate-*l/52.1%
clear-num52.1%
associate-*l*52.1%
Applied egg-rr52.1%
associate-/r/52.1%
*-commutative52.1%
*-commutative52.1%
Simplified52.1%
Taylor expanded in b around -inf 87.2%
*-commutative87.2%
Simplified87.2%
if -1.4e-57 < b < 1.5000000000000001e-154Initial program 82.8%
/-rgt-identity82.8%
metadata-eval82.8%
Simplified82.6%
Taylor expanded in b around 0 78.1%
associate-*r*78.3%
*-commutative78.3%
Simplified78.3%
clear-num78.3%
associate-/r/78.2%
associate-/r*78.3%
metadata-eval78.3%
*-commutative78.3%
*-commutative78.3%
associate-*l*78.3%
Applied egg-rr78.3%
if 1.5000000000000001e-154 < b Initial program 21.0%
/-rgt-identity21.0%
metadata-eval21.0%
Simplified21.0%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
Applied egg-rr83.8%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.05e-67)
(* (/ 1.0 a) (* b -0.6666666666666666))
(if (<= b 1.5e-154)
(* 0.3333333333333333 (/ (- (sqrt (* a (* c -3.0))) b) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-67) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else if (b <= 1.5e-154) {
tmp = 0.3333333333333333 * ((sqrt((a * (c * -3.0))) - b) / 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 <= (-1.05d-67)) then
tmp = (1.0d0 / a) * (b * (-0.6666666666666666d0))
else if (b <= 1.5d-154) then
tmp = 0.3333333333333333d0 * ((sqrt((a * (c * (-3.0d0)))) - b) / 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 <= -1.05e-67) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else if (b <= 1.5e-154) {
tmp = 0.3333333333333333 * ((Math.sqrt((a * (c * -3.0))) - b) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-67: tmp = (1.0 / a) * (b * -0.6666666666666666) elif b <= 1.5e-154: tmp = 0.3333333333333333 * ((math.sqrt((a * (c * -3.0))) - b) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.05e-67) tmp = Float64(Float64(1.0 / a) * Float64(b * -0.6666666666666666)); elseif (b <= 1.5e-154) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / 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 <= -1.05e-67) tmp = (1.0 / a) * (b * -0.6666666666666666); elseif (b <= 1.5e-154) tmp = 0.3333333333333333 * ((sqrt((a * (c * -3.0))) - b) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-67], N[(N[(1.0 / a), $MachinePrecision] * N[(b * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-154], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-67}:\\
\;\;\;\;\frac{1}{a} \cdot \left(b \cdot -0.6666666666666666\right)\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-154}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.0500000000000001e-67Initial program 62.9%
/-rgt-identity62.9%
metadata-eval62.9%
Simplified62.9%
div-sub62.9%
sub-neg62.9%
div-inv62.9%
fma-undefine62.9%
add-sqr-sqrt36.8%
hypot-define52.0%
associate-/r*52.1%
metadata-eval52.1%
div-inv52.1%
associate-/r*52.0%
metadata-eval52.0%
Applied egg-rr52.0%
distribute-lft-neg-in52.0%
distribute-rgt-in52.0%
sub-neg52.0%
associate-*r*52.0%
*-commutative52.0%
associate-*r*52.0%
*-commutative52.0%
Simplified52.0%
associate-*l/52.1%
clear-num52.1%
associate-*l*52.1%
Applied egg-rr52.1%
associate-/r/52.1%
*-commutative52.1%
*-commutative52.1%
Simplified52.1%
Taylor expanded in b around -inf 87.2%
*-commutative87.2%
Simplified87.2%
if -1.0500000000000001e-67 < b < 1.5000000000000001e-154Initial program 82.8%
/-rgt-identity82.8%
metadata-eval82.8%
Simplified82.6%
Taylor expanded in b around 0 78.1%
associate-*r*78.3%
*-commutative78.3%
Simplified78.3%
*-un-lft-identity78.3%
times-frac78.1%
metadata-eval78.1%
*-commutative78.1%
*-commutative78.1%
associate-*l*78.1%
Applied egg-rr78.1%
if 1.5000000000000001e-154 < b Initial program 21.0%
/-rgt-identity21.0%
metadata-eval21.0%
Simplified21.0%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
Applied egg-rr83.8%
Final simplification83.8%
(FPCore (a b c) :precision binary64 (if (<= b 1.7e-307) (* (/ 1.0 a) (* b -0.6666666666666666)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-307) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.7d-307) then
tmp = (1.0d0 / a) * (b * (-0.6666666666666666d0))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-307) {
tmp = (1.0 / a) * (b * -0.6666666666666666);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.7e-307: tmp = (1.0 / a) * (b * -0.6666666666666666) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.7e-307) tmp = Float64(Float64(1.0 / a) * Float64(b * -0.6666666666666666)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.7e-307) tmp = (1.0 / a) * (b * -0.6666666666666666); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.7e-307], N[(N[(1.0 / a), $MachinePrecision] * N[(b * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-307}:\\
\;\;\;\;\frac{1}{a} \cdot \left(b \cdot -0.6666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.69999999999999994e-307Initial program 68.6%
/-rgt-identity68.6%
metadata-eval68.6%
Simplified68.5%
div-sub68.5%
sub-neg68.5%
div-inv68.5%
fma-undefine68.5%
add-sqr-sqrt48.0%
hypot-define60.3%
associate-/r*60.3%
metadata-eval60.3%
div-inv60.3%
associate-/r*60.3%
metadata-eval60.3%
Applied egg-rr60.3%
distribute-lft-neg-in60.3%
distribute-rgt-in60.3%
sub-neg60.3%
associate-*r*60.3%
*-commutative60.3%
associate-*r*60.3%
*-commutative60.3%
Simplified60.3%
associate-*l/60.3%
clear-num60.3%
associate-*l*60.3%
Applied egg-rr60.3%
associate-/r/60.3%
*-commutative60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in b around -inf 67.2%
*-commutative67.2%
Simplified67.2%
if 1.69999999999999994e-307 < b Initial program 28.3%
/-rgt-identity28.3%
metadata-eval28.3%
Simplified28.3%
Taylor expanded in b around inf 74.9%
associate-*r/74.9%
Applied egg-rr74.9%
Final simplification71.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-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 <= (-5d-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 <= -5e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * -0.6666666666666666) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-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 <= -5e-310) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 68.6%
/-rgt-identity68.6%
metadata-eval68.6%
Simplified68.5%
div-sub68.5%
sub-neg68.5%
div-inv68.5%
fma-undefine68.5%
add-sqr-sqrt48.0%
hypot-define60.3%
associate-/r*60.3%
metadata-eval60.3%
div-inv60.3%
associate-/r*60.3%
metadata-eval60.3%
Applied egg-rr60.3%
distribute-lft-neg-in60.3%
distribute-rgt-in60.3%
sub-neg60.3%
associate-*r*60.3%
*-commutative60.3%
associate-*r*60.3%
*-commutative60.3%
Simplified60.3%
associate-*l/60.3%
clear-num60.3%
associate-*l*60.3%
Applied egg-rr60.3%
associate-/r/60.3%
*-commutative60.3%
*-commutative60.3%
Simplified60.3%
associate-*l/60.3%
*-un-lft-identity60.3%
*-commutative60.3%
Applied egg-rr60.3%
associate-*r/60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in b around -inf 67.1%
associate-*r/67.2%
*-commutative67.2%
Simplified67.2%
if -4.999999999999985e-310 < b Initial program 28.3%
/-rgt-identity28.3%
metadata-eval28.3%
Simplified28.3%
Taylor expanded in b around inf 74.9%
associate-*r/74.9%
Applied egg-rr74.9%
Final simplification71.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 68.6%
/-rgt-identity68.6%
metadata-eval68.6%
Simplified68.5%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
if -4.999999999999985e-310 < b Initial program 28.3%
/-rgt-identity28.3%
metadata-eval28.3%
Simplified28.3%
Taylor expanded in b around inf 74.9%
associate-*r/74.9%
Applied egg-rr74.9%
Final simplification71.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-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 <= (-5d-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 <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-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 <= -5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-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 -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 68.6%
/-rgt-identity68.6%
metadata-eval68.6%
Simplified68.5%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
if -4.999999999999985e-310 < b Initial program 28.3%
/-rgt-identity28.3%
metadata-eval28.3%
Simplified28.3%
Taylor expanded in b around inf 74.9%
Final simplification71.5%
(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 46.1%
/-rgt-identity46.1%
metadata-eval46.1%
Simplified46.0%
Taylor expanded in b around inf 42.9%
herbie shell --seed 2024144
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))