
(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 9 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+103)
(* (/ b a) -0.6666666666666666)
(if (<= b 7.3)
(/ (- (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 <= -5.8e+103) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 7.3) {
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 <= (-5.8d+103)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 7.3d0) 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 <= -5.8e+103) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 7.3) {
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 <= -5.8e+103: tmp = (b / a) * -0.6666666666666666 elif b <= 7.3: 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 <= -5.8e+103) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 7.3) 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 <= -5.8e+103) tmp = (b / a) * -0.6666666666666666; elseif (b <= 7.3) 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, -5.8e+103], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 7.3], 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.8 \cdot 10^{+103}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 7.3:\\
\;\;\;\;\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 < -5.7999999999999997e103Initial program 58.9%
sqr-neg58.9%
sqr-neg58.9%
associate-*l*58.9%
Simplified58.9%
Taylor expanded in b around -inf 99.7%
*-commutative99.7%
Simplified99.7%
if -5.7999999999999997e103 < b < 7.29999999999999982Initial program 81.4%
sqr-neg81.4%
sqr-neg81.4%
associate-*l*81.5%
Simplified81.5%
if 7.29999999999999982 < b Initial program 8.5%
sqr-neg8.5%
sqr-neg8.5%
associate-*l*8.5%
Simplified8.5%
Taylor expanded in b around inf 94.3%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -4.1e+132)
(/ (* b -2.0) (* a 3.0))
(if (<= b 7.3)
(* (/ (- (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 <= -4.1e+132) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 7.3) {
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 <= (-4.1d+132)) then
tmp = (b * (-2.0d0)) / (a * 3.0d0)
else if (b <= 7.3d0) 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 <= -4.1e+132) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 7.3) {
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 <= -4.1e+132: tmp = (b * -2.0) / (a * 3.0) elif b <= 7.3: 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 <= -4.1e+132) tmp = Float64(Float64(b * -2.0) / Float64(a * 3.0)); elseif (b <= 7.3) tmp = Float64(Float64(Float64(sqrt(Float64(Float64(b * b) + Float64(Float64(a * c) * -3.0))) - b) / a) * 0.3333333333333333); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.1e+132) tmp = (b * -2.0) / (a * 3.0); elseif (b <= 7.3) 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, -4.1e+132], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.3], N[(N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.1 \cdot 10^{+132}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{elif}\;b \leq 7.3:\\
\;\;\;\;\frac{\sqrt{b \cdot b + \left(a \cdot c\right) \cdot -3} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.09999999999999992e132Initial program 52.2%
sqr-neg52.2%
sqr-neg52.2%
associate-*l*52.2%
Simplified52.2%
Taylor expanded in b around -inf 99.8%
*-commutative99.8%
Simplified99.8%
if -4.09999999999999992e132 < b < 7.29999999999999982Initial program 82.4%
neg-sub082.4%
sqr-neg82.4%
associate-+l-82.4%
sub0-neg82.4%
neg-mul-182.4%
Simplified82.3%
associate-*r*82.3%
metadata-eval82.3%
distribute-rgt-neg-in82.3%
*-commutative82.3%
fma-neg82.3%
Applied egg-rr82.3%
associate-/r/82.3%
cancel-sign-sub-inv82.3%
metadata-eval82.3%
Applied egg-rr82.3%
if 7.29999999999999982 < b Initial program 8.5%
sqr-neg8.5%
sqr-neg8.5%
associate-*l*8.5%
Simplified8.5%
Taylor expanded in b around inf 94.3%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -5.8e-12)
(+ (* (/ b a) -0.6666666666666666) (* (/ c b) 0.5))
(if (<= b 185.0)
(* (/ 0.3333333333333333 a) (- (sqrt (* c (* a -3.0))) b))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.8e-12) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 185.0) {
tmp = (0.3333333333333333 / a) * (sqrt((c * (a * -3.0))) - 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 <= (-5.8d-12)) then
tmp = ((b / a) * (-0.6666666666666666d0)) + ((c / b) * 0.5d0)
else if (b <= 185.0d0) then
tmp = (0.3333333333333333d0 / a) * (sqrt((c * (a * (-3.0d0)))) - 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 <= -5.8e-12) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 185.0) {
tmp = (0.3333333333333333 / a) * (Math.sqrt((c * (a * -3.0))) - b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.8e-12: tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5) elif b <= 185.0: tmp = (0.3333333333333333 / a) * (math.sqrt((c * (a * -3.0))) - b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.8e-12) tmp = Float64(Float64(Float64(b / a) * -0.6666666666666666) + Float64(Float64(c / b) * 0.5)); elseif (b <= 185.0) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(c * Float64(a * -3.0))) - 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 <= -5.8e-12) tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5); elseif (b <= 185.0) tmp = (0.3333333333333333 / a) * (sqrt((c * (a * -3.0))) - b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.8e-12], N[(N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 185.0], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.8 \cdot 10^{-12}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 185:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{c \cdot \left(a \cdot -3\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.8000000000000003e-12Initial program 69.6%
sqr-neg69.6%
sqr-neg69.6%
associate-*l*69.6%
Simplified69.6%
Taylor expanded in b around -inf 94.6%
if -5.8000000000000003e-12 < b < 185Initial program 79.1%
neg-sub079.1%
sqr-neg79.1%
associate-+l-79.1%
sub0-neg79.1%
neg-mul-179.1%
Simplified78.9%
associate-*r*78.9%
metadata-eval78.9%
distribute-rgt-neg-in78.9%
*-commutative78.9%
fma-neg78.9%
Applied egg-rr78.9%
Taylor expanded in b around 0 69.7%
associate-*r*69.7%
*-commutative69.7%
associate-*l*69.7%
Simplified69.7%
div-sub69.7%
div-inv69.9%
metadata-eval69.9%
div-inv69.9%
metadata-eval69.9%
Applied egg-rr69.9%
div-sub69.9%
*-lft-identity69.9%
associate-*l/69.7%
*-commutative69.7%
associate-/r*69.8%
metadata-eval69.8%
associate-*r*69.7%
*-commutative69.7%
associate-*r*69.7%
*-commutative69.7%
*-commutative69.7%
associate-*l*69.7%
Simplified69.7%
if 185 < b Initial program 8.5%
sqr-neg8.5%
sqr-neg8.5%
associate-*l*8.5%
Simplified8.5%
Taylor expanded in b around inf 94.3%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -2.1e-91)
(+ (* (/ b a) -0.6666666666666666) (* (/ c b) 0.5))
(if (<= b 7.3)
(* 0.3333333333333333 (/ (- (sqrt (* a (* c -3.0))) b) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.1e-91) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 7.3) {
tmp = 0.3333333333333333 * ((sqrt((a * (c * -3.0))) - 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 <= (-2.1d-91)) then
tmp = ((b / a) * (-0.6666666666666666d0)) + ((c / b) * 0.5d0)
else if (b <= 7.3d0) then
tmp = 0.3333333333333333d0 * ((sqrt((a * (c * (-3.0d0)))) - 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 <= -2.1e-91) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 7.3) {
tmp = 0.3333333333333333 * ((Math.sqrt((a * (c * -3.0))) - b) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.1e-91: tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5) elif b <= 7.3: tmp = 0.3333333333333333 * ((math.sqrt((a * (c * -3.0))) - b) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.1e-91) tmp = Float64(Float64(Float64(b / a) * -0.6666666666666666) + Float64(Float64(c / b) * 0.5)); elseif (b <= 7.3) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - 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 <= -2.1e-91) tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5); elseif (b <= 7.3) tmp = 0.3333333333333333 * ((sqrt((a * (c * -3.0))) - b) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.1e-91], N[(N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.3], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.1 \cdot 10^{-91}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 7.3:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.0999999999999999e-91Initial program 70.7%
sqr-neg70.7%
sqr-neg70.7%
associate-*l*70.7%
Simplified70.7%
Taylor expanded in b around -inf 86.6%
if -2.0999999999999999e-91 < b < 7.29999999999999982Initial program 79.5%
neg-sub079.5%
sqr-neg79.5%
associate-+l-79.5%
sub0-neg79.5%
neg-mul-179.5%
Simplified79.2%
associate-*r*79.2%
metadata-eval79.2%
distribute-rgt-neg-in79.2%
*-commutative79.2%
fma-neg79.2%
Applied egg-rr79.2%
Taylor expanded in b around 0 73.9%
associate-*r*73.9%
*-commutative73.9%
associate-*l*73.9%
Simplified73.9%
associate-/r/74.1%
Applied egg-rr74.1%
if 7.29999999999999982 < b Initial program 8.5%
sqr-neg8.5%
sqr-neg8.5%
associate-*l*8.5%
Simplified8.5%
Taylor expanded in b around inf 94.3%
Final simplification84.8%
(FPCore (a b c)
:precision binary64
(if (<= b -6.6e-12)
(+ (* (/ b a) -0.6666666666666666) (* (/ c b) 0.5))
(if (<= b 9.0)
(/ (- (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 <= -6.6e-12) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 9.0) {
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 <= (-6.6d-12)) then
tmp = ((b / a) * (-0.6666666666666666d0)) + ((c / b) * 0.5d0)
else if (b <= 9.0d0) 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 <= -6.6e-12) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 9.0) {
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 <= -6.6e-12: tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5) elif b <= 9.0: 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 <= -6.6e-12) tmp = Float64(Float64(Float64(b / a) * -0.6666666666666666) + Float64(Float64(c / b) * 0.5)); elseif (b <= 9.0) tmp = Float64(Float64(sqrt(Float64(Float64(a * 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 <= -6.6e-12) tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5); elseif (b <= 9.0) 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, -6.6e-12], N[(N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.0], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $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 -6.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 9:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -6.6000000000000001e-12Initial program 69.6%
sqr-neg69.6%
sqr-neg69.6%
associate-*l*69.6%
Simplified69.6%
Taylor expanded in b around -inf 94.6%
if -6.6000000000000001e-12 < b < 9Initial program 79.1%
sqr-neg79.1%
sqr-neg79.1%
associate-*l*79.1%
Simplified79.1%
Taylor expanded in b around 0 69.9%
*-commutative69.9%
Simplified69.9%
if 9 < b Initial program 8.5%
sqr-neg8.5%
sqr-neg8.5%
associate-*l*8.5%
Simplified8.5%
Taylor expanded in b around inf 94.3%
Final simplification84.8%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* (/ b a) -0.6666666666666666) (* (/ c b) 0.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((b / a) * -0.6666666666666666) + ((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 / a) * (-0.6666666666666666d0)) + ((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 / a) * -0.6666666666666666) + ((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 / a) * -0.6666666666666666) + ((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 / a) * -0.6666666666666666) + 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 / a) * -0.6666666666666666) + ((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 / a), $MachinePrecision] * -0.6666666666666666), $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}{a} \cdot -0.6666666666666666 + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 75.2%
sqr-neg75.2%
sqr-neg75.2%
associate-*l*75.2%
Simplified75.2%
Taylor expanded in b around -inf 66.9%
if -4.999999999999985e-310 < b Initial program 34.6%
sqr-neg34.6%
sqr-neg34.6%
associate-*l*34.6%
Simplified34.6%
Taylor expanded in b around inf 65.7%
Final simplification66.3%
(FPCore (a b c) :precision binary64 (if (<= b 3.4e-304) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.4e-304) {
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.4d-304) 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.4e-304) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.4e-304: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.4e-304) tmp = Float64(Float64(b / 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.4e-304) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.4e-304], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.4 \cdot 10^{-304}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.3999999999999999e-304Initial program 75.4%
sqr-neg75.4%
sqr-neg75.4%
associate-*l*75.4%
Simplified75.4%
Taylor expanded in b around -inf 66.0%
*-commutative66.0%
Simplified66.0%
if 3.3999999999999999e-304 < b Initial program 34.1%
sqr-neg34.1%
sqr-neg34.1%
associate-*l*34.1%
Simplified34.1%
Taylor expanded in b around inf 66.2%
Final simplification66.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.85e-304) (/ (* b -0.6666666666666666) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.85e-304) {
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.85d-304) 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.85e-304) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.85e-304: tmp = (b * -0.6666666666666666) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.85e-304) tmp = Float64(Float64(b * -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.85e-304) tmp = (b * -0.6666666666666666) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.85e-304], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.85 \cdot 10^{-304}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.8499999999999999e-304Initial program 75.4%
neg-sub075.4%
sqr-neg75.4%
associate-+l-75.4%
sub0-neg75.4%
neg-mul-175.4%
Simplified75.3%
associate-*r*75.3%
metadata-eval75.3%
distribute-rgt-neg-in75.3%
*-commutative75.3%
fma-neg75.3%
Applied egg-rr75.3%
Taylor expanded in b around -inf 66.0%
associate-*r/66.1%
*-commutative66.1%
Simplified66.1%
if 2.8499999999999999e-304 < b Initial program 34.1%
sqr-neg34.1%
sqr-neg34.1%
associate-*l*34.1%
Simplified34.1%
Taylor expanded in b around inf 66.2%
Final simplification66.1%
(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 53.8%
sqr-neg53.8%
sqr-neg53.8%
associate-*l*53.8%
Simplified53.8%
Taylor expanded in b around inf 35.7%
Final simplification35.7%
herbie shell --seed 2023293
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))