
(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 10 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.5e+88)
(* (/ b a) -0.6666666666666666)
(if (<= b 1.8e-41)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e+88) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.8e-41) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * 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 <= (-5.5d+88)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 1.8d-41) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * 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 <= -5.5e+88) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.8e-41) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e+88: tmp = (b / a) * -0.6666666666666666 elif b <= 1.8e-41: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e+88) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 1.8e-41) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * 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 <= -5.5e+88) tmp = (b / a) * -0.6666666666666666; elseif (b <= 1.8e-41) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e+88], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 1.8e-41], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{+88}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-41}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.5e88Initial program 49.0%
Simplified49.0%
Taylor expanded in b around -inf 96.5%
*-commutative96.5%
Simplified96.5%
if -5.5e88 < b < 1.8e-41Initial program 79.5%
if 1.8e-41 < b Initial program 14.3%
Simplified14.3%
Taylor expanded in b around inf 89.0%
Final simplification86.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.1e-41) (* (- b (hypot b (sqrt (fabs (* (* 3.0 a) c))))) (/ 1.0 (* a -3.0))) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-41) {
tmp = (b - hypot(b, sqrt(fabs(((3.0 * a) * c))))) * (1.0 / (a * -3.0));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-41) {
tmp = (b - Math.hypot(b, Math.sqrt(Math.abs(((3.0 * a) * c))))) * (1.0 / (a * -3.0));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.1e-41: tmp = (b - math.hypot(b, math.sqrt(math.fabs(((3.0 * a) * c))))) * (1.0 / (a * -3.0)) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.1e-41) tmp = Float64(Float64(b - hypot(b, sqrt(abs(Float64(Float64(3.0 * a) * c))))) * Float64(1.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 <= 2.1e-41) tmp = (b - hypot(b, sqrt(abs(((3.0 * a) * c))))) * (1.0 / (a * -3.0)); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.1e-41], N[(N[(b - N[Sqrt[b ^ 2 + N[Sqrt[N[Abs[N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-41}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{\left|\left(3 \cdot a\right) \cdot c\right|}\right)\right) \cdot \frac{1}{a \cdot -3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.10000000000000013e-41Initial program 70.0%
Simplified69.9%
Applied egg-rr32.6%
add-sqr-sqrt32.6%
sqrt-unprod65.1%
pow265.1%
Applied egg-rr65.1%
unpow265.1%
rem-sqrt-square83.7%
associate-*r*83.7%
Simplified83.7%
if 2.10000000000000013e-41 < b Initial program 14.3%
Simplified14.3%
Taylor expanded in b around inf 89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e+89)
(* (/ b a) -0.6666666666666666)
(if (<= b 1.8e-41)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e+89) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.8e-41) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * 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 <= (-1.45d+89)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 1.8d-41) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (3.0d0 * 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 <= -1.45e+89) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.8e-41) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.45e+89: tmp = (b / a) * -0.6666666666666666 elif b <= 1.8e-41: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.45e+89) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 1.8e-41) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(3.0 * 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 <= -1.45e+89) tmp = (b / a) * -0.6666666666666666; elseif (b <= 1.8e-41) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.45e+89], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 1.8e-41], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{+89}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-41}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.45000000000000013e89Initial program 49.0%
Simplified49.0%
Taylor expanded in b around -inf 96.5%
*-commutative96.5%
Simplified96.5%
if -1.45000000000000013e89 < b < 1.8e-41Initial program 79.5%
sqr-neg79.5%
sqr-neg79.5%
associate-*l*79.4%
Simplified79.4%
if 1.8e-41 < b Initial program 14.3%
Simplified14.3%
Taylor expanded in b around inf 89.0%
Final simplification86.0%
(FPCore (a b c)
:precision binary64
(if (<= b -7e-58)
(* b (- (* 0.6666666666666666 (/ -1.0 a)) (* -0.5 (/ c (pow b 2.0)))))
(if (<= b 7.2e-87)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7e-58) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / pow(b, 2.0))));
} else if (b <= 7.2e-87) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * 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 <= (-7d-58)) then
tmp = b * ((0.6666666666666666d0 * ((-1.0d0) / a)) - ((-0.5d0) * (c / (b ** 2.0d0))))
else if (b <= 7.2d-87) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * 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 <= -7e-58) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / Math.pow(b, 2.0))));
} else if (b <= 7.2e-87) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7e-58: tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / math.pow(b, 2.0)))) elif b <= 7.2e-87: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7e-58) tmp = Float64(b * Float64(Float64(0.6666666666666666 * Float64(-1.0 / a)) - Float64(-0.5 * Float64(c / (b ^ 2.0))))); elseif (b <= 7.2e-87) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * 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 <= -7e-58) tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / (b ^ 2.0)))); elseif (b <= 7.2e-87) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7e-58], N[(b * N[(N[(0.6666666666666666 * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.2e-87], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7 \cdot 10^{-58}:\\
\;\;\;\;b \cdot \left(0.6666666666666666 \cdot \frac{-1}{a} - -0.5 \cdot \frac{c}{{b}^{2}}\right)\\
\mathbf{elif}\;b \leq 7.2 \cdot 10^{-87}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -6.9999999999999998e-58Initial program 66.7%
Simplified66.7%
Taylor expanded in b around -inf 85.7%
if -6.9999999999999998e-58 < b < 7.19999999999999986e-87Initial program 78.0%
Simplified78.0%
Taylor expanded in b around 0 72.5%
associate-*r*72.7%
*-commutative72.7%
Simplified72.7%
if 7.19999999999999986e-87 < b Initial program 18.1%
Simplified18.1%
Taylor expanded in b around inf 83.3%
Final simplification81.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.65e-53)
(* (/ b a) -0.6666666666666666)
(if (<= b 7.5e-87)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.65e-53) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 7.5e-87) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * 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 <= (-1.65d-53)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 7.5d-87) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * 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 <= -1.65e-53) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 7.5e-87) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.65e-53: tmp = (b / a) * -0.6666666666666666 elif b <= 7.5e-87: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.65e-53) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 7.5e-87) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * 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 <= -1.65e-53) tmp = (b / a) * -0.6666666666666666; elseif (b <= 7.5e-87) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.65e-53], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 7.5e-87], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65 \cdot 10^{-53}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-87}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.65000000000000002e-53Initial program 66.7%
Simplified66.7%
Taylor expanded in b around -inf 85.6%
*-commutative85.6%
Simplified85.6%
if -1.65000000000000002e-53 < b < 7.5000000000000002e-87Initial program 78.0%
Simplified78.0%
Taylor expanded in b around 0 72.5%
associate-*r*72.7%
*-commutative72.7%
Simplified72.7%
if 7.5000000000000002e-87 < b Initial program 18.1%
Simplified18.1%
Taylor expanded in b around inf 83.3%
Final simplification81.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5.7e-61)
(* (/ b a) -0.6666666666666666)
(if (<= b 7.3e-87)
(/ (- (sqrt (* -3.0 (* a c))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.7e-61) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 7.3e-87) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (3.0 * 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 <= (-5.7d-61)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 7.3d-87) then
tmp = (sqrt(((-3.0d0) * (a * c))) - b) / (3.0d0 * 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 <= -5.7e-61) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 7.3e-87) {
tmp = (Math.sqrt((-3.0 * (a * c))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.7e-61: tmp = (b / a) * -0.6666666666666666 elif b <= 7.3e-87: tmp = (math.sqrt((-3.0 * (a * c))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.7e-61) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 7.3e-87) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / Float64(3.0 * 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 <= -5.7e-61) tmp = (b / a) * -0.6666666666666666; elseif (b <= 7.3e-87) tmp = (sqrt((-3.0 * (a * c))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.7e-61], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 7.3e-87], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.7 \cdot 10^{-61}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 7.3 \cdot 10^{-87}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.70000000000000005e-61Initial program 66.7%
Simplified66.7%
Taylor expanded in b around -inf 85.6%
*-commutative85.6%
Simplified85.6%
if -5.70000000000000005e-61 < b < 7.29999999999999967e-87Initial program 78.0%
Simplified78.0%
Taylor expanded in b around 0 72.5%
if 7.29999999999999967e-87 < b Initial program 18.1%
Simplified18.1%
Taylor expanded in b around inf 83.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.1e-148)
(* (/ b a) -0.6666666666666666)
(if (<= b 8.4e-107)
(* (sqrt (/ (* c -3.0) a)) (- -0.3333333333333333))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-148) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 8.4e-107) {
tmp = sqrt(((c * -3.0) / 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 <= (-1.1d-148)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 8.4d-107) then
tmp = sqrt(((c * (-3.0d0)) / 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 <= -1.1e-148) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 8.4e-107) {
tmp = Math.sqrt(((c * -3.0) / a)) * -(-0.3333333333333333);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.1e-148: tmp = (b / a) * -0.6666666666666666 elif b <= 8.4e-107: tmp = math.sqrt(((c * -3.0) / a)) * -(-0.3333333333333333) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.1e-148) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 8.4e-107) tmp = Float64(sqrt(Float64(Float64(c * -3.0) / a)) * Float64(-(-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 <= -1.1e-148) tmp = (b / a) * -0.6666666666666666; elseif (b <= 8.4e-107) tmp = sqrt(((c * -3.0) / a)) * -(-0.3333333333333333); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.1e-148], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 8.4e-107], N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision] * (--0.3333333333333333)), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.1 \cdot 10^{-148}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 8.4 \cdot 10^{-107}:\\
\;\;\;\;\sqrt{\frac{c \cdot -3}{a}} \cdot \left(--0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.10000000000000009e-148Initial program 70.3%
Simplified70.3%
Taylor expanded in b around -inf 80.1%
*-commutative80.1%
Simplified80.1%
if -1.10000000000000009e-148 < b < 8.3999999999999997e-107Initial program 74.2%
add-cube-cbrt73.5%
pow373.6%
Applied egg-rr73.6%
Taylor expanded in a around -inf 0.0%
rem-cube-cbrt0.0%
unpow20.0%
rem-square-sqrt37.6%
Simplified37.6%
if 8.3999999999999997e-107 < b Initial program 19.8%
Simplified19.8%
Taylor expanded in b around inf 81.8%
Final simplification71.1%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
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 <= (-1d-310)) 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 <= -1e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) 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 <= -1e-310) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], 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 -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 70.8%
Simplified70.8%
Taylor expanded in b around -inf 66.9%
*-commutative66.9%
Simplified66.9%
if -9.999999999999969e-311 < b Initial program 34.8%
Simplified34.8%
Taylor expanded in b around inf 64.2%
(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.2%
Simplified53.2%
Taylor expanded in b around inf 32.4%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
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
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 53.2%
Simplified53.2%
Taylor expanded in b around inf 32.4%
expm1-log1p-u29.2%
expm1-undefine12.5%
Applied egg-rr12.5%
Taylor expanded in c around 0 9.3%
metadata-eval9.3%
Applied egg-rr9.3%
herbie shell --seed 2024150
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))