
(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 12 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 -1.76e+99)
(/ 1.0 (* (/ a b) -1.5))
(if (<= b 1.6e-37)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.76e+99) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 1.6e-37) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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.76d+99)) then
tmp = 1.0d0 / ((a / b) * (-1.5d0))
else if (b <= 1.6d-37) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.76e+99) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 1.6e-37) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.76e+99: tmp = 1.0 / ((a / b) * -1.5) elif b <= 1.6e-37: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.76e+99) tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5)); elseif (b <= 1.6e-37) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.76e+99) tmp = 1.0 / ((a / b) * -1.5); elseif (b <= 1.6e-37) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.76e+99], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.6e-37], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.76 \cdot 10^{+99}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-37}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.76000000000000007e99Initial program 54.1%
Taylor expanded in b around -inf 95.9%
*-commutative95.9%
Simplified95.9%
clear-num95.8%
inv-pow95.8%
*-commutative95.8%
times-frac96.0%
metadata-eval96.0%
Applied egg-rr96.0%
unpow-196.0%
Simplified96.0%
if -1.76000000000000007e99 < b < 1.5999999999999999e-37Initial program 76.2%
if 1.5999999999999999e-37 < b Initial program 12.9%
Taylor expanded in b around inf 92.3%
*-commutative92.3%
associate-*l/92.3%
Simplified92.3%
Final simplification85.0%
(FPCore (a b c)
:precision binary64
(if (<= b -5.6e+97)
(/ 1.0 (* (/ a b) -1.5))
(if (<= b 2.35e-37)
(/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.6e+97) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 2.35e-37) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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.6d+97)) then
tmp = 1.0d0 / ((a / b) * (-1.5d0))
else if (b <= 2.35d-37) then
tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.6e+97) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 2.35e-37) {
tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.6e+97: tmp = 1.0 / ((a / b) * -1.5) elif b <= 2.35e-37: tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.6e+97) tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5)); elseif (b <= 2.35e-37) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.6e+97) tmp = 1.0 / ((a / b) * -1.5); elseif (b <= 2.35e-37) tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.6e+97], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.35e-37], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{+97}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.35 \cdot 10^{-37}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.5999999999999998e97Initial program 54.1%
Taylor expanded in b around -inf 95.9%
*-commutative95.9%
Simplified95.9%
clear-num95.8%
inv-pow95.8%
*-commutative95.8%
times-frac96.0%
metadata-eval96.0%
Applied egg-rr96.0%
unpow-196.0%
Simplified96.0%
if -5.5999999999999998e97 < b < 2.3500000000000001e-37Initial program 76.2%
Taylor expanded in a around 0 76.1%
associate-*r*76.2%
*-commutative76.2%
associate-*l*76.1%
Simplified76.1%
if 2.3500000000000001e-37 < b Initial program 12.9%
Taylor expanded in b around inf 92.3%
*-commutative92.3%
associate-*l/92.3%
Simplified92.3%
Final simplification85.0%
(FPCore (a b c)
:precision binary64
(if (<= b -9.8e-30)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 7.6e-38)
(* 0.3333333333333333 (/ (+ b (sqrt (* c (* a -3.0)))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.8e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 7.6e-38) {
tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-9.8d-30)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 7.6d-38) then
tmp = 0.3333333333333333d0 * ((b + sqrt((c * (a * (-3.0d0))))) / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9.8e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 7.6e-38) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.8e-30: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 7.6e-38: tmp = 0.3333333333333333 * ((b + math.sqrt((c * (a * -3.0)))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.8e-30) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 7.6e-38) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.8e-30) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 7.6e-38) tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.8e-30], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-38], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.8 \cdot 10^{-30}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-38}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.79999999999999942e-30Initial program 62.8%
Taylor expanded in b around -inf 82.8%
if -9.79999999999999942e-30 < b < 7.5999999999999999e-38Initial program 75.7%
Simplified75.5%
Taylor expanded in a around inf 70.1%
associate-*r*70.2%
*-commutative70.2%
*-commutative70.2%
Simplified70.2%
*-un-lft-identity70.2%
times-frac69.9%
metadata-eval69.9%
sub-neg69.9%
add-sqr-sqrt30.3%
sqrt-unprod69.9%
sqr-neg69.9%
sqrt-prod39.8%
add-sqr-sqrt69.4%
Applied egg-rr69.4%
if 7.5999999999999999e-38 < b Initial program 12.9%
Taylor expanded in b around inf 92.3%
*-commutative92.3%
associate-*l/92.3%
Simplified92.3%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.1e-29)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.8e-36)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-29) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.8e-36) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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-29)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.8d-36) then
tmp = (sqrt(((-3.0d0) * (a * c))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-29) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.8e-36) {
tmp = (Math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.1e-29: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.8e-36: tmp = (math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.1e-29) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.8e-36) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.1e-29) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.8e-36) tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.1e-29], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-36], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.1 \cdot 10^{-29}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-36}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.09999999999999995e-29Initial program 62.8%
Taylor expanded in b around -inf 82.8%
if -1.09999999999999995e-29 < b < 1.80000000000000016e-36Initial program 75.7%
Simplified75.5%
Taylor expanded in a around inf 70.1%
if 1.80000000000000016e-36 < b Initial program 12.9%
Taylor expanded in b around inf 92.3%
*-commutative92.3%
associate-*l/92.3%
Simplified92.3%
Final simplification80.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.1e-29)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.1e-37)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-29) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.1e-37) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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-29)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.1d-37) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-29) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.1e-37) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.1e-29: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.1e-37: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.1e-29) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.1e-37) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.1e-29) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.1e-37) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.1e-29], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-37], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.1 \cdot 10^{-29}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-37}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.09999999999999995e-29Initial program 62.8%
Taylor expanded in b around -inf 82.8%
if -1.09999999999999995e-29 < b < 1.10000000000000001e-37Initial program 75.7%
Simplified75.5%
Taylor expanded in a around inf 70.1%
associate-*r*70.2%
*-commutative70.2%
*-commutative70.2%
Simplified70.2%
if 1.10000000000000001e-37 < b Initial program 12.9%
Taylor expanded in b around inf 92.3%
*-commutative92.3%
associate-*l/92.3%
Simplified92.3%
Final simplification80.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (/ (* c -0.5) b)))
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 * -0.5) / 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 = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else
tmp = (c * (-0.5d0)) / b
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 * -0.5) / b;
}
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 * -0.5) / b 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 * -0.5) / b); 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 * -0.5) / b; 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 * -0.5), $MachinePrecision] / b), $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 \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 69.2%
Taylor expanded in b around -inf 58.2%
if -4.999999999999985e-310 < b Initial program 36.6%
Taylor expanded in b around inf 62.4%
*-commutative62.4%
associate-*l/62.4%
Simplified62.4%
Final simplification60.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.65e-292) (/ 1.0 (* (/ a b) -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.65e-292) {
tmp = 1.0 / ((a / b) * -1.5);
} else {
tmp = (c * -0.5) / 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-292) then
tmp = 1.0d0 / ((a / b) * (-1.5d0))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.65e-292) {
tmp = 1.0 / ((a / b) * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.65e-292: tmp = 1.0 / ((a / b) * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.65e-292) tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.65e-292) tmp = 1.0 / ((a / b) * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.65e-292], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.65 \cdot 10^{-292}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.64999999999999997e-292Initial program 69.7%
Taylor expanded in b around -inf 57.2%
*-commutative57.2%
Simplified57.2%
clear-num57.1%
inv-pow57.1%
*-commutative57.1%
times-frac57.2%
metadata-eval57.2%
Applied egg-rr57.2%
unpow-157.2%
Simplified57.2%
if 1.64999999999999997e-292 < b Initial program 35.7%
Taylor expanded in b around inf 63.2%
*-commutative63.2%
associate-*l/63.2%
Simplified63.2%
Final simplification60.4%
(FPCore (a b c) :precision binary64 (if (<= b 1.65e-292) (/ (* b -2.0) (* a 3.0)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.65e-292) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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-292) then
tmp = (b * (-2.0d0)) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.65e-292) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.65e-292: tmp = (b * -2.0) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.65e-292) tmp = Float64(Float64(b * -2.0) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.65e-292) tmp = (b * -2.0) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.65e-292], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.65 \cdot 10^{-292}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.64999999999999997e-292Initial program 69.7%
Taylor expanded in b around -inf 57.2%
*-commutative57.2%
Simplified57.2%
if 1.64999999999999997e-292 < b Initial program 35.7%
Taylor expanded in b around inf 63.2%
*-commutative63.2%
associate-*l/63.2%
Simplified63.2%
Final simplification60.4%
(FPCore (a b c) :precision binary64 (if (<= b 3.7e-34) (* -0.6666666666666666 (/ b a)) (/ (* c 0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.7e-34) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * 0.5) / 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.7d-34) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c * 0.5d0) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3.7e-34) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.7e-34: tmp = -0.6666666666666666 * (b / a) else: tmp = (c * 0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.7e-34) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c * 0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.7e-34) tmp = -0.6666666666666666 * (b / a); else tmp = (c * 0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.7e-34], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.7 \cdot 10^{-34}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 3.69999999999999988e-34Initial program 69.7%
Taylor expanded in b around -inf 40.3%
*-commutative40.3%
Simplified40.3%
if 3.69999999999999988e-34 < b Initial program 13.0%
Simplified13.0%
*-un-lft-identity13.0%
*-un-lft-identity13.0%
prod-diff13.0%
*-commutative13.0%
*-un-lft-identity13.0%
fma-def13.0%
*-un-lft-identity13.0%
add-sqr-sqrt0.0%
sqrt-unprod4.2%
sqr-neg4.2%
sqrt-prod4.2%
add-sqr-sqrt4.2%
+-commutative4.2%
pow24.2%
Applied egg-rr4.1%
+-commutative4.1%
associate-+l+4.1%
fma-udef4.1%
associate-*r*4.1%
*-commutative4.1%
associate-*r*4.1%
*-commutative4.1%
*-commutative4.1%
fma-def4.1%
fma-udef4.1%
*-rgt-identity4.1%
Simplified4.1%
Taylor expanded in b around -inf 2.3%
Taylor expanded in a around inf 23.5%
associate-*r/23.5%
Simplified23.5%
Final simplification35.0%
(FPCore (a b c) :precision binary64 (if (<= b 1.65e-292) (* -0.6666666666666666 (/ b a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.65e-292) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / 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-292) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.65e-292) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.65e-292: tmp = -0.6666666666666666 * (b / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.65e-292) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.65e-292) tmp = -0.6666666666666666 * (b / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.65e-292], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.65 \cdot 10^{-292}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.64999999999999997e-292Initial program 69.7%
Taylor expanded in b around -inf 57.1%
*-commutative57.1%
Simplified57.1%
if 1.64999999999999997e-292 < b Initial program 35.7%
Taylor expanded in b around inf 63.2%
*-commutative63.2%
associate-*l/63.2%
Simplified63.2%
Final simplification60.3%
(FPCore (a b c) :precision binary64 (* b (/ 1.3333333333333333 a)))
double code(double a, double b, double c) {
return b * (1.3333333333333333 / 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 * (1.3333333333333333d0 / a)
end function
public static double code(double a, double b, double c) {
return b * (1.3333333333333333 / a);
}
def code(a, b, c): return b * (1.3333333333333333 / a)
function code(a, b, c) return Float64(b * Float64(1.3333333333333333 / a)) end
function tmp = code(a, b, c) tmp = b * (1.3333333333333333 / a); end
code[a_, b_, c_] := N[(b * N[(1.3333333333333333 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{1.3333333333333333}{a}
\end{array}
Initial program 51.8%
Simplified51.7%
*-un-lft-identity51.7%
*-un-lft-identity51.7%
prod-diff51.7%
*-commutative51.7%
*-un-lft-identity51.7%
fma-def51.7%
*-un-lft-identity51.7%
add-sqr-sqrt32.1%
sqrt-unprod48.8%
sqr-neg48.8%
sqrt-prod16.8%
add-sqr-sqrt35.7%
+-commutative35.7%
pow235.7%
Applied egg-rr35.5%
+-commutative35.5%
associate-+l+35.1%
fma-udef35.1%
associate-*r*35.1%
*-commutative35.1%
associate-*r*35.1%
*-commutative35.1%
*-commutative35.1%
fma-def35.2%
fma-udef35.2%
*-rgt-identity35.2%
Simplified35.2%
Taylor expanded in c around 0 2.8%
*-commutative2.8%
Simplified2.8%
*-commutative2.8%
clear-num2.8%
un-div-inv2.8%
Applied egg-rr2.8%
associate-/r/2.8%
Applied egg-rr2.8%
Final simplification2.8%
(FPCore (a b c) :precision binary64 (* -0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.6666666666666666d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
def code(a, b, c): return -0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(-0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 51.8%
Taylor expanded in b around -inf 28.3%
*-commutative28.3%
Simplified28.3%
Final simplification28.3%
herbie shell --seed 2023310
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))