
(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 -4.2e+153)
(/ (+ (* b -2.0) (* (/ (* a 1.5) b) c)) (* a 3.0))
(if (<= b 1.7e-108)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.2e+153) {
tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0);
} else if (b <= 1.7e-108) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} 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 <= (-4.2d+153)) then
tmp = ((b * (-2.0d0)) + (((a * 1.5d0) / b) * c)) / (a * 3.0d0)
else if (b <= 1.7d-108) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
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 <= -4.2e+153) {
tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0);
} else if (b <= 1.7e-108) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.2e+153: tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0) elif b <= 1.7e-108: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.2e+153) tmp = Float64(Float64(Float64(b * -2.0) + Float64(Float64(Float64(a * 1.5) / b) * c)) / Float64(a * 3.0)); elseif (b <= 1.7e-108) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.2e+153) tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0); elseif (b <= 1.7e-108) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.2e+153], N[(N[(N[(b * -2.0), $MachinePrecision] + N[(N[(N[(a * 1.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.7e-108], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.2 \cdot 10^{+153}:\\
\;\;\;\;\frac{b \cdot -2 + \frac{a \cdot 1.5}{b} \cdot c}{a \cdot 3}\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{-108}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.20000000000000033e153Initial program 37.1%
sqr-neg37.1%
sqr-neg37.1%
associate-*l*37.1%
Simplified37.1%
Taylor expanded in b around -inf 92.0%
*-commutative92.0%
fma-def92.0%
associate-/l*99.7%
associate-*r/99.7%
Simplified99.7%
fma-udef99.7%
associate-/r/99.7%
*-commutative99.7%
Applied egg-rr99.7%
if -4.20000000000000033e153 < b < 1.70000000000000001e-108Initial program 84.4%
if 1.70000000000000001e-108 < b Initial program 22.6%
sqr-neg22.6%
sqr-neg22.6%
associate-*l*22.6%
Simplified22.6%
Taylor expanded in b around inf 83.9%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4e+153)
(/ (+ (* b -2.0) (* (/ (* a 1.5) b) c)) (* a 3.0))
(if (<= b 2e-108)
(/ (- (sqrt (- (* b b) (* a (* c 3.0)))) b) (/ a 0.3333333333333333))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+153) {
tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0);
} else if (b <= 2e-108) {
tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4d+153)) then
tmp = ((b * (-2.0d0)) + (((a * 1.5d0) / b) * c)) / (a * 3.0d0)
else if (b <= 2d-108) then
tmp = (sqrt(((b * b) - (a * (c * 3.0d0)))) - b) / (a / 0.3333333333333333d0)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e+153) {
tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0);
} else if (b <= 2e-108) {
tmp = (Math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e+153: tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0) elif b <= 2e-108: tmp = (math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e+153) tmp = Float64(Float64(Float64(b * -2.0) + Float64(Float64(Float64(a * 1.5) / b) * c)) / Float64(a * 3.0)); elseif (b <= 2e-108) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 3.0)))) - b) / Float64(a / 0.3333333333333333)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e+153) tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0); elseif (b <= 2e-108) tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e+153], N[(N[(N[(b * -2.0), $MachinePrecision] + N[(N[(N[(a * 1.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-108], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a / 0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+153}:\\
\;\;\;\;\frac{b \cdot -2 + \frac{a \cdot 1.5}{b} \cdot c}{a \cdot 3}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-108}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{\frac{a}{0.3333333333333333}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4e153Initial program 37.1%
sqr-neg37.1%
sqr-neg37.1%
associate-*l*37.1%
Simplified37.1%
Taylor expanded in b around -inf 92.0%
*-commutative92.0%
fma-def92.0%
associate-/l*99.7%
associate-*r/99.7%
Simplified99.7%
fma-udef99.7%
associate-/r/99.7%
*-commutative99.7%
Applied egg-rr99.7%
if -4e153 < b < 2.00000000000000008e-108Initial program 84.4%
neg-sub084.4%
sqr-neg84.4%
associate-+l-84.4%
sub0-neg84.4%
neg-mul-184.4%
Simplified84.1%
associate-*r*84.1%
metadata-eval84.1%
distribute-rgt-neg-in84.1%
*-commutative84.1%
fma-neg84.1%
associate-*r*84.1%
*-commutative84.1%
associate-*l*84.1%
Applied egg-rr84.1%
*-commutative84.1%
Simplified84.1%
if 2.00000000000000008e-108 < b Initial program 22.6%
sqr-neg22.6%
sqr-neg22.6%
associate-*l*22.6%
Simplified22.6%
Taylor expanded in b around inf 83.9%
Final simplification87.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+152)
(/ (+ (* b -2.0) (* (/ (* a 1.5) b) c)) (* a 3.0))
(if (<= b 1.45e-108)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+152) {
tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0);
} else if (b <= 1.45e-108) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} 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 <= (-5d+152)) then
tmp = ((b * (-2.0d0)) + (((a * 1.5d0) / b) * c)) / (a * 3.0d0)
else if (b <= 1.45d-108) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
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 <= -5e+152) {
tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0);
} else if (b <= 1.45e-108) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+152: tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0) elif b <= 1.45e-108: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+152) tmp = Float64(Float64(Float64(b * -2.0) + Float64(Float64(Float64(a * 1.5) / b) * c)) / Float64(a * 3.0)); elseif (b <= 1.45e-108) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+152) tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0); elseif (b <= 1.45e-108) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+152], N[(N[(N[(b * -2.0), $MachinePrecision] + N[(N[(N[(a * 1.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-108], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+152}:\\
\;\;\;\;\frac{b \cdot -2 + \frac{a \cdot 1.5}{b} \cdot c}{a \cdot 3}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-108}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5e152Initial program 37.1%
sqr-neg37.1%
sqr-neg37.1%
associate-*l*37.1%
Simplified37.1%
Taylor expanded in b around -inf 92.0%
*-commutative92.0%
fma-def92.0%
associate-/l*99.7%
associate-*r/99.7%
Simplified99.7%
fma-udef99.7%
associate-/r/99.7%
*-commutative99.7%
Applied egg-rr99.7%
if -5e152 < b < 1.45e-108Initial program 84.4%
sqr-neg84.4%
sqr-neg84.4%
associate-*l*84.2%
Simplified84.2%
if 1.45e-108 < b Initial program 22.6%
sqr-neg22.6%
sqr-neg22.6%
associate-*l*22.6%
Simplified22.6%
Taylor expanded in b around inf 83.9%
Final simplification87.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.35e-26)
(/ (+ (* b -2.0) (* (/ (* a 1.5) b) c)) (* a 3.0))
(if (<= b 2e-108)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.35e-26) {
tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0);
} else if (b <= 2e-108) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} 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.35d-26)) then
tmp = ((b * (-2.0d0)) + (((a * 1.5d0) / b) * c)) / (a * 3.0d0)
else if (b <= 2d-108) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (a * 3.0d0)
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.35e-26) {
tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0);
} else if (b <= 2e-108) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.35e-26: tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0) elif b <= 2e-108: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.35e-26) tmp = Float64(Float64(Float64(b * -2.0) + Float64(Float64(Float64(a * 1.5) / b) * c)) / Float64(a * 3.0)); elseif (b <= 2e-108) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); 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.35e-26) tmp = ((b * -2.0) + (((a * 1.5) / b) * c)) / (a * 3.0); elseif (b <= 2e-108) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.35e-26], N[(N[(N[(b * -2.0), $MachinePrecision] + N[(N[(N[(a * 1.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-108], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.35 \cdot 10^{-26}:\\
\;\;\;\;\frac{b \cdot -2 + \frac{a \cdot 1.5}{b} \cdot c}{a \cdot 3}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-108}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.34999999999999995e-26Initial program 63.4%
sqr-neg63.4%
sqr-neg63.4%
associate-*l*63.4%
Simplified63.4%
Taylor expanded in b around -inf 87.2%
*-commutative87.2%
fma-def87.2%
associate-/l*91.6%
associate-*r/91.6%
Simplified91.6%
fma-udef91.6%
associate-/r/91.6%
*-commutative91.6%
Applied egg-rr91.6%
if -2.34999999999999995e-26 < b < 2.00000000000000008e-108Initial program 77.5%
sqr-neg77.5%
sqr-neg77.5%
associate-*l*77.3%
Simplified77.3%
Taylor expanded in b around 0 75.1%
associate-*r*75.3%
*-commutative75.3%
associate-*l*75.1%
Simplified75.1%
if 2.00000000000000008e-108 < b Initial program 22.6%
sqr-neg22.6%
sqr-neg22.6%
associate-*l*22.6%
Simplified22.6%
Taylor expanded in b around inf 83.9%
Final simplification84.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (- (* a (/ (* c -1.5) b)) (* b -2.0)) (* a -3.0)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((a * ((c * -1.5) / b)) - (b * -2.0)) / (a * -3.0);
} 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 <= (-5d-310)) then
tmp = ((a * ((c * (-1.5d0)) / b)) - (b * (-2.0d0))) / (a * (-3.0d0))
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 <= -5e-310) {
tmp = ((a * ((c * -1.5) / b)) - (b * -2.0)) / (a * -3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((a * ((c * -1.5) / b)) - (b * -2.0)) / (a * -3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(a * Float64(Float64(c * -1.5) / b)) - Float64(b * -2.0)) / Float64(a * -3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = ((a * ((c * -1.5) / b)) - (b * -2.0)) / (a * -3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(a * N[(N[(c * -1.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * -2.0), $MachinePrecision]), $MachinePrecision] / N[(a * -3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{a \cdot \frac{c \cdot -1.5}{b} - b \cdot -2}{a \cdot -3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 66.0%
sqr-neg66.0%
sqr-neg66.0%
associate-*l*66.0%
Simplified66.0%
Taylor expanded in b around -inf 64.2%
associate-*r/64.2%
Applied egg-rr64.2%
frac-2neg64.2%
div-inv64.1%
*-commutative64.1%
fma-def64.1%
*-un-lft-identity64.1%
times-frac64.1%
metadata-eval64.1%
associate-*r/67.2%
*-commutative67.2%
Applied egg-rr67.2%
associate-*r/67.2%
*-rgt-identity67.2%
neg-sub067.2%
fma-udef67.2%
*-commutative67.2%
associate-*r/64.2%
+-commutative64.2%
associate-*r/67.2%
*-commutative67.2%
associate--r+67.2%
neg-sub067.2%
distribute-lft-neg-in67.2%
metadata-eval67.2%
*-commutative67.2%
associate-*l*67.2%
associate-*l/67.2%
distribute-rgt-neg-in67.2%
metadata-eval67.2%
Simplified67.2%
if -4.999999999999985e-310 < b Initial program 39.1%
sqr-neg39.1%
sqr-neg39.1%
associate-*l*39.0%
Simplified39.0%
Taylor expanded in b around inf 65.9%
Final simplification66.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* (/ c b) 0.5) (* -0.6666666666666666 (/ b a))) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((c / b) * 0.5) + (-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 <= (-5d-310)) then
tmp = ((c / b) * 0.5d0) + ((-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 <= -5e-310) {
tmp = ((c / b) * 0.5) + (-0.6666666666666666 * (b / a));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((c / b) * 0.5) + (-0.6666666666666666 * (b / a)) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(c / b) * 0.5) + 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 <= -5e-310) tmp = ((c / b) * 0.5) + (-0.6666666666666666 * (b / a)); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5 + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 66.0%
sqr-neg66.0%
sqr-neg66.0%
associate-*l*66.0%
Simplified66.0%
Taylor expanded in b around -inf 67.2%
if -4.999999999999985e-310 < b Initial program 39.1%
sqr-neg39.1%
sqr-neg39.1%
associate-*l*39.0%
Simplified39.0%
Taylor expanded in b around inf 65.9%
Final simplification66.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (/ (* b -0.6666666666666666) a) (* (/ c b) 0.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.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 <= (-5d-310)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + ((c / b) * 0.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 <= -5e-310) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(Float64(c / b) * 0.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 <= -5e-310) tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 66.0%
sqr-neg66.0%
sqr-neg66.0%
associate-*l*66.0%
Simplified66.0%
Taylor expanded in b around -inf 67.2%
associate-*r/67.2%
Applied egg-rr67.2%
if -4.999999999999985e-310 < b Initial program 39.1%
sqr-neg39.1%
sqr-neg39.1%
associate-*l*39.0%
Simplified39.0%
Taylor expanded in b around inf 65.9%
Final simplification66.5%
(FPCore (a b c) :precision binary64 (if (<= b 9.2e-297) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 9.2e-297) {
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 <= 9.2d-297) 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 <= 9.2e-297) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 9.2e-297: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 9.2e-297) 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 <= 9.2e-297) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 9.2e-297], 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 9.2 \cdot 10^{-297}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 9.1999999999999996e-297Initial program 66.3%
sqr-neg66.3%
sqr-neg66.3%
associate-*l*66.2%
Simplified66.2%
Taylor expanded in b around -inf 66.4%
*-commutative66.4%
Simplified66.4%
if 9.1999999999999996e-297 < b Initial program 38.6%
sqr-neg38.6%
sqr-neg38.6%
associate-*l*38.5%
Simplified38.5%
Taylor expanded in b around inf 66.4%
Final simplification66.4%
(FPCore (a b c) :precision binary64 (if (<= b 5.5e-297) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.5e-297) {
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 <= 5.5d-297) 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 <= 5.5e-297) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.5e-297: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.5e-297) 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 <= 5.5e-297) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.5e-297], 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 5.5 \cdot 10^{-297}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 5.5000000000000003e-297Initial program 66.3%
sqr-neg66.3%
sqr-neg66.3%
associate-*l*66.2%
Simplified66.2%
Taylor expanded in b around -inf 66.4%
*-commutative66.4%
Simplified66.4%
associate-/r/66.4%
div-inv66.5%
metadata-eval66.5%
Applied egg-rr66.5%
if 5.5000000000000003e-297 < b Initial program 38.6%
sqr-neg38.6%
sqr-neg38.6%
associate-*l*38.5%
Simplified38.5%
Taylor expanded in b around inf 66.4%
Final simplification66.4%
(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 52.5%
sqr-neg52.5%
sqr-neg52.5%
associate-*l*52.4%
Simplified52.4%
Taylor expanded in b around inf 34.3%
Final simplification34.3%
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
return 0.0 / a;
}
def code(a, b, c): return 0.0 / a
function code(a, b, c) return Float64(0.0 / a) end
function tmp = code(a, b, c) tmp = 0.0 / a; end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 52.5%
sqr-neg52.5%
sqr-neg52.5%
associate-*l*52.4%
Simplified52.4%
Taylor expanded in b around 0 52.4%
*-commutative52.4%
unpow252.4%
fma-def52.4%
Simplified52.4%
div-inv52.4%
neg-mul-152.4%
fma-def52.4%
*-commutative52.4%
Applied egg-rr52.4%
Taylor expanded in a around 0 11.2%
associate-*r/11.2%
distribute-rgt1-in11.2%
metadata-eval11.2%
mul0-lft11.2%
metadata-eval11.2%
Simplified11.2%
Final simplification11.2%
herbie shell --seed 2023268
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))