
(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 -2.9e+102)
(* (/ b a) -0.6666666666666666)
(if (<= b 2e-100)
(/ (- (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 <= -2.9e+102) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 2e-100) {
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 <= (-2.9d+102)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 2d-100) 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 <= -2.9e+102) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 2e-100) {
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 <= -2.9e+102: tmp = (b / a) * -0.6666666666666666 elif b <= 2e-100: 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 <= -2.9e+102) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 2e-100) 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 <= -2.9e+102) tmp = (b / a) * -0.6666666666666666; elseif (b <= 2e-100) 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, -2.9e+102], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 2e-100], 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 -2.9 \cdot 10^{+102}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-100}:\\
\;\;\;\;\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 < -2.9000000000000002e102Initial program 44.3%
neg-sub044.3%
sqr-neg44.3%
associate-+l-44.3%
sub0-neg44.3%
sub-neg44.3%
distribute-neg-in44.3%
remove-double-neg44.3%
sqr-neg44.3%
associate-*l*44.3%
Simplified44.3%
Taylor expanded in b around -inf 95.6%
*-commutative95.6%
Simplified95.6%
if -2.9000000000000002e102 < b < 2e-100Initial program 82.2%
if 2e-100 < b Initial program 18.5%
neg-sub018.5%
sqr-neg18.5%
associate-+l-18.5%
sub0-neg18.5%
sub-neg18.5%
distribute-neg-in18.5%
remove-double-neg18.5%
sqr-neg18.5%
associate-*l*18.5%
Simplified18.5%
Taylor expanded in b around inf 80.6%
*-commutative80.6%
Simplified80.6%
Final simplification84.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.9e+102)
(* (/ b a) -0.6666666666666666)
(if (<= b 1.95e-100)
(/ (- (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.9e+102) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.95e-100) {
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.9d+102)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 1.95d-100) 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.9e+102) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.95e-100) {
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.9e+102: tmp = (b / a) * -0.6666666666666666 elif b <= 1.95e-100: 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.9e+102) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 1.95e-100) 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.9e+102) tmp = (b / a) * -0.6666666666666666; elseif (b <= 1.95e-100) 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.9e+102], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 1.95e-100], 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.9 \cdot 10^{+102}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 1.95 \cdot 10^{-100}:\\
\;\;\;\;\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.9000000000000002e102Initial program 44.3%
neg-sub044.3%
sqr-neg44.3%
associate-+l-44.3%
sub0-neg44.3%
sub-neg44.3%
distribute-neg-in44.3%
remove-double-neg44.3%
sqr-neg44.3%
associate-*l*44.3%
Simplified44.3%
Taylor expanded in b around -inf 95.6%
*-commutative95.6%
Simplified95.6%
if -2.9000000000000002e102 < b < 1.94999999999999989e-100Initial program 82.2%
neg-sub082.2%
sqr-neg82.2%
associate-+l-82.2%
sub0-neg82.2%
sub-neg82.2%
distribute-neg-in82.2%
remove-double-neg82.2%
sqr-neg82.2%
associate-*l*82.1%
Simplified82.1%
if 1.94999999999999989e-100 < b Initial program 18.5%
neg-sub018.5%
sqr-neg18.5%
associate-+l-18.5%
sub0-neg18.5%
sub-neg18.5%
distribute-neg-in18.5%
remove-double-neg18.5%
sqr-neg18.5%
associate-*l*18.5%
Simplified18.5%
Taylor expanded in b around inf 80.6%
*-commutative80.6%
Simplified80.6%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(if (<= b -8e-61)
(/ (* b -2.0) (* a 3.0))
(if (<= b 1.6e-100)
(* (/ -0.3333333333333333 a) (- b (sqrt (* c (* a -3.0)))))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8e-61) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 1.6e-100) {
tmp = (-0.3333333333333333 / a) * (b - sqrt((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 <= (-8d-61)) then
tmp = (b * (-2.0d0)) / (a * 3.0d0)
else if (b <= 1.6d-100) then
tmp = ((-0.3333333333333333d0) / a) * (b - sqrt((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 <= -8e-61) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 1.6e-100) {
tmp = (-0.3333333333333333 / a) * (b - Math.sqrt((c * (a * -3.0))));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8e-61: tmp = (b * -2.0) / (a * 3.0) elif b <= 1.6e-100: tmp = (-0.3333333333333333 / a) * (b - math.sqrt((c * (a * -3.0)))) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8e-61) tmp = Float64(Float64(b * -2.0) / Float64(a * 3.0)); elseif (b <= 1.6e-100) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(c * 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 <= -8e-61) tmp = (b * -2.0) / (a * 3.0); elseif (b <= 1.6e-100) tmp = (-0.3333333333333333 / a) * (b - sqrt((c * (a * -3.0)))); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8e-61], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.6e-100], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8 \cdot 10^{-61}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-100}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -8.0000000000000003e-61Initial program 67.0%
neg-sub067.0%
sqr-neg67.0%
associate-+l-67.0%
sub0-neg67.0%
sub-neg67.0%
distribute-neg-in67.0%
remove-double-neg67.0%
sqr-neg67.0%
associate-*l*67.0%
Simplified67.0%
Taylor expanded in b around -inf 87.0%
*-commutative87.0%
Simplified87.0%
if -8.0000000000000003e-61 < b < 1.60000000000000008e-100Initial program 75.4%
neg-sub075.4%
sqr-neg75.4%
associate-+l-75.4%
sub0-neg75.4%
sub-neg75.4%
distribute-neg-in75.4%
remove-double-neg75.4%
sqr-neg75.4%
associate-*l*75.3%
Simplified75.3%
Taylor expanded in b around 0 72.8%
*-commutative72.8%
associate-*r*72.8%
Simplified72.8%
frac-2neg72.8%
div-inv72.7%
Applied egg-rr72.8%
*-commutative72.8%
*-commutative72.8%
Simplified72.8%
if 1.60000000000000008e-100 < b Initial program 18.5%
neg-sub018.5%
sqr-neg18.5%
associate-+l-18.5%
sub0-neg18.5%
sub-neg18.5%
distribute-neg-in18.5%
remove-double-neg18.5%
sqr-neg18.5%
associate-*l*18.5%
Simplified18.5%
Taylor expanded in b around inf 80.6%
*-commutative80.6%
Simplified80.6%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(if (<= b -5.9e-61)
(/ (* b -2.0) (* a 3.0))
(if (<= b 1.15e-100)
(/ (- (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 <= -5.9e-61) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 1.15e-100) {
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 <= (-5.9d-61)) then
tmp = (b * (-2.0d0)) / (a * 3.0d0)
else if (b <= 1.15d-100) 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 <= -5.9e-61) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 1.15e-100) {
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 <= -5.9e-61: tmp = (b * -2.0) / (a * 3.0) elif b <= 1.15e-100: 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 <= -5.9e-61) tmp = Float64(Float64(b * -2.0) / Float64(a * 3.0)); elseif (b <= 1.15e-100) 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 <= -5.9e-61) tmp = (b * -2.0) / (a * 3.0); elseif (b <= 1.15e-100) 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, -5.9e-61], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.15e-100], 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 -5.9 \cdot 10^{-61}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-100}:\\
\;\;\;\;\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 < -5.89999999999999972e-61Initial program 67.0%
neg-sub067.0%
sqr-neg67.0%
associate-+l-67.0%
sub0-neg67.0%
sub-neg67.0%
distribute-neg-in67.0%
remove-double-neg67.0%
sqr-neg67.0%
associate-*l*67.0%
Simplified67.0%
Taylor expanded in b around -inf 87.0%
*-commutative87.0%
Simplified87.0%
if -5.89999999999999972e-61 < b < 1.14999999999999997e-100Initial program 75.4%
neg-sub075.4%
sqr-neg75.4%
associate-+l-75.4%
sub0-neg75.4%
sub-neg75.4%
distribute-neg-in75.4%
remove-double-neg75.4%
sqr-neg75.4%
associate-*l*75.3%
Simplified75.3%
Taylor expanded in b around 0 72.8%
*-commutative72.8%
*-commutative72.8%
associate-*r*72.8%
Simplified72.8%
if 1.14999999999999997e-100 < b Initial program 18.5%
neg-sub018.5%
sqr-neg18.5%
associate-+l-18.5%
sub0-neg18.5%
sub-neg18.5%
distribute-neg-in18.5%
remove-double-neg18.5%
sqr-neg18.5%
associate-*l*18.5%
Simplified18.5%
Taylor expanded in b around inf 80.6%
*-commutative80.6%
Simplified80.6%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(if (<= b -3e-58)
(* b (- (* 0.6666666666666666 (/ -1.0 a)) (* -0.5 (/ c (pow b 2.0)))))
(if (<= b 2e-100)
(/ (- (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 <= -3e-58) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / pow(b, 2.0))));
} else if (b <= 2e-100) {
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 <= (-3d-58)) then
tmp = b * ((0.6666666666666666d0 * ((-1.0d0) / a)) - ((-0.5d0) * (c / (b ** 2.0d0))))
else if (b <= 2d-100) 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 <= -3e-58) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / Math.pow(b, 2.0))));
} else if (b <= 2e-100) {
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 <= -3e-58: tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / math.pow(b, 2.0)))) elif b <= 2e-100: 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 <= -3e-58) tmp = Float64(b * Float64(Float64(0.6666666666666666 * Float64(-1.0 / a)) - Float64(-0.5 * Float64(c / (b ^ 2.0))))); elseif (b <= 2e-100) 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 <= -3e-58) tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / (b ^ 2.0)))); elseif (b <= 2e-100) 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, -3e-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, 2e-100], 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 -3 \cdot 10^{-58}:\\
\;\;\;\;b \cdot \left(0.6666666666666666 \cdot \frac{-1}{a} - -0.5 \cdot \frac{c}{{b}^{2}}\right)\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-100}:\\
\;\;\;\;\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 < -3.00000000000000008e-58Initial program 67.8%
neg-sub067.8%
sqr-neg67.8%
associate-+l-67.8%
sub0-neg67.8%
sub-neg67.8%
distribute-neg-in67.8%
remove-double-neg67.8%
sqr-neg67.8%
associate-*l*67.8%
Simplified67.8%
Taylor expanded in b around -inf 88.3%
if -3.00000000000000008e-58 < b < 2e-100Initial program 74.4%
neg-sub074.4%
sqr-neg74.4%
associate-+l-74.4%
sub0-neg74.4%
sub-neg74.4%
distribute-neg-in74.4%
remove-double-neg74.4%
sqr-neg74.4%
associate-*l*74.3%
Simplified74.3%
Taylor expanded in b around 0 71.8%
*-commutative71.8%
*-commutative71.8%
associate-*r*71.8%
Simplified71.8%
if 2e-100 < b Initial program 18.5%
neg-sub018.5%
sqr-neg18.5%
associate-+l-18.5%
sub0-neg18.5%
sub-neg18.5%
distribute-neg-in18.5%
remove-double-neg18.5%
sqr-neg18.5%
associate-*l*18.5%
Simplified18.5%
Taylor expanded in b around inf 80.6%
*-commutative80.6%
Simplified80.6%
Final simplification80.7%
(FPCore (a b c) :precision binary64 (if (<= b 7.8e-300) (/ (* b -2.0) (* a 3.0)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.8e-300) {
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 <= 7.8d-300) 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 <= 7.8e-300) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.8e-300: 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 <= 7.8e-300) tmp = Float64(Float64(b * -2.0) / 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.8e-300) 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, 7.8e-300], N[(N[(b * -2.0), $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.8 \cdot 10^{-300}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 7.8000000000000002e-300Initial program 72.3%
neg-sub072.3%
sqr-neg72.3%
associate-+l-72.3%
sub0-neg72.3%
sub-neg72.3%
distribute-neg-in72.3%
remove-double-neg72.3%
sqr-neg72.3%
associate-*l*72.2%
Simplified72.2%
Taylor expanded in b around -inf 61.5%
*-commutative61.5%
Simplified61.5%
if 7.8000000000000002e-300 < b Initial program 28.7%
neg-sub028.7%
sqr-neg28.7%
associate-+l-28.7%
sub0-neg28.7%
sub-neg28.7%
distribute-neg-in28.7%
remove-double-neg28.7%
sqr-neg28.7%
associate-*l*28.7%
Simplified28.7%
Taylor expanded in b around inf 67.4%
*-commutative67.4%
Simplified67.4%
Final simplification64.5%
(FPCore (a b c) :precision binary64 (if (<= b 7.8e-300) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.8e-300) {
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 <= 7.8d-300) 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 <= 7.8e-300) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.8e-300: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.8e-300) 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 <= 7.8e-300) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.8e-300], 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 7.8 \cdot 10^{-300}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 7.8000000000000002e-300Initial program 72.3%
neg-sub072.3%
sqr-neg72.3%
associate-+l-72.3%
sub0-neg72.3%
sub-neg72.3%
distribute-neg-in72.3%
remove-double-neg72.3%
sqr-neg72.3%
associate-*l*72.2%
Simplified72.2%
Applied egg-rr65.6%
Taylor expanded in b around -inf 61.5%
associate-*r/61.5%
*-commutative61.5%
associate-/l*61.4%
Simplified61.4%
if 7.8000000000000002e-300 < b Initial program 28.7%
neg-sub028.7%
sqr-neg28.7%
associate-+l-28.7%
sub0-neg28.7%
sub-neg28.7%
distribute-neg-in28.7%
remove-double-neg28.7%
sqr-neg28.7%
associate-*l*28.7%
Simplified28.7%
Taylor expanded in b around inf 52.3%
*-commutative52.3%
associate-/l*56.6%
associate-*r*56.7%
*-commutative56.7%
associate-*r/56.6%
Simplified56.6%
Taylor expanded in a around 0 67.4%
associate-*r/67.4%
*-commutative67.4%
associate-/l*67.3%
Simplified67.3%
Final simplification64.4%
(FPCore (a b c) :precision binary64 (if (<= b 7.8e-300) (* (/ b a) -0.6666666666666666) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.8e-300) {
tmp = (b / a) * -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 <= 7.8d-300) then
tmp = (b / a) * (-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 <= 7.8e-300) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.8e-300: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.8e-300) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7.8e-300) tmp = (b / a) * -0.6666666666666666; else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.8e-300], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.8 \cdot 10^{-300}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 7.8000000000000002e-300Initial program 72.3%
neg-sub072.3%
sqr-neg72.3%
associate-+l-72.3%
sub0-neg72.3%
sub-neg72.3%
distribute-neg-in72.3%
remove-double-neg72.3%
sqr-neg72.3%
associate-*l*72.2%
Simplified72.2%
Taylor expanded in b around -inf 61.5%
*-commutative61.5%
Simplified61.5%
if 7.8000000000000002e-300 < b Initial program 28.7%
neg-sub028.7%
sqr-neg28.7%
associate-+l-28.7%
sub0-neg28.7%
sub-neg28.7%
distribute-neg-in28.7%
remove-double-neg28.7%
sqr-neg28.7%
associate-*l*28.7%
Simplified28.7%
Taylor expanded in b around inf 52.3%
*-commutative52.3%
associate-/l*56.6%
associate-*r*56.7%
*-commutative56.7%
associate-*r/56.6%
Simplified56.6%
Taylor expanded in a around 0 67.4%
associate-*r/67.4%
*-commutative67.4%
associate-/l*67.3%
Simplified67.3%
Final simplification64.4%
(FPCore (a b c) :precision binary64 (if (<= b 7.8e-300) (* (/ b a) -0.6666666666666666) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.8e-300) {
tmp = (b / a) * -0.6666666666666666;
} 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.8d-300) then
tmp = (b / a) * (-0.6666666666666666d0)
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.8e-300) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.8e-300: tmp = (b / a) * -0.6666666666666666 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.8e-300) tmp = Float64(Float64(b / a) * -0.6666666666666666); 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.8e-300) tmp = (b / a) * -0.6666666666666666; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.8e-300], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.8 \cdot 10^{-300}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 7.8000000000000002e-300Initial program 72.3%
neg-sub072.3%
sqr-neg72.3%
associate-+l-72.3%
sub0-neg72.3%
sub-neg72.3%
distribute-neg-in72.3%
remove-double-neg72.3%
sqr-neg72.3%
associate-*l*72.2%
Simplified72.2%
Taylor expanded in b around -inf 61.5%
*-commutative61.5%
Simplified61.5%
if 7.8000000000000002e-300 < b Initial program 28.7%
neg-sub028.7%
sqr-neg28.7%
associate-+l-28.7%
sub0-neg28.7%
sub-neg28.7%
distribute-neg-in28.7%
remove-double-neg28.7%
sqr-neg28.7%
associate-*l*28.7%
Simplified28.7%
Taylor expanded in b around inf 67.4%
*-commutative67.4%
Simplified67.4%
Final simplification64.5%
(FPCore (a b c) :precision binary64 (* (/ b a) 0.6666666666666666))
double code(double a, double b, double c) {
return (b / a) * 0.6666666666666666;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (b / a) * 0.6666666666666666d0
end function
public static double code(double a, double b, double c) {
return (b / a) * 0.6666666666666666;
}
def code(a, b, c): return (b / a) * 0.6666666666666666
function code(a, b, c) return Float64(Float64(b / a) * 0.6666666666666666) end
function tmp = code(a, b, c) tmp = (b / a) * 0.6666666666666666; end
code[a_, b_, c_] := N[(N[(b / a), $MachinePrecision] * 0.6666666666666666), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a} \cdot 0.6666666666666666
\end{array}
Initial program 50.0%
/-rgt-identity50.0%
metadata-eval50.0%
Simplified49.9%
sub-neg49.9%
fma-undefine49.9%
add-sqr-sqrt41.4%
hypot-define50.8%
add-sqr-sqrt31.2%
sqrt-unprod40.0%
sqr-neg40.0%
sqrt-prod13.1%
add-sqr-sqrt27.7%
Applied egg-rr27.7%
Taylor expanded in b around inf 2.7%
Final simplification2.7%
(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 50.0%
neg-sub050.0%
sqr-neg50.0%
associate-+l-50.0%
sub0-neg50.0%
sub-neg50.0%
distribute-neg-in50.0%
remove-double-neg50.0%
sqr-neg50.0%
associate-*l*50.0%
Simplified50.0%
Applied egg-rr50.8%
Taylor expanded in b around -inf 31.4%
associate-*r/31.4%
*-commutative31.4%
associate-/l*31.4%
Simplified31.4%
Final simplification31.4%
herbie shell --seed 2024077
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))