
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -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%
*-commutative89.3%
associate-*l/89.3%
Simplified89.3%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.05e-76)
(/ (- (- (* 1.5 (/ a (/ b c))) b) b) (* 3.0 a))
(if (<= b 1.05e-106)
(* (/ 0.3333333333333333 a) (- (sqrt (* a (* c -3.0))) b))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e-76) {
tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a);
} else if (b <= 1.05e-106) {
tmp = (0.3333333333333333 / a) * (sqrt((a * (c * -3.0))) - 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 <= (-2.05d-76)) then
tmp = (((1.5d0 * (a / (b / c))) - b) - b) / (3.0d0 * a)
else if (b <= 1.05d-106) then
tmp = (0.3333333333333333d0 / a) * (sqrt((a * (c * (-3.0d0)))) - 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 <= -2.05e-76) {
tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a);
} else if (b <= 1.05e-106) {
tmp = (0.3333333333333333 / a) * (Math.sqrt((a * (c * -3.0))) - b);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.05e-76: tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a) elif b <= 1.05e-106: tmp = (0.3333333333333333 / a) * (math.sqrt((a * (c * -3.0))) - b) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.05e-76) tmp = Float64(Float64(Float64(Float64(1.5 * Float64(a / Float64(b / c))) - b) - b) / Float64(3.0 * a)); elseif (b <= 1.05e-106) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(a * Float64(c * -3.0))) - 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 <= -2.05e-76) tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a); elseif (b <= 1.05e-106) tmp = (0.3333333333333333 / a) * (sqrt((a * (c * -3.0))) - b); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.05e-76], N[(N[(N[(N[(1.5 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-106], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $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}:\\
\;\;\;\;\frac{\left(1.5 \cdot \frac{a}{\frac{b}{c}} - b\right) - b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-106}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{a \cdot \left(c \cdot -3\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.0499999999999999e-76Initial program 73.0%
flip--38.7%
div-inv38.7%
pow238.7%
pow238.7%
pow-prod-up38.7%
metadata-eval38.7%
pow238.7%
associate-*l*38.7%
fma-def38.7%
associate-*l*38.7%
Applied egg-rr38.7%
associate-*r*38.7%
*-commutative38.7%
associate-*r*38.7%
*-commutative38.7%
Simplified38.7%
Taylor expanded in b around 0 73.0%
fma-def73.0%
Simplified73.0%
Taylor expanded in b around -inf 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
associate-/l*81.9%
Simplified81.9%
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%
associate-*l*73.0%
Applied egg-rr73.0%
Taylor expanded in b around 0 70.1%
neg-mul-170.1%
unsub-neg70.1%
distribute-rgt-out70.4%
metadata-eval70.4%
*-commutative70.4%
metadata-eval70.4%
distribute-lft-neg-in70.4%
associate-*r*70.5%
*-commutative70.5%
associate-*r*70.4%
distribute-rgt-neg-in70.4%
distribute-lft-neg-in70.4%
metadata-eval70.4%
*-commutative70.4%
Simplified70.4%
add-sqr-sqrt70.2%
pow270.2%
pow1/270.2%
sqrt-pow170.3%
*-commutative70.3%
metadata-eval70.3%
Applied egg-rr70.3%
Taylor expanded in a around 0 42.7%
associate-*r/42.7%
remove-double-neg42.7%
neg-mul-142.7%
times-frac42.7%
Simplified70.4%
if 1.05000000000000002e-106 < b Initial program 16.3%
Taylor expanded in b around inf 89.3%
*-commutative89.3%
associate-*l/89.3%
Simplified89.3%
Final simplification82.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4e-74)
(/ (- (- (* 1.5 (/ a (/ b c))) b) b) (* 3.0 a))
(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 <= -4e-74) {
tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a);
} else if (b <= 1.45e-104) {
tmp = (sqrt((c * (a * -3.0))) - 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 <= (-4d-74)) then
tmp = (((1.5d0 * (a / (b / c))) - b) - b) / (3.0d0 * a)
else if (b <= 1.45d-104) then
tmp = (sqrt((c * (a * (-3.0d0)))) - 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 <= -4e-74) {
tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a);
} else if (b <= 1.45e-104) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-74: tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a) elif b <= 1.45e-104: tmp = (math.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 <= -4e-74) tmp = Float64(Float64(Float64(Float64(1.5 * Float64(a / Float64(b / c))) - b) - b) / Float64(3.0 * a)); 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
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-74) tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a); elseif (b <= 1.45e-104) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-74], N[(N[(N[(N[(1.5 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $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 \cdot 10^{-74}:\\
\;\;\;\;\frac{\left(1.5 \cdot \frac{a}{\frac{b}{c}} - b\right) - b}{3 \cdot a}\\
\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 < -3.99999999999999983e-74Initial program 73.0%
flip--38.7%
div-inv38.7%
pow238.7%
pow238.7%
pow-prod-up38.7%
metadata-eval38.7%
pow238.7%
associate-*l*38.7%
fma-def38.7%
associate-*l*38.7%
Applied egg-rr38.7%
associate-*r*38.7%
*-commutative38.7%
associate-*r*38.7%
*-commutative38.7%
Simplified38.7%
Taylor expanded in b around 0 73.0%
fma-def73.0%
Simplified73.0%
Taylor expanded in b around -inf 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
associate-/l*81.9%
Simplified81.9%
if -3.99999999999999983e-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%
*-commutative89.3%
associate-*l/89.3%
Simplified89.3%
Final simplification82.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e-75)
(/ (- (- (* 1.5 (/ a (/ b c))) b) b) (* 3.0 a))
(if (<= b 1.45e-108)
(* 0.3333333333333333 (/ (sqrt (* a (* c -3.0))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-75) {
tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a);
} else if (b <= 1.45e-108) {
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 <= (-4.5d-75)) then
tmp = (((1.5d0 * (a / (b / c))) - b) - b) / (3.0d0 * a)
else if (b <= 1.45d-108) 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 <= -4.5e-75) {
tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a);
} else if (b <= 1.45e-108) {
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 <= -4.5e-75: tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a) elif b <= 1.45e-108: 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 <= -4.5e-75) tmp = Float64(Float64(Float64(Float64(1.5 * Float64(a / Float64(b / c))) - b) - b) / Float64(3.0 * a)); elseif (b <= 1.45e-108) 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 <= -4.5e-75) tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a); elseif (b <= 1.45e-108) 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, -4.5e-75], N[(N[(N[(N[(1.5 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-108], 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 -4.5 \cdot 10^{-75}:\\
\;\;\;\;\frac{\left(1.5 \cdot \frac{a}{\frac{b}{c}} - b\right) - b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-108}:\\
\;\;\;\;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 < -4.5000000000000003e-75Initial program 73.0%
flip--38.7%
div-inv38.7%
pow238.7%
pow238.7%
pow-prod-up38.7%
metadata-eval38.7%
pow238.7%
associate-*l*38.7%
fma-def38.7%
associate-*l*38.7%
Applied egg-rr38.7%
associate-*r*38.7%
*-commutative38.7%
associate-*r*38.7%
*-commutative38.7%
Simplified38.7%
Taylor expanded in b around 0 73.0%
fma-def73.0%
Simplified73.0%
Taylor expanded in b around -inf 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
associate-/l*81.9%
Simplified81.9%
if -4.5000000000000003e-75 < b < 1.45e-108Initial 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%
associate-*l*73.0%
Applied egg-rr73.0%
Taylor expanded in b around 0 69.0%
associate-*l/69.1%
*-lft-identity69.1%
distribute-rgt-out69.4%
metadata-eval69.4%
*-commutative69.4%
metadata-eval69.4%
distribute-lft-neg-in69.4%
associate-*r*69.5%
*-commutative69.5%
associate-*r*69.5%
distribute-rgt-neg-in69.5%
distribute-lft-neg-in69.5%
metadata-eval69.5%
*-commutative69.5%
Simplified69.5%
if 1.45e-108 < b Initial program 16.3%
Taylor expanded in b around inf 89.3%
*-commutative89.3%
associate-*l/89.3%
Simplified89.3%
Final simplification82.0%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-76)
(/ (- (- (* 1.5 (/ a (/ b c))) b) b) (* 3.0 a))
(if (<= b 2.3e-95)
(* (sqrt (* c (* a -3.0))) (/ 0.3333333333333333 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-76) {
tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a);
} else if (b <= 2.3e-95) {
tmp = sqrt((c * (a * -3.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 <= (-6.5d-76)) then
tmp = (((1.5d0 * (a / (b / c))) - b) - b) / (3.0d0 * a)
else if (b <= 2.3d-95) then
tmp = sqrt((c * (a * (-3.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 <= -6.5e-76) {
tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a);
} else if (b <= 2.3e-95) {
tmp = Math.sqrt((c * (a * -3.0))) * (0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-76: tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a) elif b <= 2.3e-95: tmp = math.sqrt((c * (a * -3.0))) * (0.3333333333333333 / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-76) tmp = Float64(Float64(Float64(Float64(1.5 * Float64(a / Float64(b / c))) - b) - b) / Float64(3.0 * a)); elseif (b <= 2.3e-95) tmp = Float64(sqrt(Float64(c * Float64(a * -3.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 <= -6.5e-76) tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a); elseif (b <= 2.3e-95) tmp = sqrt((c * (a * -3.0))) * (0.3333333333333333 / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-76], N[(N[(N[(N[(1.5 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e-95], N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $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 -6.5 \cdot 10^{-76}:\\
\;\;\;\;\frac{\left(1.5 \cdot \frac{a}{\frac{b}{c}} - b\right) - b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-95}:\\
\;\;\;\;\sqrt{c \cdot \left(a \cdot -3\right)} \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.5e-76Initial program 73.0%
flip--38.7%
div-inv38.7%
pow238.7%
pow238.7%
pow-prod-up38.7%
metadata-eval38.7%
pow238.7%
associate-*l*38.7%
fma-def38.7%
associate-*l*38.7%
Applied egg-rr38.7%
associate-*r*38.7%
*-commutative38.7%
associate-*r*38.7%
*-commutative38.7%
Simplified38.7%
Taylor expanded in b around 0 73.0%
fma-def73.0%
Simplified73.0%
Taylor expanded in b around -inf 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
associate-/l*81.9%
Simplified81.9%
if -6.5e-76 < b < 2.29999999999999999e-95Initial program 71.9%
prod-diff71.6%
*-commutative71.6%
fma-def71.6%
associate-+l+71.6%
pow271.6%
*-commutative71.6%
distribute-rgt-neg-in71.6%
*-commutative71.6%
distribute-rgt-neg-in71.6%
metadata-eval71.6%
*-commutative71.6%
fma-udef71.6%
distribute-lft-neg-in71.6%
distribute-rgt-neg-in71.6%
*-commutative71.6%
distribute-rgt-neg-in71.6%
metadata-eval71.6%
associate-*l*71.6%
Applied egg-rr71.6%
Taylor expanded in b around 0 67.9%
associate-*r*68.0%
associate-*r/68.0%
metadata-eval68.0%
distribute-rgt-out68.3%
metadata-eval68.3%
*-commutative68.3%
associate-*r*68.4%
Simplified68.4%
if 2.29999999999999999e-95 < b Initial program 14.8%
Taylor expanded in b around inf 90.8%
*-commutative90.8%
associate-*l/90.8%
Simplified90.8%
Final simplification82.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (- (- (* 1.5 (/ a (/ b c))) b) b) (* 3.0 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (((1.5 * (a / (b / c))) - b) - 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 <= (-5d-310)) then
tmp = (((1.5d0 * (a / (b / c))) - b) - 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 <= -5e-310) {
tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(Float64(1.5 * Float64(a / Float64(b / c))) - b) - 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 <= -5e-310) tmp = (((1.5 * (a / (b / c))) - b) - b) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(N[(1.5 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(1.5 \cdot \frac{a}{\frac{b}{c}} - b\right) - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.2%
flip--41.8%
div-inv41.8%
pow241.8%
pow241.8%
pow-prod-up41.8%
metadata-eval41.8%
pow241.8%
associate-*l*41.7%
fma-def41.7%
associate-*l*41.8%
Applied egg-rr41.8%
associate-*r*41.8%
*-commutative41.8%
associate-*r*41.8%
*-commutative41.8%
Simplified41.8%
Taylor expanded in b around 0 74.2%
fma-def74.2%
Simplified74.2%
Taylor expanded in b around -inf 62.1%
+-commutative62.1%
mul-1-neg62.1%
unsub-neg62.1%
associate-/l*65.9%
Simplified65.9%
if -4.999999999999985e-310 < b Initial program 27.6%
Taylor expanded in b around inf 72.6%
*-commutative72.6%
associate-*l/72.6%
Simplified72.6%
Final simplification69.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / 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 <= (-5d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / 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 <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / 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 <= -5e-310) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $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.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\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%
*-commutative72.6%
associate-*l/72.6%
Simplified72.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%
*-commutative74.8%
associate-*l/74.8%
Simplified74.8%
Final simplification69.3%
(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%
*-commutative74.8%
associate-*l/74.8%
Simplified74.8%
Final simplification69.2%
(FPCore (a b c) :precision binary64 (* -0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.6666666666666666d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
def code(a, b, c): return -0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(-0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 50.7%
Taylor expanded in b around -inf 34.0%
*-commutative34.0%
Simplified34.0%
Final simplification34.0%
herbie shell --seed 2023318
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))