
(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 -3.6e+94)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 3e-65)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e+94) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 3e-65) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} 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 <= (-3.6d+94)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 3d-65) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
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 <= -3.6e+94) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 3e-65) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.6e+94: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 3e-65: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.6e+94) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 3e-65) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.6e+94) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 3e-65) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.6e+94], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3e-65], 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 / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{+94}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-65}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.59999999999999992e94Initial program 52.8%
Simplified52.8%
Taylor expanded in b around -inf 93.0%
mul-1-neg93.0%
*-commutative93.0%
distribute-rgt-neg-in93.0%
fma-define93.0%
associate-*r/93.0%
metadata-eval93.0%
Simplified93.0%
Taylor expanded in c around 0 93.4%
if -3.59999999999999992e94 < b < 2.99999999999999998e-65Initial program 83.4%
if 2.99999999999999998e-65 < b Initial program 11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
Final simplification86.4%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e+94)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.1e-64)
(/ (- (sqrt (- (* b b) (* a (* c 3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e+94) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.1e-64) {
tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a * 3.0);
} 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 <= (-7.5d+94)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.1d-64) then
tmp = (sqrt(((b * b) - (a * (c * 3.0d0)))) - b) / (a * 3.0d0)
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 <= -7.5e+94) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.1e-64) {
tmp = (Math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e+94: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.1e-64: tmp = (math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e+94) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.1e-64) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.5e+94) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.1e-64) tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e+94], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-64], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{+94}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-64}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.49999999999999978e94Initial program 52.8%
Simplified52.8%
Taylor expanded in b around -inf 93.0%
mul-1-neg93.0%
*-commutative93.0%
distribute-rgt-neg-in93.0%
fma-define93.0%
associate-*r/93.0%
metadata-eval93.0%
Simplified93.0%
Taylor expanded in c around 0 93.4%
if -7.49999999999999978e94 < b < 1.1e-64Initial program 83.4%
sqr-neg83.4%
sqr-neg83.4%
associate-*l*83.3%
Simplified83.3%
add-cube-cbrt83.0%
pow383.0%
Applied egg-rr83.0%
Taylor expanded in a around 0 83.3%
*-commutative83.3%
associate-*r*83.4%
*-commutative83.4%
Simplified83.4%
if 1.1e-64 < b Initial program 11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
Final simplification86.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.25e+94)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1e-65)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.25e+94) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1e-65) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} 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.25d+94)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1d-65) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
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.25e+94) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1e-65) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.25e+94: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1e-65: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.25e+94) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1e-65) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); 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.25e+94) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1e-65) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.25e+94], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-65], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{+94}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 10^{-65}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.24999999999999986e94Initial program 52.8%
Simplified52.8%
Taylor expanded in b around -inf 93.0%
mul-1-neg93.0%
*-commutative93.0%
distribute-rgt-neg-in93.0%
fma-define93.0%
associate-*r/93.0%
metadata-eval93.0%
Simplified93.0%
Taylor expanded in c around 0 93.4%
if -2.24999999999999986e94 < b < 9.99999999999999923e-66Initial program 83.4%
sqr-neg83.4%
sqr-neg83.4%
associate-*l*83.3%
Simplified83.3%
if 9.99999999999999923e-66 < b Initial program 11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(if (<= b -9e-54)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 2.1e-66)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e-54) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.1e-66) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} 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-54)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 2.1d-66) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
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-54) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.1e-66) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9e-54: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 2.1e-66: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9e-54) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 2.1e-66) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); 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-54) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 2.1e-66) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9e-54], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.1e-66], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-54}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -8.9999999999999997e-54Initial program 66.8%
Simplified66.8%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
*-commutative86.2%
distribute-rgt-neg-in86.2%
fma-define86.2%
associate-*r/86.3%
metadata-eval86.3%
Simplified86.3%
Taylor expanded in c around 0 86.5%
if -8.9999999999999997e-54 < b < 2.1e-66Initial program 79.2%
Simplified79.1%
Taylor expanded in b around 0 77.8%
associate-*r*78.0%
*-commutative78.0%
Simplified78.0%
if 2.1e-66 < b Initial program 11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.7e-53)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 2.9e-70)
(* 0.3333333333333333 (/ (- (sqrt (* a (* c -3.0))) b) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e-53) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.9e-70) {
tmp = 0.3333333333333333 * ((sqrt((a * (c * -3.0))) - 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 <= (-1.7d-53)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 2.9d-70) then
tmp = 0.3333333333333333d0 * ((sqrt((a * (c * (-3.0d0)))) - 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 <= -1.7e-53) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.9e-70) {
tmp = 0.3333333333333333 * ((Math.sqrt((a * (c * -3.0))) - b) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.7e-53: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 2.9e-70: tmp = 0.3333333333333333 * ((math.sqrt((a * (c * -3.0))) - b) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.7e-53) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 2.9e-70) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - 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 <= -1.7e-53) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 2.9e-70) tmp = 0.3333333333333333 * ((sqrt((a * (c * -3.0))) - b) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.7e-53], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.9e-70], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.7 \cdot 10^{-53}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-70}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.7e-53Initial program 66.8%
Simplified66.8%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
*-commutative86.2%
distribute-rgt-neg-in86.2%
fma-define86.2%
associate-*r/86.3%
metadata-eval86.3%
Simplified86.3%
Taylor expanded in c around 0 86.5%
if -1.7e-53 < b < 2.89999999999999971e-70Initial program 79.2%
Simplified79.1%
Taylor expanded in b around 0 77.8%
associate-*r*78.0%
*-commutative78.0%
Simplified78.0%
*-un-lft-identity78.0%
times-frac77.9%
metadata-eval77.9%
associate-*l*77.9%
Applied egg-rr77.9%
if 2.89999999999999971e-70 < b Initial program 11.4%
Simplified11.4%
Taylor expanded in b around inf 85.0%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e-67)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 5e-203)
(* (sqrt (* c (/ -3.0 a))) (- -0.3333333333333333))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-67) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 5e-203) {
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 <= (-3.6d-67)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 5d-203) 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 <= -3.6e-67) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 5e-203) {
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 <= -3.6e-67: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 5e-203: 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 <= -3.6e-67) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 5e-203) tmp = Float64(sqrt(Float64(c * Float64(-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 <= -3.6e-67) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 5e-203) 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, -3.6e-67], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e-203], N[(N[Sqrt[N[(c * N[(-3.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (--0.3333333333333333)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-67}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{-203}:\\
\;\;\;\;\sqrt{c \cdot \frac{-3}{a}} \cdot \left(--0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.59999999999999999e-67Initial program 66.8%
Simplified66.8%
Taylor expanded in b around -inf 86.2%
mul-1-neg86.2%
*-commutative86.2%
distribute-rgt-neg-in86.2%
fma-define86.2%
associate-*r/86.3%
metadata-eval86.3%
Simplified86.3%
Taylor expanded in c around 0 86.5%
if -3.59999999999999999e-67 < b < 5.0000000000000002e-203Initial program 81.6%
add-cube-cbrt80.9%
pow380.9%
Applied egg-rr80.9%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt36.6%
rem-cube-cbrt36.9%
associate-/l*36.9%
Simplified36.9%
if 5.0000000000000002e-203 < b Initial program 18.4%
Simplified18.4%
Taylor expanded in b around inf 78.1%
Final simplification73.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-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 <= -5e-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 <= (-5d-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 <= -5e-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 <= -5e-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 <= -5e-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 <= -5e-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, -5e-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 -5 \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 < -4.999999999999985e-310Initial program 71.6%
Simplified71.6%
Taylor expanded in b around -inf 62.9%
mul-1-neg62.9%
*-commutative62.9%
distribute-rgt-neg-in62.9%
fma-define62.9%
associate-*r/63.0%
metadata-eval63.0%
Simplified63.0%
Taylor expanded in c around 0 64.9%
if -4.999999999999985e-310 < b Initial program 24.0%
Simplified24.0%
Taylor expanded in b around inf 70.8%
Final simplification67.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.15e-300) (/ (* b -0.6666666666666666) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.15e-300) {
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.15d-300) 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.15e-300) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.15e-300: tmp = (b * -0.6666666666666666) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.15e-300) 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.15e-300) tmp = (b * -0.6666666666666666) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.15e-300], 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.15 \cdot 10^{-300}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.15e-300Initial program 71.8%
sqr-neg71.8%
sqr-neg71.8%
associate-*l*71.8%
Simplified71.8%
add-cube-cbrt71.6%
pow371.6%
Applied egg-rr71.6%
Taylor expanded in b around -inf 64.0%
associate-*r/64.1%
*-commutative64.1%
Simplified64.1%
if 1.15e-300 < b Initial program 23.4%
Simplified23.4%
Taylor expanded in b around inf 71.3%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.8e-301) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.8e-301) {
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 <= 2.8d-301) 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 <= 2.8e-301) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.8e-301: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.8e-301) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.8e-301) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.8e-301], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.8 \cdot 10^{-301}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.8000000000000001e-301Initial program 71.8%
Simplified71.8%
Taylor expanded in b around -inf 64.0%
*-commutative64.0%
Simplified64.0%
Taylor expanded in b around 0 64.0%
*-commutative64.0%
associate-*l/64.1%
associate-/l*64.0%
Simplified64.0%
if 2.8000000000000001e-301 < b Initial program 23.4%
Simplified23.4%
Taylor expanded in b around inf 71.3%
Final simplification67.4%
(FPCore (a b c) :precision binary64 (* (/ c b) -0.5))
double code(double a, double b, double c) {
return (c / b) * -0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * (-0.5d0)
end function
public static double code(double a, double b, double c) {
return (c / b) * -0.5;
}
def code(a, b, c): return (c / b) * -0.5
function code(a, b, c) return Float64(Float64(c / b) * -0.5) end
function tmp = code(a, b, c) tmp = (c / b) * -0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot -0.5
\end{array}
Initial program 49.1%
Simplified49.1%
Taylor expanded in b around inf 34.6%
Final simplification34.6%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 49.1%
sqr-neg49.1%
sqr-neg49.1%
associate-*l*49.1%
Simplified49.1%
add-cube-cbrt48.9%
pow348.9%
Applied egg-rr48.9%
div-inv48.9%
neg-mul-148.9%
fma-define48.9%
cancel-sign-sub-inv48.9%
fma-define48.9%
metadata-eval48.9%
unpow348.9%
add-cube-cbrt49.0%
Applied egg-rr49.0%
associate-/r*49.0%
metadata-eval49.0%
metadata-eval49.0%
associate-*r/48.9%
*-commutative48.9%
associate-*r/49.0%
metadata-eval49.0%
fma-undefine49.0%
unpow249.0%
metadata-eval49.0%
cancel-sign-sub-inv49.0%
associate-*r*49.1%
*-commutative49.1%
unpow249.1%
fma-neg49.1%
*-commutative49.1%
associate-*r*49.0%
distribute-lft-neg-in49.0%
metadata-eval49.0%
associate-*r*49.1%
*-commutative49.1%
Simplified49.1%
Taylor expanded in a around 0 12.5%
associate-*r/12.5%
distribute-rgt1-in12.5%
metadata-eval12.5%
mul0-lft12.5%
metadata-eval12.5%
div012.5%
Simplified12.5%
herbie shell --seed 2024139
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))