
(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
(let* ((t_0 (sqrt (fma b b (* a (* c -3.0))))))
(if (<= b -9.8e+126)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2e-131)
(/ (- t_0 b) (* 3.0 a))
(if (or (<= b 1.12e-76) (not (<= b 2.05e-11)))
(/ (* c -0.5) b)
(/ 1.0 (* 3.0 (/ a (+ b t_0)))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma(b, b, (a * (c * -3.0))));
double tmp;
if (b <= -9.8e+126) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2e-131) {
tmp = (t_0 - b) / (3.0 * a);
} else if ((b <= 1.12e-76) || !(b <= 2.05e-11)) {
tmp = (c * -0.5) / b;
} else {
tmp = 1.0 / (3.0 * (a / (b + t_0)));
}
return tmp;
}
function code(a, b, c) t_0 = sqrt(fma(b, b, Float64(a * Float64(c * -3.0)))) tmp = 0.0 if (b <= -9.8e+126) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2e-131) tmp = Float64(Float64(t_0 - b) / Float64(3.0 * a)); elseif ((b <= 1.12e-76) || !(b <= 2.05e-11)) tmp = Float64(Float64(c * -0.5) / b); else tmp = Float64(1.0 / Float64(3.0 * Float64(a / Float64(b + t_0)))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(b * b + N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -9.8e+126], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-131], N[(N[(t$95$0 - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 1.12e-76], N[Not[LessEqual[b, 2.05e-11]], $MachinePrecision]], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision], N[(1.0 / N[(3.0 * N[(a / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}\\
\mathbf{if}\;b \leq -9.8 \cdot 10^{+126}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-131}:\\
\;\;\;\;\frac{t_0 - b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.12 \cdot 10^{-76} \lor \neg \left(b \leq 2.05 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{3 \cdot \frac{a}{b + t_0}}\\
\end{array}
\end{array}
if b < -9.80000000000000002e126Initial program 52.5%
Taylor expanded in b around -inf 98.1%
*-commutative98.1%
Simplified98.1%
if -9.80000000000000002e126 < b < 2e-131Initial program 89.7%
+-commutative89.7%
sqr-neg89.7%
unsub-neg89.7%
div-sub89.7%
--rgt-identity89.7%
div-sub89.7%
Simplified89.7%
if 2e-131 < b < 1.12e-76 or 2.05e-11 < b Initial program 12.8%
Taylor expanded in b around inf 90.2%
associate-*r/90.2%
Simplified90.2%
if 1.12e-76 < b < 2.05e-11Initial program 67.3%
prod-diff67.0%
*-commutative67.0%
fma-neg67.0%
prod-diff67.0%
*-commutative67.0%
fma-neg67.0%
associate-+l+67.3%
fma-neg67.3%
*-commutative67.3%
distribute-rgt-neg-in67.3%
*-commutative67.3%
distribute-rgt-neg-in67.3%
metadata-eval67.3%
Applied egg-rr66.8%
clear-num67.3%
inv-pow67.3%
Applied egg-rr67.0%
Simplified67.6%
Final simplification90.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* a (* c -3.0))))
(if (<= b -5e+126)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.4e-132)
(/ (- (sqrt (fma b b t_0)) b) (* 3.0 a))
(if (or (<= b 1.9e-77) (not (<= b 6e-12)))
(/ (* c -0.5) b)
(* 0.3333333333333333 (/ (sqrt t_0) a)))))))
double code(double a, double b, double c) {
double t_0 = a * (c * -3.0);
double tmp;
if (b <= -5e+126) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.4e-132) {
tmp = (sqrt(fma(b, b, t_0)) - b) / (3.0 * a);
} else if ((b <= 1.9e-77) || !(b <= 6e-12)) {
tmp = (c * -0.5) / b;
} else {
tmp = 0.3333333333333333 * (sqrt(t_0) / a);
}
return tmp;
}
function code(a, b, c) t_0 = Float64(a * Float64(c * -3.0)) tmp = 0.0 if (b <= -5e+126) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.4e-132) tmp = Float64(Float64(sqrt(fma(b, b, t_0)) - b) / Float64(3.0 * a)); elseif ((b <= 1.9e-77) || !(b <= 6e-12)) tmp = Float64(Float64(c * -0.5) / b); else tmp = Float64(0.3333333333333333 * Float64(sqrt(t_0) / a)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5e+126], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-132], N[(N[(N[Sqrt[N[(b * b + t$95$0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 1.9e-77], N[Not[LessEqual[b, 6e-12]], $MachinePrecision]], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision], N[(0.3333333333333333 * N[(N[Sqrt[t$95$0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot -3\right)\\
\mathbf{if}\;b \leq -5 \cdot 10^{+126}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-132}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, t_0\right)} - b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-77} \lor \neg \left(b \leq 6 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{t_0}}{a}\\
\end{array}
\end{array}
if b < -4.99999999999999977e126Initial program 52.5%
Taylor expanded in b around -inf 98.1%
*-commutative98.1%
Simplified98.1%
if -4.99999999999999977e126 < b < 2.40000000000000015e-132Initial program 89.7%
+-commutative89.7%
sqr-neg89.7%
unsub-neg89.7%
div-sub89.7%
--rgt-identity89.7%
div-sub89.7%
Simplified89.7%
if 2.40000000000000015e-132 < b < 1.8999999999999999e-77 or 6.0000000000000003e-12 < b Initial program 12.8%
Taylor expanded in b around inf 90.2%
associate-*r/90.2%
Simplified90.2%
if 1.8999999999999999e-77 < b < 6.0000000000000003e-12Initial program 67.3%
prod-diff67.0%
*-commutative67.0%
fma-neg67.0%
prod-diff67.0%
*-commutative67.0%
fma-neg67.0%
associate-+l+67.3%
fma-neg67.3%
*-commutative67.3%
distribute-rgt-neg-in67.3%
*-commutative67.3%
distribute-rgt-neg-in67.3%
metadata-eval67.3%
Applied egg-rr66.8%
Taylor expanded in b around 0 67.3%
associate-*l/67.1%
*-lft-identity67.1%
*-commutative67.1%
distribute-rgt-out67.1%
metadata-eval67.1%
distribute-lft-out67.3%
metadata-eval67.3%
associate-*r*67.6%
Simplified67.6%
Final simplification90.7%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-24)
(/ (* b -2.0) (* 3.0 a))
(if (or (<= b 2e-131) (and (not (<= b 1.6e-77)) (<= b 4e-12)))
(* 0.3333333333333333 (/ (sqrt (* a (* c -3.0))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-24) {
tmp = (b * -2.0) / (3.0 * a);
} else if ((b <= 2e-131) || (!(b <= 1.6e-77) && (b <= 4e-12))) {
tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-3.8d-24)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if ((b <= 2d-131) .or. (.not. (b <= 1.6d-77)) .and. (b <= 4d-12)) then
tmp = 0.3333333333333333d0 * (sqrt((a * (c * (-3.0d0)))) / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-24) {
tmp = (b * -2.0) / (3.0 * a);
} else if ((b <= 2e-131) || (!(b <= 1.6e-77) && (b <= 4e-12))) {
tmp = 0.3333333333333333 * (Math.sqrt((a * (c * -3.0))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e-24: tmp = (b * -2.0) / (3.0 * a) elif (b <= 2e-131) or (not (b <= 1.6e-77) and (b <= 4e-12)): tmp = 0.3333333333333333 * (math.sqrt((a * (c * -3.0))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e-24) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif ((b <= 2e-131) || (!(b <= 1.6e-77) && (b <= 4e-12))) tmp = Float64(0.3333333333333333 * Float64(sqrt(Float64(a * Float64(c * -3.0))) / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.8e-24) tmp = (b * -2.0) / (3.0 * a); elseif ((b <= 2e-131) || (~((b <= 1.6e-77)) && (b <= 4e-12))) tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-24], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 2e-131], And[N[Not[LessEqual[b, 1.6e-77]], $MachinePrecision], LessEqual[b, 4e-12]]], N[(0.3333333333333333 * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-24}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-131} \lor \neg \left(b \leq 1.6 \cdot 10^{-77}\right) \land b \leq 4 \cdot 10^{-12}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.80000000000000026e-24Initial program 69.0%
Taylor expanded in b around -inf 94.4%
*-commutative94.4%
Simplified94.4%
if -3.80000000000000026e-24 < b < 2e-131 or 1.6e-77 < b < 3.99999999999999992e-12Initial program 82.5%
prod-diff82.3%
*-commutative82.3%
fma-neg82.3%
prod-diff82.3%
*-commutative82.3%
fma-neg82.3%
associate-+l+82.3%
fma-neg82.3%
*-commutative82.3%
distribute-rgt-neg-in82.3%
*-commutative82.3%
distribute-rgt-neg-in82.3%
metadata-eval82.3%
Applied egg-rr82.1%
Taylor expanded in b around 0 67.7%
associate-*l/67.7%
*-lft-identity67.7%
*-commutative67.7%
distribute-rgt-out67.7%
metadata-eval67.7%
distribute-lft-out67.9%
metadata-eval67.9%
associate-*r*68.0%
Simplified68.0%
if 2e-131 < b < 1.6e-77 or 3.99999999999999992e-12 < b Initial program 12.8%
Taylor expanded in b around inf 90.2%
associate-*r/90.2%
Simplified90.2%
Final simplification84.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* a (* c -3.0)))))
(if (<= b -2.5e-23)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2e-131)
(/ (- t_0 b) (* 3.0 a))
(if (or (<= b 6.5e-77) (not (<= b 4e-12)))
(/ (* c -0.5) b)
(* 0.3333333333333333 (/ t_0 a)))))))
double code(double a, double b, double c) {
double t_0 = sqrt((a * (c * -3.0)));
double tmp;
if (b <= -2.5e-23) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2e-131) {
tmp = (t_0 - b) / (3.0 * a);
} else if ((b <= 6.5e-77) || !(b <= 4e-12)) {
tmp = (c * -0.5) / b;
} else {
tmp = 0.3333333333333333 * (t_0 / a);
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt((a * (c * (-3.0d0))))
if (b <= (-2.5d-23)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2d-131) then
tmp = (t_0 - b) / (3.0d0 * a)
else if ((b <= 6.5d-77) .or. (.not. (b <= 4d-12))) then
tmp = (c * (-0.5d0)) / b
else
tmp = 0.3333333333333333d0 * (t_0 / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt((a * (c * -3.0)));
double tmp;
if (b <= -2.5e-23) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2e-131) {
tmp = (t_0 - b) / (3.0 * a);
} else if ((b <= 6.5e-77) || !(b <= 4e-12)) {
tmp = (c * -0.5) / b;
} else {
tmp = 0.3333333333333333 * (t_0 / a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt((a * (c * -3.0))) tmp = 0 if b <= -2.5e-23: tmp = (b * -2.0) / (3.0 * a) elif b <= 2e-131: tmp = (t_0 - b) / (3.0 * a) elif (b <= 6.5e-77) or not (b <= 4e-12): tmp = (c * -0.5) / b else: tmp = 0.3333333333333333 * (t_0 / a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(a * Float64(c * -3.0))) tmp = 0.0 if (b <= -2.5e-23) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2e-131) tmp = Float64(Float64(t_0 - b) / Float64(3.0 * a)); elseif ((b <= 6.5e-77) || !(b <= 4e-12)) tmp = Float64(Float64(c * -0.5) / b); else tmp = Float64(0.3333333333333333 * Float64(t_0 / a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt((a * (c * -3.0))); tmp = 0.0; if (b <= -2.5e-23) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2e-131) tmp = (t_0 - b) / (3.0 * a); elseif ((b <= 6.5e-77) || ~((b <= 4e-12))) tmp = (c * -0.5) / b; else tmp = 0.3333333333333333 * (t_0 / a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2.5e-23], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-131], N[(N[(t$95$0 - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 6.5e-77], N[Not[LessEqual[b, 4e-12]], $MachinePrecision]], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision], N[(0.3333333333333333 * N[(t$95$0 / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{a \cdot \left(c \cdot -3\right)}\\
\mathbf{if}\;b \leq -2.5 \cdot 10^{-23}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-131}:\\
\;\;\;\;\frac{t_0 - b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-77} \lor \neg \left(b \leq 4 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{t_0}{a}\\
\end{array}
\end{array}
if b < -2.5000000000000001e-23Initial program 69.0%
Taylor expanded in b around -inf 94.4%
*-commutative94.4%
Simplified94.4%
if -2.5000000000000001e-23 < b < 2e-131Initial program 85.2%
prod-diff85.0%
*-commutative85.0%
fma-neg85.0%
prod-diff85.0%
*-commutative85.0%
fma-neg85.0%
associate-+l+85.0%
fma-neg85.0%
*-commutative85.0%
distribute-rgt-neg-in85.0%
*-commutative85.0%
distribute-rgt-neg-in85.0%
metadata-eval85.0%
Applied egg-rr84.9%
Taylor expanded in b around 0 70.4%
mul-1-neg70.4%
unsub-neg70.4%
*-commutative70.4%
distribute-rgt-out70.4%
metadata-eval70.4%
distribute-lft-out70.7%
metadata-eval70.7%
associate-*r*70.7%
Simplified70.7%
if 2e-131 < b < 6.4999999999999999e-77 or 3.99999999999999992e-12 < b Initial program 12.8%
Taylor expanded in b around inf 90.2%
associate-*r/90.2%
Simplified90.2%
if 6.4999999999999999e-77 < b < 3.99999999999999992e-12Initial program 67.3%
prod-diff67.0%
*-commutative67.0%
fma-neg67.0%
prod-diff67.0%
*-commutative67.0%
fma-neg67.0%
associate-+l+67.3%
fma-neg67.3%
*-commutative67.3%
distribute-rgt-neg-in67.3%
*-commutative67.3%
distribute-rgt-neg-in67.3%
metadata-eval67.3%
Applied egg-rr66.8%
Taylor expanded in b around 0 67.3%
associate-*l/67.1%
*-lft-identity67.1%
*-commutative67.1%
distribute-rgt-out67.1%
metadata-eval67.1%
distribute-lft-out67.3%
metadata-eval67.3%
associate-*r*67.6%
Simplified67.6%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(if (<= b -6e+126)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2e-131)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(if (or (<= b 2.65e-77) (not (<= b 5.1e-12)))
(/ (* c -0.5) b)
(* 0.3333333333333333 (/ (sqrt (* a (* c -3.0))) a))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e+126) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2e-131) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else if ((b <= 2.65e-77) || !(b <= 5.1e-12)) {
tmp = (c * -0.5) / b;
} else {
tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6d+126)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2d-131) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
else if ((b <= 2.65d-77) .or. (.not. (b <= 5.1d-12))) then
tmp = (c * (-0.5d0)) / b
else
tmp = 0.3333333333333333d0 * (sqrt((a * (c * (-3.0d0)))) / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6e+126) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2e-131) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else if ((b <= 2.65e-77) || !(b <= 5.1e-12)) {
tmp = (c * -0.5) / b;
} else {
tmp = 0.3333333333333333 * (Math.sqrt((a * (c * -3.0))) / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e+126: tmp = (b * -2.0) / (3.0 * a) elif b <= 2e-131: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) elif (b <= 2.65e-77) or not (b <= 5.1e-12): tmp = (c * -0.5) / b else: tmp = 0.3333333333333333 * (math.sqrt((a * (c * -3.0))) / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e+126) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2e-131) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); elseif ((b <= 2.65e-77) || !(b <= 5.1e-12)) tmp = Float64(Float64(c * -0.5) / b); else tmp = Float64(0.3333333333333333 * Float64(sqrt(Float64(a * Float64(c * -3.0))) / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e+126) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2e-131) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); elseif ((b <= 2.65e-77) || ~((b <= 5.1e-12))) tmp = (c * -0.5) / b; else tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e+126], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-131], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 2.65e-77], N[Not[LessEqual[b, 5.1e-12]], $MachinePrecision]], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision], N[(0.3333333333333333 * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+126}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-131}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.65 \cdot 10^{-77} \lor \neg \left(b \leq 5.1 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\end{array}
\end{array}
if b < -6.0000000000000005e126Initial program 52.5%
Taylor expanded in b around -inf 98.1%
*-commutative98.1%
Simplified98.1%
if -6.0000000000000005e126 < b < 2e-131Initial program 89.7%
if 2e-131 < b < 2.65000000000000007e-77 or 5.09999999999999968e-12 < b Initial program 12.8%
Taylor expanded in b around inf 90.2%
associate-*r/90.2%
Simplified90.2%
if 2.65000000000000007e-77 < b < 5.09999999999999968e-12Initial program 67.3%
prod-diff67.0%
*-commutative67.0%
fma-neg67.0%
prod-diff67.0%
*-commutative67.0%
fma-neg67.0%
associate-+l+67.3%
fma-neg67.3%
*-commutative67.3%
distribute-rgt-neg-in67.3%
*-commutative67.3%
distribute-rgt-neg-in67.3%
metadata-eval67.3%
Applied egg-rr66.8%
Taylor expanded in b around 0 67.3%
associate-*l/67.1%
*-lft-identity67.1%
*-commutative67.1%
distribute-rgt-out67.1%
metadata-eval67.1%
distribute-lft-out67.3%
metadata-eval67.3%
associate-*r*67.6%
Simplified67.6%
Final simplification90.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* (* b -2.0) (/ 0.3333333333333333 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -2.0) * (0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (b * (-2.0d0)) * (0.3333333333333333d0 / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -2.0) * (0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * -2.0) * (0.3333333333333333 / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b * -2.0) * Float64(0.3333333333333333 / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b * -2.0) * (0.3333333333333333 / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b * -2.0), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(b \cdot -2\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 75.9%
Applied egg-rr72.3%
sub-neg72.3%
distribute-rgt-out--72.4%
Simplified72.4%
Taylor expanded in b around -inf 69.9%
*-commutative69.9%
Simplified69.9%
if -4.999999999999985e-310 < b Initial program 27.9%
Taylor expanded in b around inf 72.2%
associate-*r/72.2%
Simplified72.2%
Final simplification71.0%
(FPCore (a b c) :precision binary64 (if (<= b 2e-309) (/ (* b -2.0) (* 3.0 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2e-309) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2d-309) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2e-309) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2e-309: tmp = (b * -2.0) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2e-309) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2e-309) tmp = (b * -2.0) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2e-309], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{-309}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.9999999999999988e-309Initial program 75.9%
Taylor expanded in b around -inf 70.0%
*-commutative70.0%
Simplified70.0%
if 1.9999999999999988e-309 < b Initial program 27.9%
Taylor expanded in b around inf 72.2%
associate-*r/72.2%
Simplified72.2%
Final simplification71.0%
(FPCore (a b c) :precision binary64 (if (<= b 9e-9) (* (/ b a) -0.6666666666666666) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 9e-9) {
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 <= 9d-9) 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 <= 9e-9) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 9e-9: tmp = (b / a) * -0.6666666666666666 else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 9e-9) 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 <= 9e-9) tmp = (b / a) * -0.6666666666666666; else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 9e-9], 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 9 \cdot 10^{-9}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 8.99999999999999953e-9Initial program 71.8%
Taylor expanded in b around -inf 54.0%
*-commutative54.0%
Simplified54.0%
if 8.99999999999999953e-9 < b Initial program 11.4%
Taylor expanded in b around -inf 2.1%
+-commutative2.1%
mul-1-neg2.1%
unsub-neg2.1%
associate-/l*2.4%
associate-*r/2.4%
Simplified2.4%
Taylor expanded in b around 0 28.2%
Final simplification46.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* (/ b a) -0.6666666666666666) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 75.9%
Taylor expanded in b around -inf 69.8%
*-commutative69.8%
Simplified69.8%
if -4.999999999999985e-310 < b Initial program 27.9%
Taylor expanded in b around inf 72.2%
associate-*r/72.2%
associate-/l*71.5%
Simplified71.5%
Final simplification70.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* (/ b a) -0.6666666666666666) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b / a) * -0.6666666666666666; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 75.9%
Taylor expanded in b around -inf 69.8%
*-commutative69.8%
Simplified69.8%
if -4.999999999999985e-310 < b Initial program 27.9%
Taylor expanded in b around inf 72.2%
associate-*r/72.2%
Simplified72.2%
Final simplification70.9%
(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 53.2%
Taylor expanded in b around -inf 36.7%
+-commutative36.7%
mul-1-neg36.7%
unsub-neg36.7%
associate-/l*37.9%
associate-*r/37.9%
Simplified37.9%
Taylor expanded in b around 0 10.9%
Final simplification10.9%
herbie shell --seed 2024022
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))