
(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 -6.5e+31)
(/ (/ (* b 2.0) a) -3.0)
(if (<= b 2.2e-50)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+31) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 2.2e-50) {
tmp = (sqrt(((b * b) - ((a * 3.0) * 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 <= (-6.5d+31)) then
tmp = ((b * 2.0d0) / a) / (-3.0d0)
else if (b <= 2.2d-50) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * 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 <= -6.5e+31) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 2.2e-50) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e+31: tmp = ((b * 2.0) / a) / -3.0 elif b <= 2.2e-50: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e+31) tmp = Float64(Float64(Float64(b * 2.0) / a) / -3.0); elseif (b <= 2.2e-50) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * 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 <= -6.5e+31) tmp = ((b * 2.0) / a) / -3.0; elseif (b <= 2.2e-50) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e+31], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 2.2e-50], 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 / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{+31}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.5000000000000004e31Initial program 78.5%
sqr-neg78.5%
sqr-neg78.5%
associate-*l*78.5%
Simplified78.5%
Applied egg-rr57.7%
associate-*l/57.7%
un-div-inv57.7%
Applied egg-rr57.7%
Taylor expanded in b around -inf 98.5%
*-commutative98.5%
Simplified98.5%
if -6.5000000000000004e31 < b < 2.1999999999999999e-50Initial program 74.2%
if 2.1999999999999999e-50 < b Initial program 15.7%
sqr-neg15.7%
sqr-neg15.7%
associate-*l*15.7%
Simplified15.7%
Taylor expanded in b around inf 84.4%
*-commutative84.4%
Simplified84.4%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.7e+31)
(/ (/ (* b 2.0) a) -3.0)
(if (<= b 5.1e-49)
(/ (- (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.7e+31) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 5.1e-49) {
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.7d+31)) then
tmp = ((b * 2.0d0) / a) / (-3.0d0)
else if (b <= 5.1d-49) 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.7e+31) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 5.1e-49) {
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.7e+31: tmp = ((b * 2.0) / a) / -3.0 elif b <= 5.1e-49: 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.7e+31) tmp = Float64(Float64(Float64(b * 2.0) / a) / -3.0); elseif (b <= 5.1e-49) 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.7e+31) tmp = ((b * 2.0) / a) / -3.0; elseif (b <= 5.1e-49) 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.7e+31], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 5.1e-49], 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.7 \cdot 10^{+31}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{elif}\;b \leq 5.1 \cdot 10^{-49}:\\
\;\;\;\;\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.69999999999999986e31Initial program 78.5%
sqr-neg78.5%
sqr-neg78.5%
associate-*l*78.5%
Simplified78.5%
Applied egg-rr57.7%
associate-*l/57.7%
un-div-inv57.7%
Applied egg-rr57.7%
Taylor expanded in b around -inf 98.5%
*-commutative98.5%
Simplified98.5%
if -2.69999999999999986e31 < b < 5.10000000000000026e-49Initial program 74.2%
sqr-neg74.2%
sqr-neg74.2%
associate-*l*74.2%
Simplified74.2%
if 5.10000000000000026e-49 < b Initial program 15.7%
sqr-neg15.7%
sqr-neg15.7%
associate-*l*15.7%
Simplified15.7%
Taylor expanded in b around inf 84.4%
*-commutative84.4%
Simplified84.4%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e+16)
(/ (/ (* b 2.0) a) -3.0)
(if (<= b 2.6e-50)
(/ (/ (- (* b 2.0) (sqrt (* a (* -3.0 c)))) a) -3.0)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e+16) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 2.6e-50) {
tmp = (((b * 2.0) - sqrt((a * (-3.0 * c)))) / 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 <= (-1.45d+16)) then
tmp = ((b * 2.0d0) / a) / (-3.0d0)
else if (b <= 2.6d-50) then
tmp = (((b * 2.0d0) - sqrt((a * ((-3.0d0) * c)))) / 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 <= -1.45e+16) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 2.6e-50) {
tmp = (((b * 2.0) - Math.sqrt((a * (-3.0 * c)))) / a) / -3.0;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.45e+16: tmp = ((b * 2.0) / a) / -3.0 elif b <= 2.6e-50: tmp = (((b * 2.0) - math.sqrt((a * (-3.0 * c)))) / a) / -3.0 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.45e+16) tmp = Float64(Float64(Float64(b * 2.0) / a) / -3.0); elseif (b <= 2.6e-50) tmp = Float64(Float64(Float64(Float64(b * 2.0) - sqrt(Float64(a * Float64(-3.0 * c)))) / 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 <= -1.45e+16) tmp = ((b * 2.0) / a) / -3.0; elseif (b <= 2.6e-50) tmp = (((b * 2.0) - sqrt((a * (-3.0 * c)))) / a) / -3.0; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.45e+16], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 2.6e-50], N[(N[(N[(N[(b * 2.0), $MachinePrecision] - N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{b \cdot 2 - \sqrt{a \cdot \left(-3 \cdot c\right)}}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.45e16Initial program 79.6%
sqr-neg79.6%
sqr-neg79.6%
associate-*l*79.6%
Simplified79.6%
Applied egg-rr57.3%
associate-*l/57.3%
un-div-inv57.3%
Applied egg-rr57.3%
Taylor expanded in b around -inf 97.3%
*-commutative97.3%
Simplified97.3%
if -1.45e16 < b < 2.6000000000000001e-50Initial program 73.1%
sqr-neg73.1%
sqr-neg73.1%
associate-*l*73.1%
Simplified73.1%
Applied egg-rr71.5%
associate-*l/71.4%
un-div-inv71.5%
Applied egg-rr71.5%
div-inv71.4%
Applied egg-rr70.2%
associate-*r/70.3%
*-rgt-identity70.3%
associate-+r-70.3%
count-270.3%
Simplified70.3%
if 2.6000000000000001e-50 < b Initial program 15.7%
sqr-neg15.7%
sqr-neg15.7%
associate-*l*15.7%
Simplified15.7%
Taylor expanded in b around inf 84.4%
*-commutative84.4%
Simplified84.4%
Final simplification83.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.05e-58)
(/ (/ (* b 2.0) a) -3.0)
(if (<= b 4.4e-51)
(/ (- (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 <= -2.05e-58) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 4.4e-51) {
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 <= (-2.05d-58)) then
tmp = ((b * 2.0d0) / a) / (-3.0d0)
else if (b <= 4.4d-51) 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 <= -2.05e-58) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 4.4e-51) {
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 <= -2.05e-58: tmp = ((b * 2.0) / a) / -3.0 elif b <= 4.4e-51: 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 <= -2.05e-58) tmp = Float64(Float64(Float64(b * 2.0) / a) / -3.0); elseif (b <= 4.4e-51) 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 <= -2.05e-58) tmp = ((b * 2.0) / a) / -3.0; elseif (b <= 4.4e-51) 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, -2.05e-58], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 4.4e-51], 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 -2.05 \cdot 10^{-58}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-51}:\\
\;\;\;\;\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 < -2.05000000000000014e-58Initial program 78.5%
sqr-neg78.5%
sqr-neg78.5%
associate-*l*78.6%
Simplified78.6%
Applied egg-rr58.6%
associate-*l/58.5%
un-div-inv58.6%
Applied egg-rr58.6%
Taylor expanded in b around -inf 86.8%
*-commutative86.8%
Simplified86.8%
if -2.05000000000000014e-58 < b < 4.4e-51Initial program 72.8%
sqr-neg72.8%
sqr-neg72.8%
associate-*l*72.8%
Simplified72.8%
Taylor expanded in b around 0 68.0%
associate-*r*68.1%
*-commutative68.1%
Simplified68.1%
if 4.4e-51 < b Initial program 15.7%
sqr-neg15.7%
sqr-neg15.7%
associate-*l*15.7%
Simplified15.7%
Taylor expanded in b around inf 84.4%
*-commutative84.4%
Simplified84.4%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(if (<= b -5.3e-64)
(/ (/ (* b 2.0) a) -3.0)
(if (<= b 4.6e-49)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.3e-64) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 4.6e-49) {
tmp = (sqrt((-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 <= (-5.3d-64)) then
tmp = ((b * 2.0d0) / a) / (-3.0d0)
else if (b <= 4.6d-49) then
tmp = (sqrt(((-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 <= -5.3e-64) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 4.6e-49) {
tmp = (Math.sqrt((-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 <= -5.3e-64: tmp = ((b * 2.0) / a) / -3.0 elif b <= 4.6e-49: tmp = (math.sqrt((-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 <= -5.3e-64) tmp = Float64(Float64(Float64(b * 2.0) / a) / -3.0); elseif (b <= 4.6e-49) tmp = Float64(Float64(sqrt(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 <= -5.3e-64) tmp = ((b * 2.0) / a) / -3.0; elseif (b <= 4.6e-49) tmp = (sqrt((-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, -5.3e-64], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 4.6e-49], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $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 -5.3 \cdot 10^{-64}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{-49}:\\
\;\;\;\;\frac{\sqrt{-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 < -5.3000000000000002e-64Initial program 78.5%
sqr-neg78.5%
sqr-neg78.5%
associate-*l*78.6%
Simplified78.6%
Applied egg-rr58.6%
associate-*l/58.5%
un-div-inv58.6%
Applied egg-rr58.6%
Taylor expanded in b around -inf 86.8%
*-commutative86.8%
Simplified86.8%
if -5.3000000000000002e-64 < b < 4.5999999999999998e-49Initial program 72.8%
sqr-neg72.8%
sqr-neg72.8%
associate-*l*72.8%
Simplified72.8%
Taylor expanded in b around 0 68.0%
associate-*r*68.1%
*-commutative68.1%
Simplified68.1%
+-commutative68.1%
associate-*r*68.0%
sqrt-prod41.6%
*-commutative41.6%
sqrt-prod68.0%
unsub-neg68.0%
Applied egg-rr68.0%
Taylor expanded in a around 0 68.0%
if 4.5999999999999998e-49 < b Initial program 15.7%
sqr-neg15.7%
sqr-neg15.7%
associate-*l*15.7%
Simplified15.7%
Taylor expanded in b around inf 84.4%
*-commutative84.4%
Simplified84.4%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(if (<= b -7.2e-62)
(/ (/ (* b 2.0) a) -3.0)
(if (<= b 1.28e-49)
(* -0.3333333333333333 (/ (- b (sqrt (* a (* -3.0 c)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.2e-62) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 1.28e-49) {
tmp = -0.3333333333333333 * ((b - sqrt((a * (-3.0 * c)))) / 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 <= (-7.2d-62)) then
tmp = ((b * 2.0d0) / a) / (-3.0d0)
else if (b <= 1.28d-49) then
tmp = (-0.3333333333333333d0) * ((b - sqrt((a * ((-3.0d0) * c)))) / 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 <= -7.2e-62) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 1.28e-49) {
tmp = -0.3333333333333333 * ((b - Math.sqrt((a * (-3.0 * c)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.2e-62: tmp = ((b * 2.0) / a) / -3.0 elif b <= 1.28e-49: tmp = -0.3333333333333333 * ((b - math.sqrt((a * (-3.0 * c)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.2e-62) tmp = Float64(Float64(Float64(b * 2.0) / a) / -3.0); elseif (b <= 1.28e-49) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(a * Float64(-3.0 * c)))) / 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 <= -7.2e-62) tmp = ((b * 2.0) / a) / -3.0; elseif (b <= 1.28e-49) tmp = -0.3333333333333333 * ((b - sqrt((a * (-3.0 * c)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.2e-62], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 1.28e-49], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{elif}\;b \leq 1.28 \cdot 10^{-49}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{a \cdot \left(-3 \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.1999999999999999e-62Initial program 78.5%
sqr-neg78.5%
sqr-neg78.5%
associate-*l*78.6%
Simplified78.6%
Applied egg-rr58.6%
associate-*l/58.5%
un-div-inv58.6%
Applied egg-rr58.6%
Taylor expanded in b around -inf 86.8%
*-commutative86.8%
Simplified86.8%
if -7.1999999999999999e-62 < b < 1.28e-49Initial program 72.8%
sqr-neg72.8%
sqr-neg72.8%
associate-*l*72.8%
Simplified72.8%
Taylor expanded in b around 0 68.0%
associate-*r*68.1%
*-commutative68.1%
Simplified68.1%
+-commutative68.1%
associate-*r*68.0%
sqrt-prod41.6%
*-commutative41.6%
sqrt-prod68.0%
unsub-neg68.0%
Applied egg-rr68.0%
frac-2neg68.0%
div-inv67.9%
sub-neg67.9%
+-commutative67.9%
distribute-neg-in67.9%
add-sqr-sqrt37.9%
sqrt-unprod67.3%
sqr-neg67.3%
sqrt-unprod30.1%
add-sqr-sqrt66.6%
sub-neg66.6%
add-sqr-sqrt36.5%
sqrt-unprod66.7%
sqr-neg66.7%
sqrt-unprod30.0%
add-sqr-sqrt67.9%
*-commutative67.9%
distribute-rgt-neg-in67.9%
metadata-eval67.9%
Applied egg-rr67.9%
associate-*r/68.0%
*-rgt-identity68.0%
metadata-eval68.0%
distribute-rgt-neg-in68.0%
distribute-neg-frac268.0%
distribute-neg-frac68.0%
neg-mul-168.0%
*-commutative68.0%
times-frac67.9%
metadata-eval67.9%
Simplified67.9%
if 1.28e-49 < b Initial program 15.7%
sqr-neg15.7%
sqr-neg15.7%
associate-*l*15.7%
Simplified15.7%
Taylor expanded in b around inf 84.4%
*-commutative84.4%
Simplified84.4%
Final simplification80.5%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (/ (* b 2.0) a) -3.0) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = ((b * 2.0) / 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 <= (-2d-310)) then
tmp = ((b * 2.0d0) / 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 <= -2e-310) {
tmp = ((b * 2.0) / a) / -3.0;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = ((b * 2.0) / a) / -3.0 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(Float64(b * 2.0) / 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 <= -2e-310) tmp = ((b * 2.0) / a) / -3.0; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 79.8%
sqr-neg79.8%
sqr-neg79.8%
associate-*l*79.8%
Simplified79.8%
Applied egg-rr66.0%
associate-*l/65.9%
un-div-inv66.0%
Applied egg-rr66.0%
Taylor expanded in b around -inf 67.5%
*-commutative67.5%
Simplified67.5%
if -1.999999999999994e-310 < b Initial program 29.1%
sqr-neg29.1%
sqr-neg29.1%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
Simplified67.5%
(FPCore (a b c) :precision binary64 (if (<= b 3e-309) (/ b (* a -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3e-309) {
tmp = b / (a * -1.5);
} 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 <= 3d-309) then
tmp = b / (a * (-1.5d0))
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 <= 3e-309) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3e-309: tmp = b / (a * -1.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3e-309) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3e-309) tmp = b / (a * -1.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3e-309], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3 \cdot 10^{-309}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.000000000000001e-309Initial program 79.8%
add-cube-cbrt78.9%
pow379.0%
Applied egg-rr79.0%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
*-commutative67.1%
rem-cube-cbrt67.5%
times-frac67.4%
metadata-eval67.4%
associate-*l/67.3%
associate-/l*67.4%
Simplified67.4%
clear-num67.2%
un-div-inv67.3%
div-inv67.5%
metadata-eval67.5%
Applied egg-rr67.5%
if 3.000000000000001e-309 < b Initial program 29.1%
sqr-neg29.1%
sqr-neg29.1%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
Simplified67.5%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) 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 <= -2e-310) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], 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 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 79.8%
add-cube-cbrt78.9%
pow379.0%
Applied egg-rr79.0%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
*-commutative67.1%
rem-cube-cbrt67.5%
times-frac67.4%
metadata-eval67.4%
associate-*l/67.3%
associate-/l*67.4%
Simplified67.4%
if -1.999999999999994e-310 < b Initial program 29.1%
sqr-neg29.1%
sqr-neg29.1%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
Simplified67.5%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) 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 <= -2e-310) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], 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 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 79.8%
add-cube-cbrt78.9%
pow379.0%
Applied egg-rr79.0%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
*-commutative67.1%
rem-cube-cbrt67.5%
times-frac67.4%
metadata-eval67.4%
associate-*l/67.3%
associate-/l*67.4%
Simplified67.4%
if -1.999999999999994e-310 < b Initial program 29.1%
sqr-neg29.1%
sqr-neg29.1%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
Simplified67.5%
Taylor expanded in c around 0 67.5%
*-commutative67.5%
associate-*l/67.5%
associate-*r/67.3%
Simplified67.3%
(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 55.3%
add-cube-cbrt54.6%
pow354.7%
Applied egg-rr54.7%
Taylor expanded in b around -inf 35.9%
associate-*r/35.9%
*-commutative35.9%
rem-cube-cbrt36.1%
times-frac36.1%
metadata-eval36.1%
associate-*l/36.1%
associate-/l*36.1%
Simplified36.1%
herbie shell --seed 2024119
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))