
(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 -5e+155)
(/ 1.0 (* -1.5 (/ a b)))
(if (<= b 3.8e-33)
(/ (- (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 <= -5e+155) {
tmp = 1.0 / (-1.5 * (a / b));
} else if (b <= 3.8e-33) {
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 <= (-5d+155)) then
tmp = 1.0d0 / ((-1.5d0) * (a / b))
else if (b <= 3.8d-33) 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 <= -5e+155) {
tmp = 1.0 / (-1.5 * (a / b));
} else if (b <= 3.8e-33) {
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 <= -5e+155: tmp = 1.0 / (-1.5 * (a / b)) elif b <= 3.8e-33: 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 <= -5e+155) tmp = Float64(1.0 / Float64(-1.5 * Float64(a / b))); elseif (b <= 3.8e-33) 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 <= -5e+155) tmp = 1.0 / (-1.5 * (a / b)); elseif (b <= 3.8e-33) 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, -5e+155], N[(1.0 / N[(-1.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e-33], 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 -5 \cdot 10^{+155}:\\
\;\;\;\;\frac{1}{-1.5 \cdot \frac{a}{b}}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-33}:\\
\;\;\;\;\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 < -4.9999999999999999e155Initial program 37.9%
sqr-neg37.9%
sqr-neg37.9%
associate-*l*37.9%
Simplified37.9%
Applied egg-rr49.0%
Taylor expanded in b around -inf 97.4%
associate-*r/97.6%
*-commutative97.6%
associate-/l*97.6%
Simplified97.6%
associate-*r/97.6%
metadata-eval97.6%
associate-/l*97.6%
un-div-inv97.5%
frac-times97.6%
clear-num97.6%
*-rgt-identity97.6%
Applied egg-rr97.6%
*-commutative97.6%
times-frac97.6%
metadata-eval97.6%
Simplified97.6%
if -4.9999999999999999e155 < b < 3.79999999999999994e-33Initial program 79.2%
sqr-neg79.2%
sqr-neg79.2%
associate-*l*79.2%
Simplified79.2%
if 3.79999999999999994e-33 < b Initial program 17.6%
sqr-neg17.6%
sqr-neg17.6%
associate-*l*17.6%
Simplified17.6%
Applied egg-rr23.1%
un-div-inv23.1%
div-inv23.1%
metadata-eval23.1%
Applied egg-rr23.1%
associate-*r/23.1%
Simplified23.1%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt81.8%
associate-*r*82.1%
metadata-eval82.1%
*-commutative82.1%
Simplified82.1%
Final simplification83.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-56)
(- (* (/ b a) (- 0.6666666666666666)) (* -0.5 (/ c b)))
(if (<= b 5.8e-33)
(* 0.3333333333333333 (/ (+ b (sqrt (* a (* c -3.0)))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-56) {
tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b));
} else if (b <= 5.8e-33) {
tmp = 0.3333333333333333 * ((b + sqrt((a * (c * -3.0)))) / 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.25d-56)) then
tmp = ((b / a) * -0.6666666666666666d0) - ((-0.5d0) * (c / b))
else if (b <= 5.8d-33) then
tmp = 0.3333333333333333d0 * ((b + sqrt((a * (c * (-3.0d0))))) / 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.25e-56) {
tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b));
} else if (b <= 5.8e-33) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((a * (c * -3.0)))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e-56: tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b)) elif b <= 5.8e-33: tmp = 0.3333333333333333 * ((b + math.sqrt((a * (c * -3.0)))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e-56) tmp = Float64(Float64(Float64(b / a) * Float64(-0.6666666666666666)) - Float64(-0.5 * Float64(c / b))); elseif (b <= 5.8e-33) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(a * Float64(c * -3.0)))) / 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.25e-56) tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b)); elseif (b <= 5.8e-33) tmp = 0.3333333333333333 * ((b + sqrt((a * (c * -3.0)))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e-56], N[(N[(N[(b / a), $MachinePrecision] * (-0.6666666666666666)), $MachinePrecision] - N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e-33], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-56}:\\
\;\;\;\;\frac{b}{a} \cdot \left(-0.6666666666666666\right) - -0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-33}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.24999999999999999e-56Initial program 69.9%
sqr-neg69.9%
sqr-neg69.9%
associate-*l*69.9%
Simplified69.9%
Taylor expanded in b around -inf 89.5%
Taylor expanded in c around 0 89.6%
if -1.24999999999999999e-56 < b < 5.80000000000000005e-33Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.1%
Simplified67.1%
Taylor expanded in b around 0 61.3%
*-un-lft-identity61.3%
*-un-lft-identity61.3%
times-frac61.1%
metadata-eval61.1%
add-sqr-sqrt25.6%
sqrt-unprod60.6%
sqr-neg60.6%
sqrt-prod35.3%
add-sqr-sqrt60.4%
*-commutative60.4%
associate-*r*60.4%
Applied egg-rr60.4%
*-lft-identity60.4%
Simplified60.4%
if 5.80000000000000005e-33 < b Initial program 17.6%
sqr-neg17.6%
sqr-neg17.6%
associate-*l*17.6%
Simplified17.6%
Applied egg-rr23.1%
un-div-inv23.1%
div-inv23.1%
metadata-eval23.1%
Applied egg-rr23.1%
associate-*r/23.1%
Simplified23.1%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt81.8%
associate-*r*82.1%
metadata-eval82.1%
*-commutative82.1%
Simplified82.1%
Final simplification79.3%
(FPCore (a b c)
:precision binary64
(if (<= b -9.5e-58)
(- (* (/ b a) (- 0.6666666666666666)) (* -0.5 (/ c b)))
(if (<= b 3.4e-33)
(/ (+ b (sqrt (* a (* c -3.0)))) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.5e-58) {
tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b));
} else if (b <= 3.4e-33) {
tmp = (b + sqrt((a * (c * -3.0)))) / (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 <= (-9.5d-58)) then
tmp = ((b / a) * -0.6666666666666666d0) - ((-0.5d0) * (c / b))
else if (b <= 3.4d-33) then
tmp = (b + sqrt((a * (c * (-3.0d0))))) / (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 <= -9.5e-58) {
tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b));
} else if (b <= 3.4e-33) {
tmp = (b + Math.sqrt((a * (c * -3.0)))) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.5e-58: tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b)) elif b <= 3.4e-33: tmp = (b + math.sqrt((a * (c * -3.0)))) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.5e-58) tmp = Float64(Float64(Float64(b / a) * Float64(-0.6666666666666666)) - Float64(-0.5 * Float64(c / b))); elseif (b <= 3.4e-33) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -3.0)))) / 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 <= -9.5e-58) tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b)); elseif (b <= 3.4e-33) tmp = (b + sqrt((a * (c * -3.0)))) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.5e-58], N[(N[(N[(b / a), $MachinePrecision] * (-0.6666666666666666)), $MachinePrecision] - N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-33], N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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 -9.5 \cdot 10^{-58}:\\
\;\;\;\;\frac{b}{a} \cdot \left(-0.6666666666666666\right) - -0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-33}:\\
\;\;\;\;\frac{b + \sqrt{a \cdot \left(c \cdot -3\right)}}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.4999999999999994e-58Initial program 69.9%
sqr-neg69.9%
sqr-neg69.9%
associate-*l*69.9%
Simplified69.9%
Taylor expanded in b around -inf 89.5%
Taylor expanded in c around 0 89.6%
if -9.4999999999999994e-58 < b < 3.4000000000000001e-33Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.1%
Simplified67.1%
Taylor expanded in b around 0 61.3%
*-un-lft-identity61.3%
*-un-lft-identity61.3%
times-frac61.1%
metadata-eval61.1%
add-sqr-sqrt25.6%
sqrt-unprod60.6%
sqr-neg60.6%
sqrt-prod35.3%
add-sqr-sqrt60.4%
*-commutative60.4%
associate-*r*60.4%
Applied egg-rr60.4%
*-lft-identity60.4%
metadata-eval60.4%
times-frac60.4%
*-commutative60.4%
*-lft-identity60.4%
Simplified60.4%
if 3.4000000000000001e-33 < b Initial program 17.6%
sqr-neg17.6%
sqr-neg17.6%
associate-*l*17.6%
Simplified17.6%
Applied egg-rr23.1%
un-div-inv23.1%
div-inv23.1%
metadata-eval23.1%
Applied egg-rr23.1%
associate-*r/23.1%
Simplified23.1%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt81.8%
associate-*r*82.1%
metadata-eval82.1%
*-commutative82.1%
Simplified82.1%
Final simplification79.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.3e-54)
(- (* (/ b a) (- 0.6666666666666666)) (* -0.5 (/ c b)))
(if (<= b 3.4e-33)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-54) {
tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b));
} else if (b <= 3.4e-33) {
tmp = (sqrt(((a * c) * -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 <= (-2.3d-54)) then
tmp = ((b / a) * -0.6666666666666666d0) - ((-0.5d0) * (c / b))
else if (b <= 3.4d-33) then
tmp = (sqrt(((a * c) * (-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 <= -2.3e-54) {
tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b));
} else if (b <= 3.4e-33) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.3e-54: tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b)) elif b <= 3.4e-33: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.3e-54) tmp = Float64(Float64(Float64(b / a) * Float64(-0.6666666666666666)) - Float64(-0.5 * Float64(c / b))); elseif (b <= 3.4e-33) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -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 <= -2.3e-54) tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b)); elseif (b <= 3.4e-33) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.3e-54], N[(N[(N[(b / a), $MachinePrecision] * (-0.6666666666666666)), $MachinePrecision] - N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-33], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $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 -2.3 \cdot 10^{-54}:\\
\;\;\;\;\frac{b}{a} \cdot \left(-0.6666666666666666\right) - -0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-33}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.2999999999999999e-54Initial program 69.9%
sqr-neg69.9%
sqr-neg69.9%
associate-*l*69.9%
Simplified69.9%
Taylor expanded in b around -inf 89.5%
Taylor expanded in c around 0 89.6%
if -2.2999999999999999e-54 < b < 3.4000000000000001e-33Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.1%
Simplified67.1%
Taylor expanded in b around 0 61.3%
if 3.4000000000000001e-33 < b Initial program 17.6%
sqr-neg17.6%
sqr-neg17.6%
associate-*l*17.6%
Simplified17.6%
Applied egg-rr23.1%
un-div-inv23.1%
div-inv23.1%
metadata-eval23.1%
Applied egg-rr23.1%
associate-*r/23.1%
Simplified23.1%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt81.8%
associate-*r*82.1%
metadata-eval82.1%
*-commutative82.1%
Simplified82.1%
Final simplification79.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (- (* (/ b a) (- 0.6666666666666666)) (* -0.5 (/ c b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((b / a) * -0.6666666666666666) - (-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 <= (-5d-310)) then
tmp = ((b / a) * -0.6666666666666666d0) - ((-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 <= -5e-310) {
tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(b / a) * Float64(-0.6666666666666666)) - 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 <= -5e-310) tmp = ((b / a) * -0.6666666666666666) - (-0.5 * (c / b)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(b / a), $MachinePrecision] * (-0.6666666666666666)), $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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot \left(-0.6666666666666666\right) - -0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 71.1%
sqr-neg71.1%
sqr-neg71.1%
associate-*l*71.1%
Simplified71.1%
Taylor expanded in b around -inf 74.0%
Taylor expanded in c around 0 74.4%
if -4.999999999999985e-310 < b Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Applied egg-rr35.0%
un-div-inv35.0%
div-inv35.0%
metadata-eval35.0%
Applied egg-rr35.0%
associate-*r/35.0%
Simplified35.0%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt62.6%
associate-*r*62.8%
metadata-eval62.8%
*-commutative62.8%
Simplified62.8%
Final simplification68.7%
(FPCore (a b c) :precision binary64 (if (<= b 2.1e-308) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-308) {
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 <= 2.1d-308) 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 <= 2.1e-308) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.1e-308: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.1e-308) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.1e-308) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.1e-308], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-308}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 2.1e-308Initial program 71.1%
sqr-neg71.1%
sqr-neg71.1%
associate-*l*71.1%
Simplified71.1%
Applied egg-rr57.1%
Taylor expanded in b around -inf 73.9%
associate-*r/73.9%
*-commutative73.9%
associate-/l*74.0%
Simplified74.0%
if 2.1e-308 < b Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Taylor expanded in b around inf 44.8%
associate-/l*52.0%
Simplified52.0%
Taylor expanded in a around 0 62.8%
associate-*r/62.8%
*-commutative62.8%
metadata-eval62.8%
rem-square-sqrt0.0%
unpow20.0%
associate-*r/0.0%
unpow20.0%
rem-square-sqrt62.5%
metadata-eval62.5%
Simplified62.5%
Final simplification68.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 71.1%
sqr-neg71.1%
sqr-neg71.1%
associate-*l*71.1%
Simplified71.1%
Applied egg-rr57.1%
Taylor expanded in b around -inf 73.9%
associate-*r/73.9%
*-commutative73.9%
associate-/l*74.0%
Simplified74.0%
if -4.999999999999985e-310 < b Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Taylor expanded in b around inf 62.8%
*-commutative62.8%
Simplified62.8%
Final simplification68.5%
(FPCore (a b c) :precision binary64 (if (<= b 6e-309) (/ b (* -1.5 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6e-309) {
tmp = b / (-1.5 * 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 <= 6d-309) then
tmp = b / ((-1.5d0) * 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 <= 6e-309) {
tmp = b / (-1.5 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6e-309: tmp = b / (-1.5 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6e-309) tmp = Float64(b / Float64(-1.5 * 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 <= 6e-309) tmp = b / (-1.5 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6e-309], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6 \cdot 10^{-309}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.000000000000001e-309Initial program 71.1%
sqr-neg71.1%
sqr-neg71.1%
associate-*l*71.1%
Simplified71.1%
Applied egg-rr57.1%
Taylor expanded in b around -inf 73.9%
associate-*r/73.9%
*-commutative73.9%
associate-/l*74.0%
Simplified74.0%
clear-num73.9%
un-div-inv74.0%
div-inv74.0%
metadata-eval74.0%
Applied egg-rr74.0%
if 6.000000000000001e-309 < b Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Taylor expanded in b around inf 62.8%
*-commutative62.8%
Simplified62.8%
Final simplification68.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* -1.5 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (-1.5 * 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 / ((-1.5d0) * 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 / (-1.5 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (-1.5 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(-1.5 * 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 / (-1.5 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / N[(-1.5 * 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}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 71.1%
sqr-neg71.1%
sqr-neg71.1%
associate-*l*71.1%
Simplified71.1%
Applied egg-rr57.1%
Taylor expanded in b around -inf 73.9%
associate-*r/73.9%
*-commutative73.9%
associate-/l*74.0%
Simplified74.0%
clear-num73.9%
un-div-inv74.0%
div-inv74.0%
metadata-eval74.0%
Applied egg-rr74.0%
if -4.999999999999985e-310 < b Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Applied egg-rr35.0%
un-div-inv35.0%
div-inv35.0%
metadata-eval35.0%
Applied egg-rr35.0%
associate-*r/35.0%
Simplified35.0%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt62.6%
associate-*r*62.8%
metadata-eval62.8%
*-commutative62.8%
Simplified62.8%
Final simplification68.5%
(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.6%
sqr-neg51.6%
sqr-neg51.6%
associate-*l*51.6%
Simplified51.6%
Applied egg-rr46.2%
Taylor expanded in b around -inf 39.0%
associate-*r/39.0%
*-commutative39.0%
associate-/l*39.0%
Simplified39.0%
Final simplification39.0%
herbie shell --seed 2024112
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))