
(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 12 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 -1e+145)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 3.25e-105)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+145) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3.25e-105) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (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 <= (-1d+145)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 3.25d-105) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (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 <= -1e+145) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3.25e-105) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e+145: tmp = (b * -2.0) / (3.0 * a) elif b <= 3.25e-105: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e+145) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 3.25e-105) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / 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 <= -1e+145) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 3.25e-105) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e+145], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.25e-105], 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], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+145}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 3.25 \cdot 10^{-105}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.9999999999999999e144Initial program 44.0%
Taylor expanded in b around -inf 99.9%
*-commutative99.9%
Simplified99.9%
if -9.9999999999999999e144 < b < 3.25000000000000003e-105Initial program 81.9%
if 3.25000000000000003e-105 < b Initial program 16.3%
Taylor expanded in b around inf 89.3%
associate-*r/89.3%
Applied egg-rr89.3%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-76)
(fma -0.6666666666666666 (/ b a) (* 0.5 (/ c b)))
(if (<= b 2.8e-108)
(/ (+ b (sqrt (* c (* a -3.0)))) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-76) {
tmp = fma(-0.6666666666666666, (b / a), (0.5 * (c / b)));
} else if (b <= 2.8e-108) {
tmp = (b + sqrt((c * (a * -3.0)))) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-76) tmp = fma(-0.6666666666666666, Float64(b / a), Float64(0.5 * Float64(c / b))); elseif (b <= 2.8e-108) tmp = Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-76], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.8e-108], N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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 -6.5 \cdot 10^{-76}:\\
\;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-108}:\\
\;\;\;\;\frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.5e-76Initial program 73.0%
Taylor expanded in b around -inf 81.8%
fma-def81.8%
Simplified81.8%
if -6.5e-76 < b < 2.8e-108Initial program 73.2%
Taylor expanded in b around 0 70.4%
expm1-log1p-u68.3%
expm1-udef29.3%
add-sqr-sqrt16.9%
sqrt-unprod29.3%
sqr-neg29.3%
sqrt-unprod12.4%
add-sqr-sqrt29.3%
associate-*r*29.3%
*-commutative29.3%
*-commutative29.3%
Applied egg-rr29.3%
expm1-def67.7%
expm1-log1p69.8%
Simplified69.8%
if 2.8e-108 < b Initial program 16.3%
Taylor expanded in b around inf 89.3%
associate-*r/89.3%
Applied egg-rr89.3%
Final simplification82.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.05e-76)
(fma -0.6666666666666666 (/ b a) (* 0.5 (/ c b)))
(if (<= b 1.05e-106)
(/ (- (sqrt (* a (* c -3.0))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e-76) {
tmp = fma(-0.6666666666666666, (b / a), (0.5 * (c / b)));
} else if (b <= 1.05e-106) {
tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.05e-76) tmp = fma(-0.6666666666666666, Float64(b / a), Float64(0.5 * Float64(c / b))); elseif (b <= 1.05e-106) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.05e-76], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-106], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $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.05 \cdot 10^{-76}:\\
\;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-106}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.0499999999999999e-76Initial program 73.0%
Taylor expanded in b around -inf 81.8%
fma-def81.8%
Simplified81.8%
if -2.0499999999999999e-76 < b < 1.05000000000000002e-106Initial program 73.2%
prod-diff72.9%
*-commutative72.9%
fma-def72.9%
associate-+l+72.9%
pow272.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
*-commutative72.9%
fma-udef72.9%
distribute-lft-neg-in72.9%
distribute-rgt-neg-in72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
*-commutative72.9%
associate-*l*72.9%
Applied egg-rr72.9%
+-commutative72.9%
associate-+r+72.9%
count-272.9%
associate-+l+72.9%
count-272.9%
*-commutative72.9%
*-commutative72.9%
associate-*r*72.8%
*-commutative72.8%
*-commutative72.8%
associate-*r*72.7%
distribute-rgt-out72.7%
metadata-eval72.7%
+-commutative72.7%
unpow272.7%
fma-udef72.7%
*-commutative72.7%
*-commutative72.7%
associate-*l*72.7%
*-commutative72.7%
Simplified72.7%
Taylor expanded in b around 0 70.1%
distribute-rgt-out70.4%
*-commutative70.4%
metadata-eval70.4%
associate-*r*70.5%
mul-1-neg70.5%
unsub-neg70.5%
associate-*r*70.4%
*-commutative70.4%
rem-square-sqrt0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt70.4%
Simplified70.4%
if 1.05000000000000002e-106 < b Initial program 16.3%
Taylor expanded in b around inf 89.3%
associate-*r/89.3%
Applied egg-rr89.3%
Final simplification82.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-74)
(fma -0.6666666666666666 (/ b a) (* 0.5 (/ c b)))
(if (<= b 1.45e-104)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-74) {
tmp = fma(-0.6666666666666666, (b / a), (0.5 * (c / b)));
} else if (b <= 1.45e-104) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-74) tmp = fma(-0.6666666666666666, Float64(b / a), Float64(0.5 * Float64(c / b))); elseif (b <= 1.45e-104) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-74], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-104], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $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 -4.6 \cdot 10^{-74}:\\
\;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-104}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.59999999999999961e-74Initial program 73.0%
Taylor expanded in b around -inf 81.8%
fma-def81.8%
Simplified81.8%
if -4.59999999999999961e-74 < b < 1.4500000000000001e-104Initial program 73.2%
Taylor expanded in b around 0 70.4%
associate-*r*70.5%
*-commutative70.5%
*-commutative70.5%
Simplified70.5%
if 1.4500000000000001e-104 < b Initial program 16.3%
Taylor expanded in b around inf 89.3%
associate-*r/89.3%
Applied egg-rr89.3%
Final simplification82.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e-75)
(+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a)))
(if (<= b 1e-104)
(* 0.3333333333333333 (/ (sqrt (* a (* c -3.0))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-75) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 1e-104) {
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 <= (-1.5d-75)) then
tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / a))
else if (b <= 1d-104) 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 <= -1.5e-75) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 1e-104) {
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 <= -1.5e-75: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) elif b <= 1e-104: 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 <= -1.5e-75) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / a))); elseif (b <= 1e-104) 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 <= -1.5e-75) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); elseif (b <= 1e-104) 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, -1.5e-75], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-104], 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 -1.5 \cdot 10^{-75}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 10^{-104}:\\
\;\;\;\;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 < -1.4999999999999999e-75Initial program 73.0%
Taylor expanded in b around -inf 81.8%
if -1.4999999999999999e-75 < b < 9.99999999999999927e-105Initial program 73.2%
prod-diff72.9%
*-commutative72.9%
fma-def72.9%
associate-+l+72.9%
pow272.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
*-commutative72.9%
fma-udef72.9%
distribute-lft-neg-in72.9%
distribute-rgt-neg-in72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
*-commutative72.9%
associate-*l*72.9%
Applied egg-rr72.9%
+-commutative72.9%
associate-+r+72.9%
count-272.9%
associate-+l+72.9%
count-272.9%
*-commutative72.9%
*-commutative72.9%
associate-*r*72.8%
*-commutative72.8%
*-commutative72.8%
associate-*r*72.7%
distribute-rgt-out72.7%
metadata-eval72.7%
+-commutative72.7%
unpow272.7%
fma-udef72.7%
*-commutative72.7%
*-commutative72.7%
associate-*l*72.7%
*-commutative72.7%
Simplified72.7%
Taylor expanded in b around 0 69.0%
associate-*l/69.1%
distribute-rgt-out69.4%
*-commutative69.4%
metadata-eval69.4%
associate-*r*69.5%
*-lft-identity69.5%
associate-*r*69.4%
*-commutative69.4%
rem-square-sqrt0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt69.5%
Simplified69.5%
if 9.99999999999999927e-105 < b Initial program 16.3%
Taylor expanded in b around inf 89.3%
associate-*r/89.3%
Applied egg-rr89.3%
Final simplification82.0%
(FPCore (a b c)
:precision binary64
(if (<= b -3.7e-75)
(fma -0.6666666666666666 (/ b a) (* 0.5 (/ c b)))
(if (<= b 2e-106)
(* 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.7e-75) {
tmp = fma(-0.6666666666666666, (b / a), (0.5 * (c / b)));
} else if (b <= 2e-106) {
tmp = 0.3333333333333333 * (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.7e-75) tmp = fma(-0.6666666666666666, Float64(b / a), Float64(0.5 * Float64(c / b))); elseif (b <= 2e-106) 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
code[a_, b_, c_] := If[LessEqual[b, -3.7e-75], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-106], 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.7 \cdot 10^{-75}:\\
\;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-106}:\\
\;\;\;\;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.70000000000000024e-75Initial program 73.0%
Taylor expanded in b around -inf 81.8%
fma-def81.8%
Simplified81.8%
if -3.70000000000000024e-75 < b < 1.99999999999999988e-106Initial program 73.2%
prod-diff72.9%
*-commutative72.9%
fma-def72.9%
associate-+l+72.9%
pow272.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
*-commutative72.9%
fma-udef72.9%
distribute-lft-neg-in72.9%
distribute-rgt-neg-in72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
*-commutative72.9%
associate-*l*72.9%
Applied egg-rr72.9%
+-commutative72.9%
associate-+r+72.9%
count-272.9%
associate-+l+72.9%
count-272.9%
*-commutative72.9%
*-commutative72.9%
associate-*r*72.8%
*-commutative72.8%
*-commutative72.8%
associate-*r*72.7%
distribute-rgt-out72.7%
metadata-eval72.7%
+-commutative72.7%
unpow272.7%
fma-udef72.7%
*-commutative72.7%
*-commutative72.7%
associate-*l*72.7%
*-commutative72.7%
Simplified72.7%
Taylor expanded in b around 0 69.0%
associate-*l/69.1%
distribute-rgt-out69.4%
*-commutative69.4%
metadata-eval69.4%
associate-*r*69.5%
*-lft-identity69.5%
associate-*r*69.4%
*-commutative69.4%
rem-square-sqrt0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt69.5%
Simplified69.5%
if 1.99999999999999988e-106 < b Initial program 16.3%
Taylor expanded in b around inf 89.3%
associate-*r/89.3%
Applied egg-rr89.3%
Final simplification82.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-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 <= -5e-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 <= (-5d-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 <= -5e-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 <= -5e-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 <= -5e-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 <= -5e-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, -5e-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 -5 \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 < -4.999999999999985e-310Initial program 74.2%
Taylor expanded in b around -inf 65.9%
if -4.999999999999985e-310 < b Initial program 27.6%
Taylor expanded in b around inf 72.6%
associate-*r/72.6%
Applied egg-rr72.6%
Final simplification69.3%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e-283) (/ (* b -2.0) (* 3.0 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e-283) {
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 <= 3.1d-283) 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 <= 3.1e-283) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e-283: 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 <= 3.1e-283) 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 <= 3.1e-283) 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, 3.1e-283], 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 3.1 \cdot 10^{-283}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 3.10000000000000004e-283Initial program 73.5%
Taylor expanded in b around -inf 63.9%
*-commutative63.9%
Simplified63.9%
if 3.10000000000000004e-283 < b Initial program 26.8%
Taylor expanded in b around inf 74.8%
associate-*r/74.8%
Applied egg-rr74.8%
Final simplification69.3%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e-283) (* (/ b a) -0.3333333333333333) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e-283) {
tmp = (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 <= 3.1d-283) then
tmp = (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 <= 3.1e-283) {
tmp = (b / a) * -0.3333333333333333;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e-283: tmp = (b / a) * -0.3333333333333333 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e-283) tmp = Float64(Float64(b / 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 <= 3.1e-283) tmp = (b / a) * -0.3333333333333333; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e-283], N[(N[(b / a), $MachinePrecision] * -0.3333333333333333), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{-283}:\\
\;\;\;\;\frac{b}{a} \cdot -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.10000000000000004e-283Initial program 73.5%
Taylor expanded in b around 0 40.8%
Taylor expanded in b around inf 26.7%
if 3.10000000000000004e-283 < b Initial program 26.8%
Taylor expanded in b around inf 74.8%
Final simplification50.2%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e-283) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e-283) {
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 <= 3.1d-283) 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 <= 3.1e-283) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e-283: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e-283) 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 <= 3.1e-283) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e-283], 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 3.1 \cdot 10^{-283}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.10000000000000004e-283Initial program 73.5%
Taylor expanded in b around -inf 63.9%
*-commutative63.9%
Simplified63.9%
if 3.10000000000000004e-283 < b Initial program 26.8%
Taylor expanded in b around inf 74.8%
Final simplification69.2%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e-283) (* -0.6666666666666666 (/ b a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e-283) {
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 <= 3.1d-283) 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 <= 3.1e-283) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e-283: tmp = -0.6666666666666666 * (b / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e-283) 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 <= 3.1e-283) tmp = -0.6666666666666666 * (b / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e-283], 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 3.1 \cdot 10^{-283}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 3.10000000000000004e-283Initial program 73.5%
Taylor expanded in b around -inf 63.9%
*-commutative63.9%
Simplified63.9%
if 3.10000000000000004e-283 < b Initial program 26.8%
Taylor expanded in b around inf 74.8%
associate-*r/74.8%
Applied egg-rr74.8%
Final simplification69.2%
(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 50.7%
Taylor expanded in b around inf 37.7%
Final simplification37.7%
herbie shell --seed 2023318
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))