
(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 13 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 -0.6666666666666666) (/ 1.0 a))
(if (<= b 2.25e-108)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+145) {
tmp = (b * -0.6666666666666666) * (1.0 / a);
} else if (b <= 2.25e-108) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 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 <= (-1d+145)) then
tmp = (b * (-0.6666666666666666d0)) * (1.0d0 / a)
else if (b <= 2.25d-108) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 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 <= -1e+145) {
tmp = (b * -0.6666666666666666) * (1.0 / a);
} else if (b <= 2.25e-108) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e+145: tmp = (b * -0.6666666666666666) * (1.0 / a) elif b <= 2.25e-108: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e+145) tmp = Float64(Float64(b * -0.6666666666666666) * Float64(1.0 / a)); elseif (b <= 2.25e-108) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 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 <= -1e+145) tmp = (b * -0.6666666666666666) * (1.0 / a); elseif (b <= 2.25e-108) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e+145], N[(N[(b * -0.6666666666666666), $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.25e-108], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+145}:\\
\;\;\;\;\left(b \cdot -0.6666666666666666\right) \cdot \frac{1}{a}\\
\mathbf{elif}\;b \leq 2.25 \cdot 10^{-108}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.9999999999999999e144Initial program 43.6%
/-rgt-identity43.6%
metadata-eval43.6%
associate-/r/43.6%
metadata-eval43.6%
metadata-eval43.6%
times-frac43.6%
*-commutative43.6%
times-frac43.6%
*-commutative43.6%
associate-/r*43.6%
associate-*l/43.6%
Simplified43.6%
div-inv43.6%
*-commutative43.6%
fma-udef43.6%
associate-*r*43.6%
add-sqr-sqrt24.1%
hypot-def51.1%
Applied egg-rr51.1%
Taylor expanded in b around -inf 96.0%
*-commutative96.0%
Simplified96.0%
if -9.9999999999999999e144 < b < 2.24999999999999985e-108Initial program 87.6%
if 2.24999999999999985e-108 < b Initial program 15.9%
Taylor expanded in b around inf 87.6%
associate-*r/87.6%
Applied egg-rr87.6%
Final simplification89.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.75e+153)
(* (* b -0.6666666666666666) (/ 1.0 a))
(if (<= b 2.2e-108)
(* -0.3333333333333333 (/ (- b (sqrt (- (* b b) (* 3.0 (* a c))))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e+153) {
tmp = (b * -0.6666666666666666) * (1.0 / a);
} else if (b <= 2.2e-108) {
tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / 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.75d+153)) then
tmp = (b * (-0.6666666666666666d0)) * (1.0d0 / a)
else if (b <= 2.2d-108) then
tmp = (-0.3333333333333333d0) * ((b - sqrt(((b * b) - (3.0d0 * (a * c))))) / 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.75e+153) {
tmp = (b * -0.6666666666666666) * (1.0 / a);
} else if (b <= 2.2e-108) {
tmp = -0.3333333333333333 * ((b - Math.sqrt(((b * b) - (3.0 * (a * c))))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.75e+153: tmp = (b * -0.6666666666666666) * (1.0 / a) elif b <= 2.2e-108: tmp = -0.3333333333333333 * ((b - math.sqrt(((b * b) - (3.0 * (a * c))))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.75e+153) tmp = Float64(Float64(b * -0.6666666666666666) * Float64(1.0 / a)); elseif (b <= 2.2e-108) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c))))) / 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.75e+153) tmp = (b * -0.6666666666666666) * (1.0 / a); elseif (b <= 2.2e-108) tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.75e+153], N[(N[(b * -0.6666666666666666), $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.2e-108], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $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.75 \cdot 10^{+153}:\\
\;\;\;\;\left(b \cdot -0.6666666666666666\right) \cdot \frac{1}{a}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-108}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.75e153Initial program 41.2%
/-rgt-identity41.2%
metadata-eval41.2%
associate-/r/41.2%
metadata-eval41.2%
metadata-eval41.2%
times-frac41.2%
*-commutative41.2%
times-frac41.2%
*-commutative41.2%
associate-/r*41.2%
associate-*l/41.2%
Simplified41.2%
div-inv41.2%
*-commutative41.2%
fma-udef41.2%
associate-*r*41.2%
add-sqr-sqrt25.1%
hypot-def53.2%
Applied egg-rr53.2%
Taylor expanded in b around -inf 95.8%
*-commutative95.8%
Simplified95.8%
if -1.75e153 < b < 2.2000000000000001e-108Initial program 87.8%
/-rgt-identity87.8%
metadata-eval87.8%
associate-/l*87.8%
associate-*r/87.7%
*-commutative87.7%
associate-*l/87.8%
associate-*r/87.8%
metadata-eval87.8%
metadata-eval87.8%
times-frac87.8%
neg-mul-187.8%
distribute-rgt-neg-in87.8%
times-frac87.6%
metadata-eval87.6%
neg-mul-187.6%
Simplified87.7%
fma-udef87.7%
associate-*r*87.6%
*-commutative87.6%
metadata-eval87.6%
cancel-sign-sub-inv87.6%
Applied egg-rr87.6%
if 2.2000000000000001e-108 < b Initial program 15.9%
Taylor expanded in b around inf 87.6%
associate-*r/87.6%
Applied egg-rr87.6%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e+149)
(* (* b -0.6666666666666666) (/ 1.0 a))
(if (<= b 4.2e-110)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+149) {
tmp = (b * -0.6666666666666666) * (1.0 / a);
} else if (b <= 4.2e-110) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 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 <= (-6.5d+149)) then
tmp = (b * (-0.6666666666666666d0)) * (1.0d0 / a)
else if (b <= 4.2d-110) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 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 <= -6.5e+149) {
tmp = (b * -0.6666666666666666) * (1.0 / a);
} else if (b <= 4.2e-110) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e+149: tmp = (b * -0.6666666666666666) * (1.0 / a) elif b <= 4.2e-110: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e+149) tmp = Float64(Float64(b * -0.6666666666666666) * Float64(1.0 / a)); elseif (b <= 4.2e-110) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 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 <= -6.5e+149) tmp = (b * -0.6666666666666666) * (1.0 / a); elseif (b <= 4.2e-110) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e+149], N[(N[(b * -0.6666666666666666), $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.2e-110], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{+149}:\\
\;\;\;\;\left(b \cdot -0.6666666666666666\right) \cdot \frac{1}{a}\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-110}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.50000000000000015e149Initial program 43.6%
/-rgt-identity43.6%
metadata-eval43.6%
associate-/r/43.6%
metadata-eval43.6%
metadata-eval43.6%
times-frac43.6%
*-commutative43.6%
times-frac43.6%
*-commutative43.6%
associate-/r*43.6%
associate-*l/43.6%
Simplified43.6%
div-inv43.6%
*-commutative43.6%
fma-udef43.6%
associate-*r*43.6%
add-sqr-sqrt24.1%
hypot-def51.1%
Applied egg-rr51.1%
Taylor expanded in b around -inf 96.0%
*-commutative96.0%
Simplified96.0%
if -6.50000000000000015e149 < b < 4.20000000000000004e-110Initial program 87.6%
neg-sub087.6%
associate-+l-87.6%
sub0-neg87.6%
neg-mul-187.6%
associate-*r/87.6%
metadata-eval87.6%
metadata-eval87.6%
times-frac87.6%
*-commutative87.6%
times-frac87.6%
associate-*l/87.6%
Simplified87.5%
if 4.20000000000000004e-110 < b Initial program 15.9%
Taylor expanded in b around inf 87.6%
associate-*r/87.6%
Applied egg-rr87.6%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -6e-23)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.5e-108)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-23) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.5e-108) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 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 <= (-6d-23)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.5d-108) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (a * 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 <= -6e-23) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.5e-108) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-23: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.5e-108: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-23) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.5e-108) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(a * 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 <= -6e-23) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.5e-108) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-23], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-108], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-23}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-108}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.00000000000000006e-23Initial program 69.2%
Taylor expanded in b around -inf 88.6%
if -6.00000000000000006e-23 < b < 1.49999999999999996e-108Initial program 83.3%
Taylor expanded in b around 0 75.5%
if 1.49999999999999996e-108 < b Initial program 15.9%
Taylor expanded in b around inf 87.6%
associate-*r/87.6%
Applied egg-rr87.6%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.2e-22)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 2.25e-108)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.2e-22) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.25e-108) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 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 <= (-1.2d-22)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 2.25d-108) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 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 <= -1.2e-22) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.25e-108) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.2e-22: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 2.25e-108: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.2e-22) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 2.25e-108) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 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 <= -1.2e-22) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 2.25e-108) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.2e-22], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.25e-108], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.2 \cdot 10^{-22}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 2.25 \cdot 10^{-108}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.20000000000000001e-22Initial program 69.2%
Taylor expanded in b around -inf 88.6%
if -1.20000000000000001e-22 < b < 2.24999999999999985e-108Initial program 83.3%
Taylor expanded in b around 0 75.5%
*-commutative75.5%
metadata-eval75.5%
distribute-lft-neg-in75.5%
associate-*r*75.7%
distribute-lft-neg-out75.7%
*-commutative75.7%
distribute-lft-neg-in75.7%
metadata-eval75.7%
Simplified75.7%
if 2.24999999999999985e-108 < b Initial program 15.9%
Taylor expanded in b around inf 87.6%
associate-*r/87.6%
Applied egg-rr87.6%
Final simplification84.5%
(FPCore (a b c) :precision binary64 (if (<= b -4e-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 <= -4e-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 <= (-4d-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 <= -4e-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 <= -4e-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 <= -4e-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 <= -4e-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, -4e-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 -4 \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 < -3.999999999999988e-310Initial program 72.5%
Taylor expanded in b around -inf 69.4%
if -3.999999999999988e-310 < b Initial program 36.6%
Taylor expanded in b around inf 65.5%
associate-*r/65.5%
Applied egg-rr65.5%
Final simplification67.7%
(FPCore (a b c) :precision binary64 (if (<= b 3.8e-305) (* (* b -0.6666666666666666) (/ 1.0 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-305) {
tmp = (b * -0.6666666666666666) * (1.0 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 3.8d-305) then
tmp = (b * (-0.6666666666666666d0)) * (1.0d0 / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-305) {
tmp = (b * -0.6666666666666666) * (1.0 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.8e-305: tmp = (b * -0.6666666666666666) * (1.0 / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.8e-305) tmp = Float64(Float64(b * -0.6666666666666666) * Float64(1.0 / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.8e-305) tmp = (b * -0.6666666666666666) * (1.0 / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.8e-305], N[(N[(b * -0.6666666666666666), $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.8 \cdot 10^{-305}:\\
\;\;\;\;\left(b \cdot -0.6666666666666666\right) \cdot \frac{1}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 3.8e-305Initial program 72.7%
/-rgt-identity72.7%
metadata-eval72.7%
associate-/r/72.7%
metadata-eval72.7%
metadata-eval72.7%
times-frac72.7%
*-commutative72.7%
times-frac72.6%
*-commutative72.6%
associate-/r*72.6%
associate-*l/72.6%
Simplified72.6%
div-inv72.6%
*-commutative72.6%
fma-udef72.6%
associate-*r*72.6%
add-sqr-sqrt58.3%
hypot-def68.6%
Applied egg-rr68.6%
Taylor expanded in b around -inf 68.7%
*-commutative68.7%
Simplified68.7%
if 3.8e-305 < b Initial program 36.0%
Taylor expanded in b around inf 66.1%
associate-*r/66.1%
Applied egg-rr66.1%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 3.8e-305) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-305) {
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.8d-305) 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.8e-305) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.8e-305: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.8e-305) 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.8e-305) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.8e-305], 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.8 \cdot 10^{-305}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.8e-305Initial program 72.7%
Taylor expanded in b around -inf 68.6%
*-commutative68.6%
Simplified68.6%
if 3.8e-305 < b Initial program 36.0%
Taylor expanded in b around inf 66.1%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 3.8e-305) (/ -0.6666666666666666 (/ a b)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-305) {
tmp = -0.6666666666666666 / (a / b);
} 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.8d-305) then
tmp = (-0.6666666666666666d0) / (a / b)
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.8e-305) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.8e-305: tmp = -0.6666666666666666 / (a / b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.8e-305) tmp = Float64(-0.6666666666666666 / Float64(a / b)); 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.8e-305) tmp = -0.6666666666666666 / (a / b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.8e-305], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.8 \cdot 10^{-305}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.8e-305Initial program 72.7%
/-rgt-identity72.7%
metadata-eval72.7%
associate-/l*72.7%
associate-*r/72.6%
*-commutative72.6%
associate-*l/72.7%
associate-*r/72.7%
metadata-eval72.7%
metadata-eval72.7%
times-frac72.7%
neg-mul-172.7%
distribute-rgt-neg-in72.7%
times-frac72.6%
metadata-eval72.6%
neg-mul-172.6%
Simplified72.6%
fma-udef72.6%
associate-*r*72.6%
*-commutative72.6%
metadata-eval72.6%
cancel-sign-sub-inv72.6%
Applied egg-rr72.6%
Taylor expanded in b around -inf 68.6%
associate-*r/68.7%
associate-/l*68.6%
Simplified68.6%
if 3.8e-305 < b Initial program 36.0%
Taylor expanded in b around inf 66.1%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 3.8e-305) (/ b (/ a -0.6666666666666666)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-305) {
tmp = b / (a / -0.6666666666666666);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 3.8d-305) then
tmp = b / (a / (-0.6666666666666666d0))
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-305) {
tmp = b / (a / -0.6666666666666666);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.8e-305: tmp = b / (a / -0.6666666666666666) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.8e-305) tmp = Float64(b / Float64(a / -0.6666666666666666)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.8e-305) tmp = b / (a / -0.6666666666666666); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.8e-305], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.8 \cdot 10^{-305}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.8e-305Initial program 72.7%
/-rgt-identity72.7%
metadata-eval72.7%
associate-/r/72.7%
metadata-eval72.7%
metadata-eval72.7%
times-frac72.7%
*-commutative72.7%
times-frac72.6%
*-commutative72.6%
associate-/r*72.6%
associate-*l/72.6%
Simplified72.6%
div-inv72.6%
*-commutative72.6%
fma-udef72.6%
associate-*r*72.6%
add-sqr-sqrt58.3%
hypot-def68.6%
Applied egg-rr68.6%
Taylor expanded in b around -inf 68.6%
associate-*r/68.7%
*-commutative68.7%
associate-/l*68.6%
Simplified68.6%
if 3.8e-305 < b Initial program 36.0%
Taylor expanded in b around inf 66.1%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 3.8e-305) (/ b (/ a -0.6666666666666666)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-305) {
tmp = b / (a / -0.6666666666666666);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 3.8d-305) then
tmp = b / (a / (-0.6666666666666666d0))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-305) {
tmp = b / (a / -0.6666666666666666);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.8e-305: tmp = b / (a / -0.6666666666666666) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.8e-305) tmp = Float64(b / Float64(a / -0.6666666666666666)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.8e-305) tmp = b / (a / -0.6666666666666666); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.8e-305], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.8 \cdot 10^{-305}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 3.8e-305Initial program 72.7%
/-rgt-identity72.7%
metadata-eval72.7%
associate-/r/72.7%
metadata-eval72.7%
metadata-eval72.7%
times-frac72.7%
*-commutative72.7%
times-frac72.6%
*-commutative72.6%
associate-/r*72.6%
associate-*l/72.6%
Simplified72.6%
div-inv72.6%
*-commutative72.6%
fma-udef72.6%
associate-*r*72.6%
add-sqr-sqrt58.3%
hypot-def68.6%
Applied egg-rr68.6%
Taylor expanded in b around -inf 68.6%
associate-*r/68.7%
*-commutative68.7%
associate-/l*68.6%
Simplified68.6%
if 3.8e-305 < b Initial program 36.0%
Taylor expanded in b around inf 66.1%
associate-*r/66.1%
Applied egg-rr66.1%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 3.8e-305) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-305) {
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 <= 3.8d-305) 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 <= 3.8e-305) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.8e-305: tmp = (b * -0.6666666666666666) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.8e-305) 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 <= 3.8e-305) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.8e-305], 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 3.8 \cdot 10^{-305}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 3.8e-305Initial program 72.7%
/-rgt-identity72.7%
metadata-eval72.7%
associate-/r/72.7%
metadata-eval72.7%
metadata-eval72.7%
times-frac72.7%
*-commutative72.7%
times-frac72.6%
*-commutative72.6%
associate-/r*72.6%
associate-*l/72.6%
Simplified72.6%
Taylor expanded in b around -inf 68.7%
*-commutative68.7%
Simplified68.7%
if 3.8e-305 < b Initial program 36.0%
Taylor expanded in b around inf 66.1%
associate-*r/66.1%
Applied egg-rr66.1%
Final simplification67.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 56.5%
Taylor expanded in b around inf 30.3%
Final simplification30.3%
herbie shell --seed 2023242
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))