
(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 8 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.6e+118)
(/ (/ (* b 2.0) -3.0) a)
(if (<= b 1.1e-41)
(/ (- (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.6e+118) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 1.1e-41) {
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.6d+118)) then
tmp = ((b * 2.0d0) / (-3.0d0)) / a
else if (b <= 1.1d-41) 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.6e+118) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 1.1e-41) {
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.6e+118: tmp = ((b * 2.0) / -3.0) / a elif b <= 1.1e-41: 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.6e+118) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / a); elseif (b <= 1.1e-41) 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.6e+118) tmp = ((b * 2.0) / -3.0) / a; elseif (b <= 1.1e-41) 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.6e+118], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.1e-41], 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.6 \cdot 10^{+118}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-41}:\\
\;\;\;\;\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.60000000000000016e118Initial program 57.3%
neg-sub057.3%
sqr-neg57.3%
associate-+l-57.3%
sub0-neg57.3%
sub-neg57.3%
distribute-neg-in57.3%
remove-double-neg57.3%
sqr-neg57.3%
associate-*l*57.3%
Simplified57.3%
Applied egg-rr51.8%
Taylor expanded in b around -inf 96.5%
*-commutative96.5%
Simplified96.5%
un-div-inv96.5%
*-commutative96.5%
associate-/r*96.5%
Applied egg-rr96.5%
if -2.60000000000000016e118 < b < 1.1e-41Initial program 84.6%
if 1.1e-41 < b Initial program 12.4%
neg-sub012.4%
sqr-neg12.4%
associate-+l-12.4%
sub0-neg12.4%
sub-neg12.4%
distribute-neg-in12.4%
remove-double-neg12.4%
sqr-neg12.4%
associate-*l*12.4%
Simplified12.4%
Taylor expanded in b around inf 90.1%
*-commutative90.1%
Simplified90.1%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.3e+118)
(/ (/ (* b 2.0) -3.0) a)
(if (<= b 1.3e-41)
(/ (- (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.3e+118) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 1.3e-41) {
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.3d+118)) then
tmp = ((b * 2.0d0) / (-3.0d0)) / a
else if (b <= 1.3d-41) 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.3e+118) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 1.3e-41) {
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.3e+118: tmp = ((b * 2.0) / -3.0) / a elif b <= 1.3e-41: 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.3e+118) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / a); elseif (b <= 1.3e-41) 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.3e+118) tmp = ((b * 2.0) / -3.0) / a; elseif (b <= 1.3e-41) 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.3e+118], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.3e-41], 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.3 \cdot 10^{+118}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{elif}\;b \leq 1.3 \cdot 10^{-41}:\\
\;\;\;\;\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.30000000000000016e118Initial program 57.3%
neg-sub057.3%
sqr-neg57.3%
associate-+l-57.3%
sub0-neg57.3%
sub-neg57.3%
distribute-neg-in57.3%
remove-double-neg57.3%
sqr-neg57.3%
associate-*l*57.3%
Simplified57.3%
Applied egg-rr51.8%
Taylor expanded in b around -inf 96.5%
*-commutative96.5%
Simplified96.5%
un-div-inv96.5%
*-commutative96.5%
associate-/r*96.5%
Applied egg-rr96.5%
if -2.30000000000000016e118 < b < 1.3e-41Initial program 84.6%
neg-sub084.6%
sqr-neg84.6%
associate-+l-84.6%
sub0-neg84.6%
sub-neg84.6%
distribute-neg-in84.6%
remove-double-neg84.6%
sqr-neg84.6%
associate-*l*84.4%
Simplified84.4%
if 1.3e-41 < b Initial program 12.4%
neg-sub012.4%
sqr-neg12.4%
associate-+l-12.4%
sub0-neg12.4%
sub-neg12.4%
distribute-neg-in12.4%
remove-double-neg12.4%
sqr-neg12.4%
associate-*l*12.4%
Simplified12.4%
Taylor expanded in b around inf 90.1%
*-commutative90.1%
Simplified90.1%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -9e-14)
(* b (/ -0.6666666666666666 a))
(if (<= b 2e-41)
(* (/ -0.3333333333333333 a) (- b (sqrt (* a (* -3.0 c)))))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e-14) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 2e-41) {
tmp = (-0.3333333333333333 / a) * (b - sqrt((a * (-3.0 * c))));
} 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-14)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 2d-41) then
tmp = ((-0.3333333333333333d0) / a) * (b - sqrt((a * ((-3.0d0) * c))))
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-14) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 2e-41) {
tmp = (-0.3333333333333333 / a) * (b - Math.sqrt((a * (-3.0 * c))));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9e-14: tmp = b * (-0.6666666666666666 / a) elif b <= 2e-41: tmp = (-0.3333333333333333 / a) * (b - math.sqrt((a * (-3.0 * c)))) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9e-14) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 2e-41) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(a * Float64(-3.0 * c))))); 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-14) tmp = b * (-0.6666666666666666 / a); elseif (b <= 2e-41) tmp = (-0.3333333333333333 / a) * (b - sqrt((a * (-3.0 * c)))); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9e-14], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-41], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-14}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{a \cdot \left(-3 \cdot c\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -8.9999999999999995e-14Initial program 69.5%
neg-sub069.5%
sqr-neg69.5%
associate-+l-69.5%
sub0-neg69.5%
sub-neg69.5%
distribute-neg-in69.5%
remove-double-neg69.5%
sqr-neg69.5%
associate-*l*69.5%
Simplified69.5%
Applied egg-rr58.8%
Taylor expanded in b around -inf 93.1%
*-commutative93.1%
associate-*l/93.2%
associate-/l*93.2%
Simplified93.2%
if -8.9999999999999995e-14 < b < 2.00000000000000001e-41Initial program 81.8%
neg-sub081.8%
sqr-neg81.8%
associate-+l-81.8%
sub0-neg81.8%
sub-neg81.8%
distribute-neg-in81.8%
remove-double-neg81.8%
sqr-neg81.8%
associate-*l*81.6%
Simplified81.6%
Taylor expanded in b around 0 73.8%
*-commutative73.8%
*-commutative73.8%
associate-*r*74.0%
Simplified74.0%
frac-2neg74.0%
div-inv73.9%
distribute-neg-in73.9%
add-sqr-sqrt44.3%
sqrt-unprod74.0%
sqr-neg74.0%
sqrt-unprod29.8%
add-sqr-sqrt72.0%
sub-neg72.0%
add-sqr-sqrt42.2%
sqrt-unprod71.9%
sqr-neg71.9%
sqrt-unprod29.6%
add-sqr-sqrt73.9%
distribute-lft-neg-in73.9%
metadata-eval73.9%
associate-/r*73.8%
metadata-eval73.8%
Applied egg-rr73.8%
*-commutative73.8%
associate-*r*73.8%
*-commutative73.8%
rem-square-sqrt0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt73.9%
Simplified73.9%
if 2.00000000000000001e-41 < b Initial program 12.4%
neg-sub012.4%
sqr-neg12.4%
associate-+l-12.4%
sub0-neg12.4%
sub-neg12.4%
distribute-neg-in12.4%
remove-double-neg12.4%
sqr-neg12.4%
associate-*l*12.4%
Simplified12.4%
Taylor expanded in b around inf 90.1%
*-commutative90.1%
Simplified90.1%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e-15)
(* b (/ -0.6666666666666666 a))
(if (<= b 1.7e-41)
(/ (- (sqrt (* c (* -3.0 a))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-15) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 1.7e-41) {
tmp = (sqrt((c * (-3.0 * a))) - 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 <= (-1.15d-15)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 1.7d-41) then
tmp = (sqrt((c * ((-3.0d0) * a))) - 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 <= -1.15e-15) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 1.7e-41) {
tmp = (Math.sqrt((c * (-3.0 * a))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-15: tmp = b * (-0.6666666666666666 / a) elif b <= 1.7e-41: tmp = (math.sqrt((c * (-3.0 * a))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-15) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 1.7e-41) tmp = Float64(Float64(sqrt(Float64(c * Float64(-3.0 * a))) - 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 <= -1.15e-15) tmp = b * (-0.6666666666666666 / a); elseif (b <= 1.7e-41) tmp = (sqrt((c * (-3.0 * a))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-15], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.7e-41], N[(N[(N[Sqrt[N[(c * N[(-3.0 * a), $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 -1.15 \cdot 10^{-15}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{-41}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(-3 \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.14999999999999995e-15Initial program 69.5%
neg-sub069.5%
sqr-neg69.5%
associate-+l-69.5%
sub0-neg69.5%
sub-neg69.5%
distribute-neg-in69.5%
remove-double-neg69.5%
sqr-neg69.5%
associate-*l*69.5%
Simplified69.5%
Applied egg-rr58.8%
Taylor expanded in b around -inf 93.1%
*-commutative93.1%
associate-*l/93.2%
associate-/l*93.2%
Simplified93.2%
if -1.14999999999999995e-15 < b < 1.6999999999999999e-41Initial program 81.8%
neg-sub081.8%
sqr-neg81.8%
associate-+l-81.8%
sub0-neg81.8%
sub-neg81.8%
distribute-neg-in81.8%
remove-double-neg81.8%
sqr-neg81.8%
associate-*l*81.6%
Simplified81.6%
Taylor expanded in b around 0 73.8%
*-commutative73.8%
*-commutative73.8%
associate-*r*74.0%
Simplified74.0%
if 1.6999999999999999e-41 < b Initial program 12.4%
neg-sub012.4%
sqr-neg12.4%
associate-+l-12.4%
sub0-neg12.4%
sub-neg12.4%
distribute-neg-in12.4%
remove-double-neg12.4%
sqr-neg12.4%
associate-*l*12.4%
Simplified12.4%
Taylor expanded in b around inf 90.1%
*-commutative90.1%
Simplified90.1%
Final simplification85.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.8e-232) (/ (/ (* b 2.0) -3.0) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.8e-232) {
tmp = ((b * 2.0) / -3.0) / 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.8d-232) then
tmp = ((b * 2.0d0) / (-3.0d0)) / 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.8e-232) {
tmp = ((b * 2.0) / -3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.8e-232: tmp = ((b * 2.0) / -3.0) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.8e-232) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / 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.8e-232) tmp = ((b * 2.0) / -3.0) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.8e-232], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.8 \cdot 10^{-232}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.80000000000000008e-232Initial program 75.1%
neg-sub075.1%
sqr-neg75.1%
associate-+l-75.1%
sub0-neg75.1%
sub-neg75.1%
distribute-neg-in75.1%
remove-double-neg75.1%
sqr-neg75.1%
associate-*l*75.0%
Simplified75.0%
Applied egg-rr68.9%
Taylor expanded in b around -inf 62.6%
*-commutative62.6%
Simplified62.6%
un-div-inv62.7%
*-commutative62.7%
associate-/r*62.7%
Applied egg-rr62.7%
if 1.80000000000000008e-232 < b Initial program 29.2%
neg-sub029.2%
sqr-neg29.2%
associate-+l-29.2%
sub0-neg29.2%
sub-neg29.2%
distribute-neg-in29.2%
remove-double-neg29.2%
sqr-neg29.2%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 72.0%
*-commutative72.0%
Simplified72.0%
Final simplification66.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.8e-232) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.8e-232) {
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.8d-232) 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.8e-232) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.8e-232: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.8e-232) 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 <= 1.8e-232) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.8e-232], 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 1.8 \cdot 10^{-232}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.80000000000000008e-232Initial program 75.1%
neg-sub075.1%
sqr-neg75.1%
associate-+l-75.1%
sub0-neg75.1%
sub-neg75.1%
distribute-neg-in75.1%
remove-double-neg75.1%
sqr-neg75.1%
associate-*l*75.0%
Simplified75.0%
Applied egg-rr68.9%
Taylor expanded in b around -inf 62.6%
*-commutative62.6%
associate-*l/62.6%
associate-/l*62.7%
Simplified62.7%
if 1.80000000000000008e-232 < b Initial program 29.2%
neg-sub029.2%
sqr-neg29.2%
associate-+l-29.2%
sub0-neg29.2%
sub-neg29.2%
distribute-neg-in29.2%
remove-double-neg29.2%
sqr-neg29.2%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 72.0%
*-commutative72.0%
Simplified72.0%
Final simplification66.7%
(FPCore (a b c) :precision binary64 (* 1.3333333333333333 (/ b a)))
double code(double a, double b, double c) {
return 1.3333333333333333 * (b / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 1.3333333333333333d0 * (b / a)
end function
public static double code(double a, double b, double c) {
return 1.3333333333333333 * (b / a);
}
def code(a, b, c): return 1.3333333333333333 * (b / a)
function code(a, b, c) return Float64(1.3333333333333333 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = 1.3333333333333333 * (b / a); end
code[a_, b_, c_] := N[(1.3333333333333333 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1.3333333333333333 \cdot \frac{b}{a}
\end{array}
Initial program 55.2%
/-rgt-identity55.2%
metadata-eval55.2%
Simplified55.1%
*-un-lft-identity55.1%
*-un-lft-identity55.1%
prod-diff55.1%
*-commutative55.1%
*-un-lft-identity55.1%
fma-define55.1%
*-un-lft-identity55.1%
+-commutative55.1%
add-sqr-sqrt40.9%
sqrt-unprod53.4%
sqr-neg53.4%
sqrt-prod12.5%
add-sqr-sqrt36.7%
fma-undefine36.7%
add-sqr-sqrt31.6%
hypot-define28.1%
Applied egg-rr27.7%
+-commutative27.7%
associate-+l+27.7%
associate-*r*27.7%
*-commutative27.7%
associate-*r*27.8%
fma-undefine27.8%
*-rgt-identity27.8%
Simplified27.8%
Taylor expanded in b around inf 2.3%
Final simplification2.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.2%
neg-sub055.2%
sqr-neg55.2%
associate-+l-55.2%
sub0-neg55.2%
sub-neg55.2%
distribute-neg-in55.2%
remove-double-neg55.2%
sqr-neg55.2%
associate-*l*55.1%
Simplified55.1%
Applied egg-rr55.1%
Taylor expanded in b around -inf 36.6%
*-commutative36.6%
associate-*l/36.6%
associate-/l*36.6%
Simplified36.6%
Final simplification36.6%
herbie shell --seed 2024059
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))