
(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 -5e+110)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 5e-119)
(* (/ -0.3333333333333333 a) (- b (sqrt (- (* b b) (* 3.0 (* a c))))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+110) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 5e-119) {
tmp = (-0.3333333333333333 / a) * (b - sqrt(((b * b) - (3.0 * (a * c)))));
} 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+110)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 5d-119) then
tmp = ((-0.3333333333333333d0) / a) * (b - sqrt(((b * b) - (3.0d0 * (a * c)))))
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+110) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 5e-119) {
tmp = (-0.3333333333333333 / a) * (b - Math.sqrt(((b * b) - (3.0 * (a * c)))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+110: tmp = (b * -2.0) / (3.0 * a) elif b <= 5e-119: tmp = (-0.3333333333333333 / a) * (b - math.sqrt(((b * b) - (3.0 * (a * c))))) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+110) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 5e-119) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))))); 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+110) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 5e-119) tmp = (-0.3333333333333333 / a) * (b - sqrt(((b * b) - (3.0 * (a * c))))); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+110], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e-119], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+110}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{-119}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.99999999999999978e110Initial program 44.8%
neg-sub044.8%
associate-+l-44.8%
sub0-neg44.8%
neg-mul-144.8%
associate-*r/44.8%
metadata-eval44.8%
metadata-eval44.8%
times-frac44.8%
*-commutative44.8%
times-frac44.7%
associate-*l/44.8%
Simplified44.8%
Taylor expanded in b around -inf 96.5%
*-commutative96.5%
Simplified96.5%
if -4.99999999999999978e110 < b < 4.99999999999999993e-119Initial program 91.9%
/-rgt-identity91.9%
metadata-eval91.9%
associate-/r/91.9%
metadata-eval91.9%
metadata-eval91.9%
times-frac91.9%
*-commutative91.9%
times-frac91.8%
*-commutative91.8%
associate-/r*92.0%
associate-*l/92.0%
Simplified91.9%
fma-udef91.9%
*-commutative91.9%
metadata-eval91.9%
cancel-sign-sub-inv91.9%
associate-*r*92.0%
*-commutative92.0%
*-commutative92.0%
Applied egg-rr92.0%
expm1-log1p-u64.9%
expm1-udef32.0%
associate-/l*32.0%
Applied egg-rr32.0%
expm1-def64.9%
expm1-log1p91.9%
associate-/r/92.0%
associate-*r*92.0%
Simplified92.0%
if 4.99999999999999993e-119 < b Initial program 13.9%
/-rgt-identity13.9%
metadata-eval13.9%
associate-/r/13.9%
metadata-eval13.9%
metadata-eval13.9%
times-frac13.9%
*-commutative13.9%
times-frac14.0%
*-commutative14.0%
associate-/r*13.9%
associate-*l/13.9%
Simplified13.9%
Taylor expanded in b around inf 86.6%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification91.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5.3e-24)
(+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a)))
(if (<= b 5.6e-119)
(* (/ -0.3333333333333333 a) (- b (sqrt (* (* a c) -3.0))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.3e-24) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 5.6e-119) {
tmp = (-0.3333333333333333 / a) * (b - sqrt(((a * c) * -3.0)));
} 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 <= (-5.3d-24)) then
tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / a))
else if (b <= 5.6d-119) then
tmp = ((-0.3333333333333333d0) / a) * (b - sqrt(((a * c) * (-3.0d0))))
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 <= -5.3e-24) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 5.6e-119) {
tmp = (-0.3333333333333333 / a) * (b - Math.sqrt(((a * c) * -3.0)));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.3e-24: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) elif b <= 5.6e-119: tmp = (-0.3333333333333333 / a) * (b - math.sqrt(((a * c) * -3.0))) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.3e-24) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / a))); elseif (b <= 5.6e-119) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(Float64(a * c) * -3.0)))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.3e-24) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); elseif (b <= 5.6e-119) tmp = (-0.3333333333333333 / a) * (b - sqrt(((a * c) * -3.0))); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.3e-24], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-119], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.3 \cdot 10^{-24}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-119}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{\left(a \cdot c\right) \cdot -3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.29999999999999969e-24Initial program 65.6%
/-rgt-identity65.6%
metadata-eval65.6%
associate-/r/65.6%
metadata-eval65.6%
metadata-eval65.6%
times-frac65.6%
*-commutative65.6%
times-frac65.5%
*-commutative65.5%
associate-/r*65.7%
associate-*l/65.7%
Simplified65.7%
Taylor expanded in b around -inf 92.8%
if -5.29999999999999969e-24 < b < 5.6e-119Initial program 89.3%
/-rgt-identity89.3%
metadata-eval89.3%
associate-/r/89.3%
metadata-eval89.3%
metadata-eval89.3%
times-frac89.3%
*-commutative89.3%
times-frac89.2%
*-commutative89.2%
associate-/r*89.2%
associate-*l/89.3%
Simplified89.2%
Taylor expanded in b around 0 79.3%
clear-num79.1%
inv-pow79.1%
*-commutative79.1%
Applied egg-rr79.1%
unpow-179.1%
associate-/r*79.1%
associate-*l*79.1%
Simplified79.1%
*-un-lft-identity79.1%
associate-/r/79.2%
div-inv79.3%
metadata-eval79.3%
Applied egg-rr79.3%
*-lft-identity79.3%
*-commutative79.3%
associate-/r*79.3%
metadata-eval79.3%
associate-*r*79.3%
*-commutative79.3%
Simplified79.3%
if 5.6e-119 < b Initial program 13.9%
/-rgt-identity13.9%
metadata-eval13.9%
associate-/r/13.9%
metadata-eval13.9%
metadata-eval13.9%
times-frac13.9%
*-commutative13.9%
times-frac14.0%
*-commutative14.0%
associate-/r*13.9%
associate-*l/13.9%
Simplified13.9%
Taylor expanded in b around inf 86.6%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification86.9%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e-24)
(+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a)))
(if (<= b 5.6e-119)
(/ (* -0.3333333333333333 (- b (sqrt (* a (* c -3.0))))) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e-24) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 5.6e-119) {
tmp = (-0.3333333333333333 * (b - 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 <= (-4.8d-24)) then
tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / a))
else if (b <= 5.6d-119) then
tmp = ((-0.3333333333333333d0) * (b - 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 <= -4.8e-24) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 5.6e-119) {
tmp = (-0.3333333333333333 * (b - Math.sqrt((a * (c * -3.0))))) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.8e-24: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) elif b <= 5.6e-119: tmp = (-0.3333333333333333 * (b - 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 <= -4.8e-24) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / a))); elseif (b <= 5.6e-119) tmp = Float64(Float64(-0.3333333333333333 * Float64(b - 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 <= -4.8e-24) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); elseif (b <= 5.6e-119) tmp = (-0.3333333333333333 * (b - sqrt((a * (c * -3.0))))) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.8e-24], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-119], N[(N[(-0.3333333333333333 * N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{-24}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-119}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(b - \sqrt{a \cdot \left(c \cdot -3\right)}\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.7999999999999996e-24Initial program 65.6%
/-rgt-identity65.6%
metadata-eval65.6%
associate-/r/65.6%
metadata-eval65.6%
metadata-eval65.6%
times-frac65.6%
*-commutative65.6%
times-frac65.5%
*-commutative65.5%
associate-/r*65.7%
associate-*l/65.7%
Simplified65.7%
Taylor expanded in b around -inf 92.8%
if -4.7999999999999996e-24 < b < 5.6e-119Initial program 89.3%
/-rgt-identity89.3%
metadata-eval89.3%
associate-/r/89.3%
metadata-eval89.3%
metadata-eval89.3%
times-frac89.3%
*-commutative89.3%
times-frac89.2%
*-commutative89.2%
associate-/r*89.2%
associate-*l/89.3%
Simplified89.2%
Taylor expanded in b around 0 79.3%
*-commutative79.3%
*-commutative79.3%
associate-*r*79.3%
Simplified79.3%
if 5.6e-119 < b Initial program 13.9%
/-rgt-identity13.9%
metadata-eval13.9%
associate-/r/13.9%
metadata-eval13.9%
metadata-eval13.9%
times-frac13.9%
*-commutative13.9%
times-frac14.0%
*-commutative14.0%
associate-/r*13.9%
associate-*l/13.9%
Simplified13.9%
Taylor expanded in b around inf 86.6%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification86.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5.7e-24)
(+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a)))
(if (<= b 5.6e-119)
(/ (* -0.3333333333333333 (- b (sqrt (* c (* a -3.0))))) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.7e-24) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 5.6e-119) {
tmp = (-0.3333333333333333 * (b - sqrt((c * (a * -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 <= (-5.7d-24)) then
tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / a))
else if (b <= 5.6d-119) then
tmp = ((-0.3333333333333333d0) * (b - sqrt((c * (a * (-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 <= -5.7e-24) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 5.6e-119) {
tmp = (-0.3333333333333333 * (b - Math.sqrt((c * (a * -3.0))))) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.7e-24: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) elif b <= 5.6e-119: tmp = (-0.3333333333333333 * (b - math.sqrt((c * (a * -3.0))))) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.7e-24) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / a))); elseif (b <= 5.6e-119) tmp = Float64(Float64(-0.3333333333333333 * Float64(b - sqrt(Float64(c * Float64(a * -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 <= -5.7e-24) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); elseif (b <= 5.6e-119) tmp = (-0.3333333333333333 * (b - sqrt((c * (a * -3.0))))) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.7e-24], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-119], N[(N[(-0.3333333333333333 * N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.7 \cdot 10^{-24}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-119}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.70000000000000002e-24Initial program 65.6%
/-rgt-identity65.6%
metadata-eval65.6%
associate-/r/65.6%
metadata-eval65.6%
metadata-eval65.6%
times-frac65.6%
*-commutative65.6%
times-frac65.5%
*-commutative65.5%
associate-/r*65.7%
associate-*l/65.7%
Simplified65.7%
Taylor expanded in b around -inf 92.8%
if -5.70000000000000002e-24 < b < 5.6e-119Initial program 89.3%
/-rgt-identity89.3%
metadata-eval89.3%
associate-/r/89.3%
metadata-eval89.3%
metadata-eval89.3%
times-frac89.3%
*-commutative89.3%
times-frac89.2%
*-commutative89.2%
associate-/r*89.2%
associate-*l/89.3%
Simplified89.2%
Taylor expanded in b around 0 79.3%
*-commutative79.3%
associate-*l*79.3%
Simplified79.3%
if 5.6e-119 < b Initial program 13.9%
/-rgt-identity13.9%
metadata-eval13.9%
associate-/r/13.9%
metadata-eval13.9%
metadata-eval13.9%
times-frac13.9%
*-commutative13.9%
times-frac14.0%
*-commutative14.0%
associate-/r*13.9%
associate-*l/13.9%
Simplified13.9%
Taylor expanded in b around inf 86.6%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification86.9%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (/ (* -0.3333333333333333 (+ b (- b (* 1.5 (* a (/ c b)))))) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = (-0.3333333333333333 * (b + (b - (1.5 * (a * (c / b)))))) / 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 <= (-1d-310)) then
tmp = ((-0.3333333333333333d0) * (b + (b - (1.5d0 * (a * (c / b)))))) / 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 <= -1e-310) {
tmp = (-0.3333333333333333 * (b + (b - (1.5 * (a * (c / b)))))) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (-0.3333333333333333 * (b + (b - (1.5 * (a * (c / b)))))) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(Float64(-0.3333333333333333 * Float64(b + Float64(b - Float64(1.5 * Float64(a * Float64(c / b)))))) / 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 <= -1e-310) tmp = (-0.3333333333333333 * (b + (b - (1.5 * (a * (c / b)))))) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(N[(-0.3333333333333333 * N[(b + N[(b - N[(1.5 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(b + \left(b - 1.5 \cdot \left(a \cdot \frac{c}{b}\right)\right)\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 73.2%
/-rgt-identity73.2%
metadata-eval73.2%
associate-/r/73.2%
metadata-eval73.2%
metadata-eval73.2%
times-frac73.2%
*-commutative73.2%
times-frac73.1%
*-commutative73.1%
associate-/r*73.3%
associate-*l/73.3%
Simplified73.2%
fma-udef73.2%
*-commutative73.2%
metadata-eval73.2%
cancel-sign-sub-inv73.2%
associate-*r*73.3%
*-commutative73.3%
*-commutative73.3%
Applied egg-rr73.3%
Taylor expanded in b around -inf 68.3%
mul-1-neg68.3%
unsub-neg68.3%
associate-*l/70.5%
*-commutative70.5%
Simplified70.5%
if -9.999999999999969e-311 < b Initial program 31.9%
/-rgt-identity31.9%
metadata-eval31.9%
associate-/r/31.9%
metadata-eval31.9%
metadata-eval31.9%
times-frac31.9%
*-commutative31.9%
times-frac31.9%
*-commutative31.9%
associate-/r*31.9%
associate-*l/31.9%
Simplified31.9%
Taylor expanded in b around inf 69.2%
associate-*r/69.2%
Applied egg-rr69.2%
Final simplification69.9%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / 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 <= (-1d-310)) then
tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / 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 <= -1e-310) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / 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 <= -1e-310) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 73.2%
/-rgt-identity73.2%
metadata-eval73.2%
associate-/r/73.2%
metadata-eval73.2%
metadata-eval73.2%
times-frac73.2%
*-commutative73.2%
times-frac73.1%
*-commutative73.1%
associate-/r*73.3%
associate-*l/73.3%
Simplified73.2%
Taylor expanded in b around -inf 70.5%
if -9.999999999999969e-311 < b Initial program 31.9%
/-rgt-identity31.9%
metadata-eval31.9%
associate-/r/31.9%
metadata-eval31.9%
metadata-eval31.9%
times-frac31.9%
*-commutative31.9%
times-frac31.9%
*-commutative31.9%
associate-/r*31.9%
associate-*l/31.9%
Simplified31.9%
Taylor expanded in b around inf 69.2%
associate-*r/69.2%
Applied egg-rr69.2%
Final simplification69.9%
(FPCore (a b c) :precision binary64 (if (<= b 6.9e-282) (/ -0.3333333333333333 (/ (* a 0.5) b)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.9e-282) {
tmp = -0.3333333333333333 / ((a * 0.5) / b);
} 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 <= 6.9d-282) then
tmp = (-0.3333333333333333d0) / ((a * 0.5d0) / b)
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 <= 6.9e-282) {
tmp = -0.3333333333333333 / ((a * 0.5) / b);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.9e-282: tmp = -0.3333333333333333 / ((a * 0.5) / b) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.9e-282) tmp = Float64(-0.3333333333333333 / Float64(Float64(a * 0.5) / b)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.9e-282) tmp = -0.3333333333333333 / ((a * 0.5) / b); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.9e-282], N[(-0.3333333333333333 / N[(N[(a * 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.9 \cdot 10^{-282}:\\
\;\;\;\;\frac{-0.3333333333333333}{\frac{a \cdot 0.5}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 6.89999999999999967e-282Initial program 73.6%
/-rgt-identity73.6%
metadata-eval73.6%
associate-/r/73.6%
metadata-eval73.6%
metadata-eval73.6%
times-frac73.6%
*-commutative73.6%
times-frac73.5%
*-commutative73.5%
associate-/r*73.7%
associate-*l/73.7%
Simplified73.6%
fma-udef73.6%
*-commutative73.6%
metadata-eval73.6%
cancel-sign-sub-inv73.6%
associate-*r*73.7%
*-commutative73.7%
*-commutative73.7%
Applied egg-rr73.7%
*-un-lft-identity73.7%
associate-/l*73.6%
Applied egg-rr73.6%
Taylor expanded in b around -inf 68.9%
associate-*r/68.9%
Simplified68.9%
if 6.89999999999999967e-282 < b Initial program 30.8%
/-rgt-identity30.8%
metadata-eval30.8%
associate-/r/30.8%
metadata-eval30.8%
metadata-eval30.8%
times-frac30.8%
*-commutative30.8%
times-frac30.8%
*-commutative30.8%
associate-/r*30.7%
associate-*l/30.7%
Simplified30.7%
Taylor expanded in b around inf 70.3%
associate-*r/70.4%
Applied egg-rr70.4%
Final simplification69.6%
(FPCore (a b c) :precision binary64 (if (<= b 6.9e-282) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.9e-282) {
tmp = -0.6666666666666666 * (b / 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 <= 6.9d-282) then
tmp = (-0.6666666666666666d0) * (b / 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 <= 6.9e-282) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.9e-282: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.9e-282) tmp = Float64(-0.6666666666666666 * Float64(b / 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 <= 6.9e-282) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.9e-282], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.9 \cdot 10^{-282}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.89999999999999967e-282Initial program 73.6%
/-rgt-identity73.6%
metadata-eval73.6%
associate-/r/73.6%
metadata-eval73.6%
metadata-eval73.6%
times-frac73.6%
*-commutative73.6%
times-frac73.5%
*-commutative73.5%
associate-/r*73.7%
associate-*l/73.7%
Simplified73.6%
Taylor expanded in b around -inf 68.8%
*-commutative68.8%
Simplified68.8%
if 6.89999999999999967e-282 < b Initial program 30.8%
/-rgt-identity30.8%
metadata-eval30.8%
associate-/r/30.8%
metadata-eval30.8%
metadata-eval30.8%
times-frac30.8%
*-commutative30.8%
times-frac30.8%
*-commutative30.8%
associate-/r*30.7%
associate-*l/30.7%
Simplified30.7%
Taylor expanded in b around inf 70.3%
Final simplification69.5%
(FPCore (a b c) :precision binary64 (if (<= b 6.9e-282) (* -0.6666666666666666 (/ b a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.9e-282) {
tmp = -0.6666666666666666 * (b / 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 <= 6.9d-282) then
tmp = (-0.6666666666666666d0) * (b / 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 <= 6.9e-282) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.9e-282: tmp = -0.6666666666666666 * (b / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.9e-282) tmp = Float64(-0.6666666666666666 * Float64(b / 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 <= 6.9e-282) tmp = -0.6666666666666666 * (b / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.9e-282], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.9 \cdot 10^{-282}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 6.89999999999999967e-282Initial program 73.6%
/-rgt-identity73.6%
metadata-eval73.6%
associate-/r/73.6%
metadata-eval73.6%
metadata-eval73.6%
times-frac73.6%
*-commutative73.6%
times-frac73.5%
*-commutative73.5%
associate-/r*73.7%
associate-*l/73.7%
Simplified73.6%
Taylor expanded in b around -inf 68.8%
*-commutative68.8%
Simplified68.8%
if 6.89999999999999967e-282 < b Initial program 30.8%
/-rgt-identity30.8%
metadata-eval30.8%
associate-/r/30.8%
metadata-eval30.8%
metadata-eval30.8%
times-frac30.8%
*-commutative30.8%
times-frac30.8%
*-commutative30.8%
associate-/r*30.7%
associate-*l/30.7%
Simplified30.7%
Taylor expanded in b around inf 70.3%
associate-*r/70.4%
Applied egg-rr70.4%
Final simplification69.5%
(FPCore (a b c) :precision binary64 (if (<= b 6.9e-282) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.9e-282) {
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 <= 6.9d-282) 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 <= 6.9e-282) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.9e-282: tmp = (b * -0.6666666666666666) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.9e-282) tmp = Float64(Float64(b * -0.6666666666666666) / 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 <= 6.9e-282) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.9e-282], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.9 \cdot 10^{-282}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 6.89999999999999967e-282Initial program 73.6%
/-rgt-identity73.6%
metadata-eval73.6%
associate-/r/73.6%
metadata-eval73.6%
metadata-eval73.6%
times-frac73.6%
*-commutative73.6%
times-frac73.5%
*-commutative73.5%
associate-/r*73.7%
associate-*l/73.7%
Simplified73.6%
fma-udef73.6%
*-commutative73.6%
metadata-eval73.6%
cancel-sign-sub-inv73.6%
associate-*r*73.7%
*-commutative73.7%
*-commutative73.7%
Applied egg-rr73.7%
Taylor expanded in b around -inf 68.9%
*-commutative68.9%
Simplified68.9%
if 6.89999999999999967e-282 < b Initial program 30.8%
/-rgt-identity30.8%
metadata-eval30.8%
associate-/r/30.8%
metadata-eval30.8%
metadata-eval30.8%
times-frac30.8%
*-commutative30.8%
times-frac30.8%
*-commutative30.8%
associate-/r*30.7%
associate-*l/30.7%
Simplified30.7%
Taylor expanded in b around inf 70.3%
associate-*r/70.4%
Applied egg-rr70.4%
Final simplification69.5%
(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.0%
/-rgt-identity54.0%
metadata-eval54.0%
associate-/r/54.0%
metadata-eval54.0%
metadata-eval54.0%
times-frac54.0%
*-commutative54.0%
times-frac54.0%
*-commutative54.0%
associate-/r*54.0%
associate-*l/54.0%
Simplified54.0%
Taylor expanded in b around inf 33.4%
Final simplification33.4%
herbie shell --seed 2023174
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))