
(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 -5e+140)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.25e-84)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+140) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.25e-84) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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+140)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.25d-84) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+140) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.25e-84) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+140: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.25e-84: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+140) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.25e-84) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+140) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.25e-84) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+140], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.25e-84], 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[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+140}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-84}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.00000000000000008e140Initial program 38.7%
sqr-neg38.7%
sqr-neg38.7%
associate-*l*38.7%
Simplified38.7%
Taylor expanded in b around -inf 95.1%
if -5.00000000000000008e140 < b < 1.25e-84Initial program 79.0%
if 1.25e-84 < b Initial program 18.9%
sqr-neg18.9%
sqr-neg18.9%
associate-*l*18.9%
Simplified18.9%
Taylor expanded in b around inf 88.7%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e+140)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.5e-79)
(/ (- (sqrt (- (* b b) (* a (* c 3.0)))) b) (/ a 0.3333333333333333))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e+140) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.5e-79) {
tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333);
} else {
tmp = (c / b) * -0.5;
}
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+140)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.5d-79) then
tmp = (sqrt(((b * b) - (a * (c * 3.0d0)))) - b) / (a / 0.3333333333333333d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e+140) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.5e-79) {
tmp = (Math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e+140: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.5e-79: tmp = (math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e+140) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.5e-79) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 3.0)))) - b) / Float64(a / 0.3333333333333333)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.15e+140) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.5e-79) tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a / 0.3333333333333333); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e+140], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-79], 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[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{+140}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-79}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{\frac{a}{0.3333333333333333}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.14999999999999995e140Initial program 38.7%
sqr-neg38.7%
sqr-neg38.7%
associate-*l*38.7%
Simplified38.7%
Taylor expanded in b around -inf 95.1%
if -1.14999999999999995e140 < b < 1.5e-79Initial program 79.0%
neg-sub079.0%
sqr-neg79.0%
associate-+l-79.0%
sub0-neg79.0%
neg-mul-179.0%
Simplified78.7%
associate-*r*78.8%
metadata-eval78.8%
distribute-rgt-neg-in78.8%
*-commutative78.8%
fma-neg78.8%
associate-*r*78.8%
*-commutative78.8%
associate-*l*78.7%
Applied egg-rr78.7%
*-commutative78.7%
Simplified78.7%
if 1.5e-79 < b Initial program 18.9%
sqr-neg18.9%
sqr-neg18.9%
associate-*l*18.9%
Simplified18.9%
Taylor expanded in b around inf 88.7%
Final simplification86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+144)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 5.5e-82)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+144) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 5.5e-82) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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+144)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 5.5d-82) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+144) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 5.5e-82) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+144: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 5.5e-82: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+144) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 5.5e-82) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+144) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 5.5e-82) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+144], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.5e-82], 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 / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+144}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-82}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.9999999999999999e144Initial program 38.7%
sqr-neg38.7%
sqr-neg38.7%
associate-*l*38.7%
Simplified38.7%
Taylor expanded in b around -inf 95.1%
if -4.9999999999999999e144 < b < 5.4999999999999998e-82Initial program 79.0%
sqr-neg79.0%
sqr-neg79.0%
associate-*l*78.9%
Simplified78.9%
if 5.4999999999999998e-82 < b Initial program 18.9%
sqr-neg18.9%
sqr-neg18.9%
associate-*l*18.9%
Simplified18.9%
Taylor expanded in b around inf 88.7%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.85e-34)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.2e-83)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.85e-34) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.2e-83) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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.85d-34)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.2d-83) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.85e-34) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.2e-83) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.85e-34: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.2e-83: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.85e-34) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.2e-83) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.85e-34) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.2e-83) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.85e-34], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.2e-83], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.85 \cdot 10^{-34}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-83}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.84999999999999994e-34Initial program 58.3%
sqr-neg58.3%
sqr-neg58.3%
associate-*l*58.3%
Simplified58.3%
Taylor expanded in b around -inf 90.9%
if -1.84999999999999994e-34 < b < 1.2e-83Initial program 72.6%
sqr-neg72.6%
sqr-neg72.6%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around 0 61.3%
associate-*r*61.4%
*-commutative61.4%
associate-*l*61.3%
Simplified61.3%
if 1.2e-83 < b Initial program 18.9%
sqr-neg18.9%
sqr-neg18.9%
associate-*l*18.9%
Simplified18.9%
Taylor expanded in b around inf 88.7%
Final simplification82.3%
(FPCore (a b c)
:precision binary64
(if (<= b -8.8e-33)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 7e-87)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.8e-33) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 7e-87) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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 <= (-8.8d-33)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 7d-87) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.8e-33) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 7e-87) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.8e-33: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 7e-87: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.8e-33) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 7e-87) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.8e-33) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 7e-87) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.8e-33], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7e-87], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.8 \cdot 10^{-33}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-87}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -8.80000000000000022e-33Initial program 58.3%
sqr-neg58.3%
sqr-neg58.3%
associate-*l*58.3%
Simplified58.3%
Taylor expanded in b around -inf 90.9%
if -8.80000000000000022e-33 < b < 7.00000000000000023e-87Initial program 72.6%
sqr-neg72.6%
sqr-neg72.6%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around 0 61.3%
*-commutative61.3%
Simplified61.3%
if 7.00000000000000023e-87 < b Initial program 18.9%
sqr-neg18.9%
sqr-neg18.9%
associate-*l*18.9%
Simplified18.9%
Taylor expanded in b around inf 88.7%
Final simplification82.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 62.6%
sqr-neg62.6%
sqr-neg62.6%
associate-*l*62.6%
Simplified62.6%
Taylor expanded in b around -inf 73.7%
if -4.999999999999985e-310 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*30.9%
Simplified30.9%
Taylor expanded in b around inf 72.7%
Final simplification73.2%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* b -2.0) (* a 3.0)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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 * (-2.0d0)) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * -2.0) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b * -2.0) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b * -2.0) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 62.6%
sqr-neg62.6%
sqr-neg62.6%
associate-*l*62.6%
Simplified62.6%
Taylor expanded in b around -inf 73.0%
*-commutative73.0%
Simplified73.0%
if -4.999999999999985e-310 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*30.9%
Simplified30.9%
Taylor expanded in b around inf 72.7%
Final simplification72.9%
(FPCore (a b c) :precision binary64 (if (<= b 6e-309) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
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-309) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6e-309: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6e-309) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6e-309) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6e-309], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6 \cdot 10^{-309}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 6.000000000000001e-309Initial program 62.6%
sqr-neg62.6%
sqr-neg62.6%
associate-*l*62.6%
Simplified62.6%
Taylor expanded in b around -inf 73.0%
*-commutative73.0%
Simplified73.0%
if 6.000000000000001e-309 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*30.9%
Simplified30.9%
Taylor expanded in b around inf 72.7%
Final simplification72.9%
(FPCore (a b c) :precision binary64 (* (/ c b) -0.5))
double code(double a, double b, double c) {
return (c / b) * -0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * (-0.5d0)
end function
public static double code(double a, double b, double c) {
return (c / b) * -0.5;
}
def code(a, b, c): return (c / b) * -0.5
function code(a, b, c) return Float64(Float64(c / b) * -0.5) end
function tmp = code(a, b, c) tmp = (c / b) * -0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot -0.5
\end{array}
Initial program 47.4%
sqr-neg47.4%
sqr-neg47.4%
associate-*l*47.4%
Simplified47.4%
Taylor expanded in b around inf 36.2%
Final simplification36.2%
herbie shell --seed 2023278
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))