
(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 8 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 -4e+154)
(* b (/ -0.6666666666666666 a))
(if (<= b 8.5e-119)
(/ (- (sqrt (fma b b (* a (* c -3.0)))) b) (* a 3.0))
(if (or (<= b 6.5e-61) (not (<= b 2.9e-34)))
(* -0.5 (/ c b))
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+154) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 8.5e-119) {
tmp = (sqrt(fma(b, b, (a * (c * -3.0)))) - b) / (a * 3.0);
} else if ((b <= 6.5e-61) || !(b <= 2.9e-34)) {
tmp = -0.5 * (c / b);
} else {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+154) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 8.5e-119) tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -3.0)))) - b) / Float64(a * 3.0)); elseif ((b <= 6.5e-61) || !(b <= 2.9e-34)) tmp = Float64(-0.5 * Float64(c / b)); else tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+154], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-119], N[(N[(N[Sqrt[N[(b * b + N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 6.5e-61], N[Not[LessEqual[b, 2.9e-34]], $MachinePrecision]], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+154}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-119}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-61} \lor \neg \left(b \leq 2.9 \cdot 10^{-34}\right):\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\end{array}
\end{array}
if b < -4.00000000000000015e154Initial program 41.2%
Taylor expanded in b around -inf 99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in b around 0 99.5%
associate-*r/99.7%
associate-*l/99.8%
Simplified99.8%
if -4.00000000000000015e154 < b < 8.49999999999999977e-119Initial program 82.7%
+-commutative82.7%
sqr-neg82.7%
unsub-neg82.7%
div-sub82.8%
--rgt-identity82.8%
div-sub82.7%
Simplified82.8%
if 8.49999999999999977e-119 < b < 6.4999999999999994e-61 or 2.9000000000000002e-34 < b Initial program 17.4%
Taylor expanded in b around inf 86.6%
if 6.4999999999999994e-61 < b < 2.9000000000000002e-34Initial program 85.9%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4e+154)
(* b (/ -0.6666666666666666 a))
(if (or (<= b 8.5e-119) (and (not (<= b 5.5e-61)) (<= b 3.9e-34)))
(/ (- (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 <= -4e+154) {
tmp = b * (-0.6666666666666666 / a);
} else if ((b <= 8.5e-119) || (!(b <= 5.5e-61) && (b <= 3.9e-34))) {
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 <= (-4d+154)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if ((b <= 8.5d-119) .or. (.not. (b <= 5.5d-61)) .and. (b <= 3.9d-34)) 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 <= -4e+154) {
tmp = b * (-0.6666666666666666 / a);
} else if ((b <= 8.5e-119) || (!(b <= 5.5e-61) && (b <= 3.9e-34))) {
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 <= -4e+154: tmp = b * (-0.6666666666666666 / a) elif (b <= 8.5e-119) or (not (b <= 5.5e-61) and (b <= 3.9e-34)): 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 <= -4e+154) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif ((b <= 8.5e-119) || (!(b <= 5.5e-61) && (b <= 3.9e-34))) 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 <= -4e+154) tmp = b * (-0.6666666666666666 / a); elseif ((b <= 8.5e-119) || (~((b <= 5.5e-61)) && (b <= 3.9e-34))) 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, -4e+154], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 8.5e-119], And[N[Not[LessEqual[b, 5.5e-61]], $MachinePrecision], LessEqual[b, 3.9e-34]]], 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 \cdot 10^{+154}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-119} \lor \neg \left(b \leq 5.5 \cdot 10^{-61}\right) \land b \leq 3.9 \cdot 10^{-34}:\\
\;\;\;\;\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.00000000000000015e154Initial program 41.2%
Taylor expanded in b around -inf 99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in b around 0 99.5%
associate-*r/99.7%
associate-*l/99.8%
Simplified99.8%
if -4.00000000000000015e154 < b < 8.49999999999999977e-119 or 5.4999999999999997e-61 < b < 3.89999999999999991e-34Initial program 82.9%
if 8.49999999999999977e-119 < b < 5.4999999999999997e-61 or 3.89999999999999991e-34 < b Initial program 17.4%
Taylor expanded in b around inf 86.6%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -2.4e-95)
(* b (/ -0.6666666666666666 a))
(if (<= b 8.5e-119)
(* 0.3333333333333333 (/ (+ b (sqrt (* a (* c -3.0)))) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.4e-95) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 8.5e-119) {
tmp = 0.3333333333333333 * ((b + sqrt((a * (c * -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 <= (-2.4d-95)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 8.5d-119) then
tmp = 0.3333333333333333d0 * ((b + sqrt((a * (c * (-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 <= -2.4e-95) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 8.5e-119) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((a * (c * -3.0)))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.4e-95: tmp = b * (-0.6666666666666666 / a) elif b <= 8.5e-119: tmp = 0.3333333333333333 * ((b + math.sqrt((a * (c * -3.0)))) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.4e-95) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 8.5e-119) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(a * Float64(c * -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 <= -2.4e-95) tmp = b * (-0.6666666666666666 / a); elseif (b <= 8.5e-119) tmp = 0.3333333333333333 * ((b + sqrt((a * (c * -3.0)))) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.4e-95], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-119], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.4 \cdot 10^{-95}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-119}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.4e-95Initial program 68.2%
Taylor expanded in b around -inf 86.2%
*-commutative86.2%
Simplified86.2%
Taylor expanded in b around 0 86.2%
associate-*r/86.3%
associate-*l/86.4%
Simplified86.4%
if -2.4e-95 < b < 8.49999999999999977e-119Initial program 74.6%
Taylor expanded in b around 0 72.9%
*-un-lft-identity72.9%
times-frac73.0%
metadata-eval73.0%
add-sqr-sqrt42.1%
sqrt-unprod72.4%
sqr-neg72.4%
sqrt-unprod31.5%
add-sqr-sqrt72.7%
*-commutative72.7%
associate-*r*72.7%
Applied egg-rr72.7%
if 8.49999999999999977e-119 < b Initial program 22.1%
Taylor expanded in b around inf 82.3%
Final simplification81.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e-81)
(* b (/ -0.6666666666666666 a))
(if (<= b 3.6e-119)
(/ (- (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 <= -1.15e-81) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 3.6e-119) {
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 <= (-1.15d-81)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 3.6d-119) 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 <= -1.15e-81) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 3.6e-119) {
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 <= -1.15e-81: tmp = b * (-0.6666666666666666 / a) elif b <= 3.6e-119: 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 <= -1.15e-81) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 3.6e-119) 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 <= -1.15e-81) tmp = b * (-0.6666666666666666 / a); elseif (b <= 3.6e-119) 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, -1.15e-81], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.6e-119], 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 -1.15 \cdot 10^{-81}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{-119}:\\
\;\;\;\;\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 < -1.14999999999999996e-81Initial program 67.5%
Taylor expanded in b around -inf 86.9%
*-commutative86.9%
Simplified86.9%
Taylor expanded in b around 0 86.9%
associate-*r/87.1%
associate-*l/87.1%
Simplified87.1%
if -1.14999999999999996e-81 < b < 3.6e-119Initial program 75.4%
Taylor expanded in b around 0 72.5%
+-commutative72.5%
unsub-neg72.5%
*-commutative72.5%
associate-*r*72.4%
Applied egg-rr72.4%
if 3.6e-119 < b Initial program 22.1%
Taylor expanded in b around inf 82.3%
Final simplification81.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.2e-81)
(* b (/ -0.6666666666666666 a))
(if (<= b 8e-121)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.2e-81) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 8e-121) {
tmp = (sqrt((-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 <= (-1.2d-81)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 8d-121) then
tmp = (sqrt(((-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 <= -1.2e-81) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 8e-121) {
tmp = (Math.sqrt((-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 <= -1.2e-81: tmp = b * (-0.6666666666666666 / a) elif b <= 8e-121: tmp = (math.sqrt((-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 <= -1.2e-81) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 8e-121) tmp = Float64(Float64(sqrt(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 <= -1.2e-81) tmp = b * (-0.6666666666666666 / a); elseif (b <= 8e-121) tmp = (sqrt((-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, -1.2e-81], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-121], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $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 -1.2 \cdot 10^{-81}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-121}:\\
\;\;\;\;\frac{\sqrt{-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 < -1.2e-81Initial program 67.5%
Taylor expanded in b around -inf 86.9%
*-commutative86.9%
Simplified86.9%
Taylor expanded in b around 0 86.9%
associate-*r/87.1%
associate-*l/87.1%
Simplified87.1%
if -1.2e-81 < b < 7.9999999999999998e-121Initial program 75.4%
Taylor expanded in b around 0 72.5%
if 7.9999999999999998e-121 < b Initial program 22.1%
Taylor expanded in b around inf 82.3%
Final simplification81.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 71.9%
Taylor expanded in b around -inf 65.2%
associate-*r/65.4%
Applied egg-rr65.4%
if -4.999999999999985e-310 < b Initial program 31.7%
Taylor expanded in b around inf 67.1%
Final simplification66.3%
(FPCore (a b c) :precision binary64 (if (<= b 6.5e-299) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e-299) {
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 <= 6.5d-299) 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 <= 6.5e-299) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.5e-299: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.5e-299) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.5e-299) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.5e-299], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5 \cdot 10^{-299}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.4999999999999997e-299Initial program 70.8%
Taylor expanded in b around -inf 64.1%
*-commutative64.1%
Simplified64.1%
Taylor expanded in b around 0 64.1%
associate-*r/64.2%
associate-*l/64.3%
Simplified64.3%
if 6.4999999999999997e-299 < b Initial program 32.2%
Taylor expanded in b around inf 68.1%
Final simplification66.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 51.2%
Taylor expanded in b around inf 35.7%
Final simplification35.7%
herbie shell --seed 2023332
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))