
(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 -6.8e+41)
(/ (/ (* b -2.0) a) 3.0)
(if (or (<= b 2.2e-94) (and (not (<= b 3.1e-80)) (<= b 0.135)))
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.8e+41) {
tmp = ((b * -2.0) / a) / 3.0;
} else if ((b <= 2.2e-94) || (!(b <= 3.1e-80) && (b <= 0.135))) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} 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 <= (-6.8d+41)) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
else if ((b <= 2.2d-94) .or. (.not. (b <= 3.1d-80)) .and. (b <= 0.135d0)) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
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 <= -6.8e+41) {
tmp = ((b * -2.0) / a) / 3.0;
} else if ((b <= 2.2e-94) || (!(b <= 3.1e-80) && (b <= 0.135))) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.8e+41: tmp = ((b * -2.0) / a) / 3.0 elif (b <= 2.2e-94) or (not (b <= 3.1e-80) and (b <= 0.135)): tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.8e+41) tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0); elseif ((b <= 2.2e-94) || (!(b <= 3.1e-80) && (b <= 0.135))) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.8e+41) tmp = ((b * -2.0) / a) / 3.0; elseif ((b <= 2.2e-94) || (~((b <= 3.1e-80)) && (b <= 0.135))) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.8e+41], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[Or[LessEqual[b, 2.2e-94], And[N[Not[LessEqual[b, 3.1e-80]], $MachinePrecision], LessEqual[b, 0.135]]], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.8 \cdot 10^{+41}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-94} \lor \neg \left(b \leq 3.1 \cdot 10^{-80}\right) \land b \leq 0.135:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -6.79999999999999996e41Initial program 58.9%
sqr-neg58.9%
sqr-neg58.9%
associate-*l*58.9%
Simplified58.9%
Taylor expanded in b around -inf 97.2%
*-commutative97.2%
Simplified97.2%
expm1-log1p-u54.8%
expm1-udef44.8%
times-frac44.8%
Applied egg-rr44.8%
expm1-def54.8%
expm1-log1p97.1%
associate-*r/97.3%
associate-*l/97.3%
associate-/r*97.2%
*-rgt-identity97.2%
associate-*r/97.2%
associate-*l*97.2%
associate-/r*97.1%
metadata-eval97.1%
associate-*r/97.1%
metadata-eval97.1%
Simplified97.1%
clear-num97.1%
div-inv97.2%
associate-/r/97.1%
metadata-eval97.1%
times-frac97.2%
associate-/r*97.3%
Applied egg-rr97.3%
if -6.79999999999999996e41 < b < 2.20000000000000001e-94 or 3.10000000000000016e-80 < b < 0.13500000000000001Initial program 80.3%
if 2.20000000000000001e-94 < b < 3.10000000000000016e-80 or 0.13500000000000001 < b Initial program 16.6%
sqr-neg16.6%
sqr-neg16.6%
associate-*l*16.6%
Simplified16.6%
Taylor expanded in b around inf 83.2%
Final simplification86.1%
(FPCore (a b c)
:precision binary64
(if (<= b -9.2e+38)
(/ (/ (* b -2.0) a) 3.0)
(if (or (<= b 2.1e-94) (and (not (<= b 1.04e-78)) (<= b 0.135)))
(/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (/ a 0.3333333333333333))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.2e+38) {
tmp = ((b * -2.0) / a) / 3.0;
} else if ((b <= 2.1e-94) || (!(b <= 1.04e-78) && (b <= 0.135))) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
} 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 <= (-9.2d+38)) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
else if ((b <= 2.1d-94) .or. (.not. (b <= 1.04d-78)) .and. (b <= 0.135d0)) then
tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (a / 0.3333333333333333d0)
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 <= -9.2e+38) {
tmp = ((b * -2.0) / a) / 3.0;
} else if ((b <= 2.1e-94) || (!(b <= 1.04e-78) && (b <= 0.135))) {
tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.2e+38: tmp = ((b * -2.0) / a) / 3.0 elif (b <= 2.1e-94) or (not (b <= 1.04e-78) and (b <= 0.135)): tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.2e+38) tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0); elseif ((b <= 2.1e-94) || (!(b <= 1.04e-78) && (b <= 0.135))) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(a / 0.3333333333333333)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.2e+38) tmp = ((b * -2.0) / a) / 3.0; elseif ((b <= 2.1e-94) || (~((b <= 1.04e-78)) && (b <= 0.135))) tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.2e+38], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[Or[LessEqual[b, 2.1e-94], And[N[Not[LessEqual[b, 1.04e-78]], $MachinePrecision], LessEqual[b, 0.135]]], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a / 0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.2 \cdot 10^{+38}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-94} \lor \neg \left(b \leq 1.04 \cdot 10^{-78}\right) \land b \leq 0.135:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{\frac{a}{0.3333333333333333}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -9.2000000000000005e38Initial program 59.5%
sqr-neg59.5%
sqr-neg59.5%
associate-*l*59.5%
Simplified59.5%
Taylor expanded in b around -inf 97.2%
*-commutative97.2%
Simplified97.2%
expm1-log1p-u55.3%
expm1-udef45.4%
times-frac45.4%
Applied egg-rr45.4%
expm1-def55.3%
expm1-log1p97.2%
associate-*r/97.3%
associate-*l/97.3%
associate-/r*97.2%
*-rgt-identity97.2%
associate-*r/97.2%
associate-*l*97.2%
associate-/r*97.1%
metadata-eval97.1%
associate-*r/97.1%
metadata-eval97.1%
Simplified97.1%
clear-num97.1%
div-inv97.2%
associate-/r/97.1%
metadata-eval97.1%
times-frac97.2%
associate-/r*97.4%
Applied egg-rr97.4%
if -9.2000000000000005e38 < b < 2.1000000000000001e-94 or 1.03999999999999997e-78 < b < 0.13500000000000001Initial program 80.1%
neg-sub080.1%
sqr-neg80.1%
associate-+l-80.1%
sub0-neg80.1%
neg-mul-180.1%
Simplified79.9%
associate-*r*79.8%
metadata-eval79.8%
distribute-rgt-neg-in79.8%
*-commutative79.8%
fma-neg79.8%
associate-*r*80.0%
*-commutative80.0%
associate-*l*79.9%
Applied egg-rr79.9%
*-commutative79.9%
Simplified79.9%
if 2.1000000000000001e-94 < b < 1.03999999999999997e-78 or 0.13500000000000001 < b Initial program 16.6%
sqr-neg16.6%
sqr-neg16.6%
associate-*l*16.6%
Simplified16.6%
Taylor expanded in b around inf 83.2%
Final simplification86.0%
(FPCore (a b c)
:precision binary64
(if (<= b -9.2e+38)
(/ (/ (* b -2.0) a) 3.0)
(if (<= b 6e-95)
(/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (/ a 0.3333333333333333))
(if (or (<= b 3.5e-80) (not (<= b 0.7)))
(* -0.5 (/ c b))
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.2e+38) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 6e-95) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
} else if ((b <= 3.5e-80) || !(b <= 0.7)) {
tmp = -0.5 * (c / b);
} else {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
}
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.2d+38)) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
else if (b <= 6d-95) then
tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (a / 0.3333333333333333d0)
else if ((b <= 3.5d-80) .or. (.not. (b <= 0.7d0))) then
tmp = (-0.5d0) * (c / b)
else
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9.2e+38) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 6e-95) {
tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
} else if ((b <= 3.5e-80) || !(b <= 0.7)) {
tmp = -0.5 * (c / b);
} else {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.2e+38: tmp = ((b * -2.0) / a) / 3.0 elif b <= 6e-95: tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333) elif (b <= 3.5e-80) or not (b <= 0.7): tmp = -0.5 * (c / b) else: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.2e+38) tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0); elseif (b <= 6e-95) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(a / 0.3333333333333333)); elseif ((b <= 3.5e-80) || !(b <= 0.7)) tmp = Float64(-0.5 * Float64(c / b)); else tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.2e+38) tmp = ((b * -2.0) / a) / 3.0; elseif (b <= 6e-95) tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333); elseif ((b <= 3.5e-80) || ~((b <= 0.7))) tmp = -0.5 * (c / b); else tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.2e+38], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 6e-95], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a / 0.3333333333333333), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 3.5e-80], N[Not[LessEqual[b, 0.7]], $MachinePrecision]], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.2 \cdot 10^{+38}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-95}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{\frac{a}{0.3333333333333333}}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-80} \lor \neg \left(b \leq 0.7\right):\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\end{array}
\end{array}
if b < -9.2000000000000005e38Initial program 59.5%
sqr-neg59.5%
sqr-neg59.5%
associate-*l*59.5%
Simplified59.5%
Taylor expanded in b around -inf 97.2%
*-commutative97.2%
Simplified97.2%
expm1-log1p-u55.3%
expm1-udef45.4%
times-frac45.4%
Applied egg-rr45.4%
expm1-def55.3%
expm1-log1p97.2%
associate-*r/97.3%
associate-*l/97.3%
associate-/r*97.2%
*-rgt-identity97.2%
associate-*r/97.2%
associate-*l*97.2%
associate-/r*97.1%
metadata-eval97.1%
associate-*r/97.1%
metadata-eval97.1%
Simplified97.1%
clear-num97.1%
div-inv97.2%
associate-/r/97.1%
metadata-eval97.1%
times-frac97.2%
associate-/r*97.4%
Applied egg-rr97.4%
if -9.2000000000000005e38 < b < 6e-95Initial program 84.2%
neg-sub084.2%
sqr-neg84.2%
associate-+l-84.2%
sub0-neg84.2%
neg-mul-184.2%
Simplified84.1%
associate-*r*84.0%
metadata-eval84.0%
distribute-rgt-neg-in84.0%
*-commutative84.0%
fma-neg84.0%
associate-*r*84.2%
*-commutative84.2%
associate-*l*84.1%
Applied egg-rr84.1%
*-commutative84.1%
Simplified84.1%
if 6e-95 < b < 3.50000000000000015e-80 or 0.69999999999999996 < b Initial program 16.6%
sqr-neg16.6%
sqr-neg16.6%
associate-*l*16.6%
Simplified16.6%
Taylor expanded in b around inf 83.2%
if 3.50000000000000015e-80 < b < 0.69999999999999996Initial program 57.7%
sqr-neg57.7%
sqr-neg57.7%
associate-*l*57.5%
Simplified57.5%
Final simplification86.0%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-74)
(/ (/ (* b -2.0) a) 3.0)
(if (<= b 3.9e-95)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-74) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 3.9e-95) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} 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 <= (-6.5d-74)) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
else if (b <= 3.9d-95) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (a * 3.0d0)
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 <= -6.5e-74) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 3.9e-95) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-74: tmp = ((b * -2.0) / a) / 3.0 elif b <= 3.9e-95: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-74) tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0); elseif (b <= 3.9e-95) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-74) tmp = ((b * -2.0) / a) / 3.0; elseif (b <= 3.9e-95) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-74], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 3.9e-95], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-95}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -6.5000000000000002e-74Initial program 67.9%
sqr-neg67.9%
sqr-neg67.9%
associate-*l*67.9%
Simplified67.9%
Taylor expanded in b around -inf 93.1%
*-commutative93.1%
Simplified93.1%
expm1-log1p-u58.3%
expm1-udef42.0%
times-frac42.0%
Applied egg-rr42.0%
expm1-def58.3%
expm1-log1p93.0%
associate-*r/93.2%
associate-*l/93.2%
associate-/r*93.1%
*-rgt-identity93.1%
associate-*r/93.1%
associate-*l*93.1%
associate-/r*93.0%
metadata-eval93.0%
associate-*r/93.0%
metadata-eval93.0%
Simplified93.0%
clear-num93.0%
div-inv93.1%
associate-/r/93.0%
metadata-eval93.0%
times-frac93.1%
associate-/r*93.2%
Applied egg-rr93.2%
if -6.5000000000000002e-74 < b < 3.9e-95Initial program 80.2%
sqr-neg80.2%
sqr-neg80.2%
associate-*l*79.9%
Simplified79.9%
Taylor expanded in b around 0 71.6%
associate-*r*71.8%
*-commutative71.8%
associate-*l*71.7%
Simplified71.7%
if 3.9e-95 < b Initial program 23.5%
sqr-neg23.5%
sqr-neg23.5%
associate-*l*23.5%
Simplified23.5%
Taylor expanded in b around inf 74.3%
Final simplification80.9%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (/ (* b -2.0) 3.0) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = ((b * -2.0) / 3.0) / 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 <= (-2d-310)) then
tmp = ((b * (-2.0d0)) / 3.0d0) / 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 <= -2e-310) {
tmp = ((b * -2.0) / 3.0) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = ((b * -2.0) / 3.0) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(Float64(b * -2.0) / 3.0) / 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 <= -2e-310) tmp = ((b * -2.0) / 3.0) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(N[(b * -2.0), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 72.6%
sqr-neg72.6%
sqr-neg72.6%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around -inf 76.1%
*-commutative76.1%
Simplified76.1%
expm1-log1p-u49.2%
expm1-udef34.2%
times-frac34.2%
Applied egg-rr34.2%
expm1-def49.2%
expm1-log1p76.0%
associate-*r/76.1%
associate-*l/76.1%
associate-/r*76.1%
*-rgt-identity76.1%
associate-*r/76.0%
associate-*l*76.0%
associate-/r*76.0%
metadata-eval76.0%
associate-*r/76.0%
metadata-eval76.0%
Simplified76.0%
clear-num76.0%
div-inv76.0%
associate-/r/76.0%
metadata-eval76.0%
times-frac76.1%
*-commutative76.1%
associate-/r*76.1%
Applied egg-rr76.1%
if -1.999999999999994e-310 < b Initial program 36.3%
sqr-neg36.3%
sqr-neg36.3%
associate-*l*36.2%
Simplified36.2%
Taylor expanded in b around inf 58.1%
Final simplification67.1%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (/ (* b -2.0) a) 3.0) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = ((b * -2.0) / a) / 3.0;
} 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 <= (-2d-310)) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
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 <= -2e-310) {
tmp = ((b * -2.0) / a) / 3.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = ((b * -2.0) / a) / 3.0 else: tmp = -0.5 * (c / b) 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(-0.5 * Float64(c / b)); 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 = -0.5 * (c / b); 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 72.6%
sqr-neg72.6%
sqr-neg72.6%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around -inf 76.1%
*-commutative76.1%
Simplified76.1%
expm1-log1p-u49.2%
expm1-udef34.2%
times-frac34.2%
Applied egg-rr34.2%
expm1-def49.2%
expm1-log1p76.0%
associate-*r/76.1%
associate-*l/76.1%
associate-/r*76.1%
*-rgt-identity76.1%
associate-*r/76.0%
associate-*l*76.0%
associate-/r*76.0%
metadata-eval76.0%
associate-*r/76.0%
metadata-eval76.0%
Simplified76.0%
clear-num76.0%
div-inv76.0%
associate-/r/76.0%
metadata-eval76.0%
times-frac76.1%
associate-/r*76.2%
Applied egg-rr76.2%
if -1.999999999999994e-310 < b Initial program 36.3%
sqr-neg36.3%
sqr-neg36.3%
associate-*l*36.2%
Simplified36.2%
Taylor expanded in b around inf 58.1%
Final simplification67.1%
(FPCore (a b c) :precision binary64 (if (<= b 3e-308) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3e-308) {
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 <= 3d-308) 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 <= 3e-308) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3e-308: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3e-308) 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 <= 3e-308) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3e-308], 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 3 \cdot 10^{-308}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.00000000000000022e-308Initial program 72.6%
sqr-neg72.6%
sqr-neg72.6%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around -inf 76.1%
*-commutative76.1%
Simplified76.1%
expm1-log1p-u49.2%
expm1-udef34.2%
times-frac34.2%
Applied egg-rr34.2%
expm1-def49.2%
expm1-log1p76.0%
associate-*r/76.1%
associate-*l/76.1%
associate-/r*76.1%
*-rgt-identity76.1%
associate-*r/76.0%
associate-*l*76.0%
associate-/r*76.0%
metadata-eval76.0%
associate-*r/76.0%
metadata-eval76.0%
Simplified76.0%
if 3.00000000000000022e-308 < b Initial program 36.3%
sqr-neg36.3%
sqr-neg36.3%
associate-*l*36.2%
Simplified36.2%
Taylor expanded in b around inf 58.1%
Final simplification67.0%
(FPCore (a b c) :precision binary64 (if (<= b 5e-308) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5e-308) {
tmp = (b / a) * -0.6666666666666666;
} 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-308) then
tmp = (b / a) * (-0.6666666666666666d0)
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-308) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5e-308: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5e-308) tmp = Float64(Float64(b / a) * -0.6666666666666666); 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-308) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5e-308], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{-308}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 4.99999999999999955e-308Initial program 72.6%
sqr-neg72.6%
sqr-neg72.6%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around -inf 76.0%
*-commutative76.0%
Simplified76.0%
if 4.99999999999999955e-308 < b Initial program 36.3%
sqr-neg36.3%
sqr-neg36.3%
associate-*l*36.2%
Simplified36.2%
Taylor expanded in b around inf 58.1%
Final simplification67.0%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = b / (a * -1.5);
} 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 <= (-2d-310)) then
tmp = b / (a * (-1.5d0))
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 <= -2e-310) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 72.6%
sqr-neg72.6%
sqr-neg72.6%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around -inf 76.1%
*-commutative76.1%
Simplified76.1%
expm1-log1p-u49.2%
expm1-udef34.2%
times-frac34.2%
Applied egg-rr34.2%
expm1-def49.2%
expm1-log1p76.0%
associate-*r/76.1%
associate-*l/76.1%
associate-/r*76.1%
*-rgt-identity76.1%
associate-*r/76.0%
associate-*l*76.0%
associate-/r*76.0%
metadata-eval76.0%
associate-*r/76.0%
metadata-eval76.0%
Simplified76.0%
clear-num76.0%
div-inv76.0%
div-inv76.1%
metadata-eval76.1%
Applied egg-rr76.1%
if -1.999999999999994e-310 < b Initial program 36.3%
sqr-neg36.3%
sqr-neg36.3%
associate-*l*36.2%
Simplified36.2%
Taylor expanded in b around inf 58.1%
Final simplification67.1%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 54.4%
sqr-neg54.4%
sqr-neg54.4%
associate-*l*54.4%
Simplified54.4%
Taylor expanded in b around inf 30.2%
Final simplification30.2%
herbie shell --seed 2023279
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))