
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -5.8e+134)
(/ b (* a -1.5))
(if (<= b 3.5e-116)
(/ (- (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 <= -5.8e+134) {
tmp = b / (a * -1.5);
} else if (b <= 3.5e-116) {
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 <= (-5.8d+134)) then
tmp = b / (a * (-1.5d0))
else if (b <= 3.5d-116) 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 <= -5.8e+134) {
tmp = b / (a * -1.5);
} else if (b <= 3.5e-116) {
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 <= -5.8e+134: tmp = b / (a * -1.5) elif b <= 3.5e-116: 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 <= -5.8e+134) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 3.5e-116) 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 <= -5.8e+134) tmp = b / (a * -1.5); elseif (b <= 3.5e-116) 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, -5.8e+134], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-116], 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 -5.8 \cdot 10^{+134}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-116}:\\
\;\;\;\;\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 < -5.80000000000000023e134Initial program 52.4%
Taylor expanded in b around -inf 92.5%
*-commutative92.5%
Simplified92.5%
metadata-eval92.5%
times-frac92.9%
*-commutative92.9%
associate-/l*92.9%
frac-2neg92.9%
add-sqr-sqrt92.5%
sqrt-unprod52.6%
sqr-neg52.6%
sqrt-unprod0.0%
add-sqr-sqrt0.5%
div-inv0.5%
add-sqr-sqrt0.2%
sqrt-unprod38.2%
*-commutative38.2%
*-commutative38.2%
swap-sqr38.2%
metadata-eval38.2%
metadata-eval38.2%
swap-sqr38.2%
sqrt-unprod45.1%
add-sqr-sqrt92.9%
metadata-eval92.9%
Applied egg-rr92.9%
associate-*l*92.9%
metadata-eval92.9%
distribute-rgt-neg-in92.9%
metadata-eval92.9%
Simplified92.9%
if -5.80000000000000023e134 < b < 3.49999999999999984e-116Initial program 88.8%
if 3.49999999999999984e-116 < b Initial program 17.9%
fma-neg17.9%
associate-*l*17.9%
distribute-lft-neg-in17.9%
metadata-eval17.9%
*-commutative17.9%
associate-*r*17.9%
add-cube-cbrt15.1%
sqrt-prod15.2%
Applied egg-rr15.2%
Taylor expanded in b around inf 84.3%
associate-*r/84.3%
*-commutative84.3%
Simplified84.3%
Final simplification87.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e-69)
(/ (/ (* b 2.0) -3.0) a)
(if (<= b 3.5e-116)
(* (+ b (sqrt (* a (* c -3.0)))) (/ 0.3333333333333333 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-69) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 3.5e-116) {
tmp = (b + sqrt((a * (c * -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 <= (-1.15d-69)) then
tmp = ((b * 2.0d0) / (-3.0d0)) / a
else if (b <= 3.5d-116) then
tmp = (b + sqrt((a * (c * (-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 <= -1.15e-69) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 3.5e-116) {
tmp = (b + Math.sqrt((a * (c * -3.0)))) * (0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-69: tmp = ((b * 2.0) / -3.0) / a elif b <= 3.5e-116: tmp = (b + math.sqrt((a * (c * -3.0)))) * (0.3333333333333333 / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-69) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / a); elseif (b <= 3.5e-116) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -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 <= -1.15e-69) tmp = ((b * 2.0) / -3.0) / a; elseif (b <= 3.5e-116) tmp = (b + sqrt((a * (c * -3.0)))) * (0.3333333333333333 / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-69], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.5e-116], N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $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 -1.15 \cdot 10^{-69}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-116}:\\
\;\;\;\;\left(b + \sqrt{a \cdot \left(c \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.15e-69Initial program 78.9%
Applied egg-rr8.1%
Applied egg-rr62.7%
Taylor expanded in b around -inf 89.6%
*-commutative89.6%
Simplified89.6%
if -1.15e-69 < b < 3.49999999999999984e-116Initial program 79.8%
Taylor expanded in b around 0 77.7%
associate-*r*77.8%
*-commutative77.8%
*-commutative77.8%
Simplified77.8%
add-cbrt-cube57.2%
pow357.2%
sqrt-pow257.2%
metadata-eval57.2%
Applied egg-rr57.2%
expm1-log1p-u41.0%
expm1-udef16.9%
Applied egg-rr23.2%
expm1-def59.2%
expm1-log1p77.1%
*-commutative77.1%
*-commutative77.1%
associate-*l*77.3%
*-commutative77.3%
Simplified77.3%
if 3.49999999999999984e-116 < b Initial program 17.9%
fma-neg17.9%
associate-*l*17.9%
distribute-lft-neg-in17.9%
metadata-eval17.9%
*-commutative17.9%
associate-*r*17.9%
add-cube-cbrt15.1%
sqrt-prod15.2%
Applied egg-rr15.2%
Taylor expanded in b around inf 84.3%
associate-*r/84.3%
*-commutative84.3%
Simplified84.3%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.7e-67)
(/ (/ (* b 2.0) -3.0) a)
(if (<= b 3.5e-116)
(/ (/ (+ b (sqrt (* a (* c -3.0)))) a) 3.0)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e-67) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 3.5e-116) {
tmp = ((b + sqrt((a * (c * -3.0)))) / 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 <= (-2.7d-67)) then
tmp = ((b * 2.0d0) / (-3.0d0)) / a
else if (b <= 3.5d-116) then
tmp = ((b + sqrt((a * (c * (-3.0d0))))) / 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 <= -2.7e-67) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 3.5e-116) {
tmp = ((b + Math.sqrt((a * (c * -3.0)))) / a) / 3.0;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.7e-67: tmp = ((b * 2.0) / -3.0) / a elif b <= 3.5e-116: tmp = ((b + math.sqrt((a * (c * -3.0)))) / a) / 3.0 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.7e-67) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / a); elseif (b <= 3.5e-116) tmp = Float64(Float64(Float64(b + sqrt(Float64(a * Float64(c * -3.0)))) / 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 <= -2.7e-67) tmp = ((b * 2.0) / -3.0) / a; elseif (b <= 3.5e-116) tmp = ((b + sqrt((a * (c * -3.0)))) / a) / 3.0; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.7e-67], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.5e-116], N[(N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{-67}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-116}:\\
\;\;\;\;\frac{\frac{b + \sqrt{a \cdot \left(c \cdot -3\right)}}{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.70000000000000016e-67Initial program 78.9%
Applied egg-rr8.1%
Applied egg-rr62.7%
Taylor expanded in b around -inf 89.6%
*-commutative89.6%
Simplified89.6%
if -2.70000000000000016e-67 < b < 3.49999999999999984e-116Initial program 79.8%
Taylor expanded in b around 0 77.7%
associate-*r*77.8%
*-commutative77.8%
*-commutative77.8%
Simplified77.8%
add-cbrt-cube57.2%
pow357.2%
sqrt-pow257.2%
metadata-eval57.2%
Applied egg-rr57.2%
add-cube-cbrt56.6%
*-commutative56.6%
times-frac56.6%
Applied egg-rr76.1%
associate-*l/76.1%
associate-*r/76.0%
unpow276.0%
rem-3cbrt-lft77.3%
rem-square-sqrt77.0%
associate-*r/77.2%
associate-*l/77.0%
*-commutative77.0%
associate-*l/77.1%
Simplified77.4%
if 3.49999999999999984e-116 < b Initial program 17.9%
fma-neg17.9%
associate-*l*17.9%
distribute-lft-neg-in17.9%
metadata-eval17.9%
*-commutative17.9%
associate-*r*17.9%
add-cube-cbrt15.1%
sqrt-prod15.2%
Applied egg-rr15.2%
Taylor expanded in b around inf 84.3%
associate-*r/84.3%
*-commutative84.3%
Simplified84.3%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -3.3e-53)
(/ (/ (* b 2.0) -3.0) a)
(if (<= b 2.8e-116)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.3e-53) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 2.8e-116) {
tmp = (sqrt((-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 <= (-3.3d-53)) then
tmp = ((b * 2.0d0) / (-3.0d0)) / a
else if (b <= 2.8d-116) then
tmp = (sqrt(((-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 <= -3.3e-53) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 2.8e-116) {
tmp = (Math.sqrt((-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 <= -3.3e-53: tmp = ((b * 2.0) / -3.0) / a elif b <= 2.8e-116: tmp = (math.sqrt((-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 <= -3.3e-53) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / a); elseif (b <= 2.8e-116) tmp = Float64(Float64(sqrt(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 <= -3.3e-53) tmp = ((b * 2.0) / -3.0) / a; elseif (b <= 2.8e-116) tmp = (sqrt((-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, -3.3e-53], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.8e-116], N[(N[(N[Sqrt[N[(-3.0 * N[(a * 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 -3.3 \cdot 10^{-53}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-116}:\\
\;\;\;\;\frac{\sqrt{-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 < -3.30000000000000004e-53Initial program 78.4%
Applied egg-rr7.1%
Applied egg-rr61.8%
Taylor expanded in b around -inf 90.4%
*-commutative90.4%
Simplified90.4%
if -3.30000000000000004e-53 < b < 2.7999999999999999e-116Initial program 80.4%
Taylor expanded in b around 0 77.1%
if 2.7999999999999999e-116 < b Initial program 17.9%
fma-neg17.9%
associate-*l*17.9%
distribute-lft-neg-in17.9%
metadata-eval17.9%
*-commutative17.9%
associate-*r*17.9%
add-cube-cbrt15.1%
sqrt-prod15.2%
Applied egg-rr15.2%
Taylor expanded in b around inf 84.3%
associate-*r/84.3%
*-commutative84.3%
Simplified84.3%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -6.4e-52)
(/ (/ (* b 2.0) -3.0) a)
(if (<= b 3.5e-116)
(/ (- (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 <= -6.4e-52) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 3.5e-116) {
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 <= (-6.4d-52)) then
tmp = ((b * 2.0d0) / (-3.0d0)) / a
else if (b <= 3.5d-116) 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 <= -6.4e-52) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 3.5e-116) {
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 <= -6.4e-52: tmp = ((b * 2.0) / -3.0) / a elif b <= 3.5e-116: 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 <= -6.4e-52) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / a); elseif (b <= 3.5e-116) 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 <= -6.4e-52) tmp = ((b * 2.0) / -3.0) / a; elseif (b <= 3.5e-116) 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, -6.4e-52], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.5e-116], 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 -6.4 \cdot 10^{-52}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-116}:\\
\;\;\;\;\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 < -6.4000000000000002e-52Initial program 78.4%
Applied egg-rr7.1%
Applied egg-rr61.8%
Taylor expanded in b around -inf 90.4%
*-commutative90.4%
Simplified90.4%
if -6.4000000000000002e-52 < b < 3.49999999999999984e-116Initial program 80.4%
Taylor expanded in b around 0 77.1%
associate-*r*77.2%
*-commutative77.2%
*-commutative77.2%
Simplified77.2%
if 3.49999999999999984e-116 < b Initial program 17.9%
fma-neg17.9%
associate-*l*17.9%
distribute-lft-neg-in17.9%
metadata-eval17.9%
*-commutative17.9%
associate-*r*17.9%
add-cube-cbrt15.1%
sqrt-prod15.2%
Applied egg-rr15.2%
Taylor expanded in b around inf 84.3%
associate-*r/84.3%
*-commutative84.3%
Simplified84.3%
Final simplification84.7%
(FPCore (a b c) :precision binary64 (if (<= b 2.6e-287) (/ (/ (* b 2.0) -3.0) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.6e-287) {
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 <= 2.6d-287) 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 <= 2.6e-287) {
tmp = ((b * 2.0) / -3.0) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.6e-287: 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 <= 2.6e-287) tmp = Float64(Float64(Float64(b * 2.0) / -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 <= 2.6e-287) 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, 2.6e-287], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{-287}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 2.6e-287Initial program 80.4%
Applied egg-rr29.1%
Applied egg-rr69.6%
Taylor expanded in b around -inf 66.5%
*-commutative66.5%
Simplified66.5%
if 2.6e-287 < b Initial program 28.2%
fma-neg28.2%
associate-*l*28.2%
distribute-lft-neg-in28.2%
metadata-eval28.2%
*-commutative28.2%
associate-*r*28.2%
add-cube-cbrt25.9%
sqrt-prod25.9%
Applied egg-rr25.9%
Taylor expanded in b around inf 71.5%
associate-*r/71.5%
*-commutative71.5%
Simplified71.5%
Final simplification69.0%
(FPCore (a b c) :precision binary64 (if (<= b 2.6e-287) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.6e-287) {
tmp = b * (-0.6666666666666666 / 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 <= 2.6d-287) then
tmp = b * ((-0.6666666666666666d0) / 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 <= 2.6e-287) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.6e-287: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.6e-287) tmp = Float64(b * Float64(-0.6666666666666666 / 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 <= 2.6e-287) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.6e-287], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{-287}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.6e-287Initial program 80.4%
fma-neg80.4%
associate-*l*80.4%
distribute-lft-neg-in80.4%
metadata-eval80.4%
*-commutative80.4%
associate-*r*80.4%
add-cube-cbrt80.1%
sqrt-prod80.1%
Applied egg-rr80.2%
sqrt-pow180.2%
metadata-eval80.2%
pow180.2%
Applied egg-rr80.2%
Taylor expanded in b around -inf 66.3%
*-commutative66.3%
associate-*l/66.4%
associate-*r/66.3%
Simplified66.3%
if 2.6e-287 < b Initial program 28.2%
Taylor expanded in b around inf 71.5%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (<= b 2.6e-287) (/ -0.6666666666666666 (/ a b)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.6e-287) {
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 <= 2.6d-287) 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 <= 2.6e-287) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.6e-287: tmp = -0.6666666666666666 / (a / b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.6e-287) 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 <= 2.6e-287) tmp = -0.6666666666666666 / (a / b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.6e-287], 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 2.6 \cdot 10^{-287}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.6e-287Initial program 80.4%
Taylor expanded in b around -inf 66.3%
*-commutative66.3%
Simplified66.3%
*-commutative66.3%
clear-num66.2%
un-div-inv66.3%
Applied egg-rr66.3%
if 2.6e-287 < b Initial program 28.2%
Taylor expanded in b around inf 71.5%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (<= b 2.6e-287) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.6e-287) {
tmp = b / (a * -1.5);
} 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 <= 2.6d-287) then
tmp = b / (a * (-1.5d0))
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 <= 2.6e-287) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.6e-287: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.6e-287) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.6e-287) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.6e-287], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{-287}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.6e-287Initial program 80.4%
Taylor expanded in b around -inf 66.3%
*-commutative66.3%
Simplified66.3%
metadata-eval66.3%
times-frac66.4%
*-commutative66.4%
associate-/l*66.4%
frac-2neg66.4%
add-sqr-sqrt66.2%
sqrt-unprod52.9%
sqr-neg52.9%
sqrt-unprod0.1%
add-sqr-sqrt1.4%
div-inv1.4%
add-sqr-sqrt0.7%
sqrt-unprod29.1%
*-commutative29.1%
*-commutative29.1%
swap-sqr29.1%
metadata-eval29.1%
metadata-eval29.1%
swap-sqr29.1%
sqrt-unprod32.6%
add-sqr-sqrt66.4%
metadata-eval66.4%
Applied egg-rr66.4%
associate-*l*66.4%
metadata-eval66.4%
distribute-rgt-neg-in66.4%
metadata-eval66.4%
Simplified66.4%
if 2.6e-287 < b Initial program 28.2%
Taylor expanded in b around inf 71.5%
Final simplification69.0%
(FPCore (a b c) :precision binary64 (if (<= b 2.6e-287) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.6e-287) {
tmp = b / (a * -1.5);
} 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.6d-287) then
tmp = b / (a * (-1.5d0))
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.6e-287) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.6e-287: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.6e-287) tmp = Float64(b / Float64(a * -1.5)); 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.6e-287) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.6e-287], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{-287}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 2.6e-287Initial program 80.4%
Taylor expanded in b around -inf 66.3%
*-commutative66.3%
Simplified66.3%
metadata-eval66.3%
times-frac66.4%
*-commutative66.4%
associate-/l*66.4%
frac-2neg66.4%
add-sqr-sqrt66.2%
sqrt-unprod52.9%
sqr-neg52.9%
sqrt-unprod0.1%
add-sqr-sqrt1.4%
div-inv1.4%
add-sqr-sqrt0.7%
sqrt-unprod29.1%
*-commutative29.1%
*-commutative29.1%
swap-sqr29.1%
metadata-eval29.1%
metadata-eval29.1%
swap-sqr29.1%
sqrt-unprod32.6%
add-sqr-sqrt66.4%
metadata-eval66.4%
Applied egg-rr66.4%
associate-*l*66.4%
metadata-eval66.4%
distribute-rgt-neg-in66.4%
metadata-eval66.4%
Simplified66.4%
if 2.6e-287 < b Initial program 28.2%
fma-neg28.2%
associate-*l*28.2%
distribute-lft-neg-in28.2%
metadata-eval28.2%
*-commutative28.2%
associate-*r*28.2%
add-cube-cbrt25.9%
sqrt-prod25.9%
Applied egg-rr25.9%
Taylor expanded in b around inf 71.5%
associate-*r/71.5%
*-commutative71.5%
Simplified71.5%
Final simplification69.0%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 54.3%
Taylor expanded in b around inf 36.7%
Final simplification36.7%
herbie shell --seed 2023321
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))