
(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 11 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+166)
(/ (fma b -2.0 (* (* (/ a b) c) 1.5)) (* a 3.0))
(if (<= b 3.55e-66)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+166) {
tmp = fma(b, -2.0, (((a / b) * c) * 1.5)) / (a * 3.0);
} else if (b <= 3.55e-66) {
tmp = (sqrt(((b * b) - (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 <= -5e+166) tmp = Float64(fma(b, -2.0, Float64(Float64(Float64(a / b) * c) * 1.5)) / Float64(a * 3.0)); elseif (b <= 3.55e-66) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+166], N[(N[(b * -2.0 + N[(N[(N[(a / b), $MachinePrecision] * c), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.55e-66], 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 * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+166}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, \left(\frac{a}{b} \cdot c\right) \cdot 1.5\right)}{a \cdot 3}\\
\mathbf{elif}\;b \leq 3.55 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 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 < -5.0000000000000002e166Initial program 37.5%
Taylor expanded in b around -inf 90.2%
*-commutative90.2%
fma-def90.2%
*-commutative90.2%
associate-/l*97.5%
associate-/r/97.5%
Simplified97.5%
if -5.0000000000000002e166 < b < 3.54999999999999982e-66Initial program 77.7%
if 3.54999999999999982e-66 < b Initial program 9.8%
Taylor expanded in b around inf 93.1%
*-commutative93.1%
associate-*l/93.1%
Simplified93.1%
Final simplification86.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2.05e-73)
(+ (* b (/ -0.6666666666666666 a)) (* 0.5 (/ c b)))
(if (<= b 4.5e-69)
(/ (- (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 <= -2.05e-73) {
tmp = (b * (-0.6666666666666666 / a)) + (0.5 * (c / b));
} else if (b <= 4.5e-69) {
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 <= (-2.05d-73)) then
tmp = (b * ((-0.6666666666666666d0) / a)) + (0.5d0 * (c / b))
else if (b <= 4.5d-69) 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 <= -2.05e-73) {
tmp = (b * (-0.6666666666666666 / a)) + (0.5 * (c / b));
} else if (b <= 4.5e-69) {
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 <= -2.05e-73: tmp = (b * (-0.6666666666666666 / a)) + (0.5 * (c / b)) elif b <= 4.5e-69: 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 <= -2.05e-73) tmp = Float64(Float64(b * Float64(-0.6666666666666666 / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 4.5e-69) 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 <= -2.05e-73) tmp = (b * (-0.6666666666666666 / a)) + (0.5 * (c / b)); elseif (b <= 4.5e-69) 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, -2.05e-73], N[(N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-69], 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 -2.05 \cdot 10^{-73}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-69}:\\
\;\;\;\;\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 < -2.05000000000000008e-73Initial program 65.2%
Taylor expanded in b around -inf 84.7%
fma-def84.7%
associate-*r/84.7%
Simplified84.7%
fma-udef84.7%
*-commutative84.7%
*-un-lft-identity84.7%
times-frac84.7%
metadata-eval84.7%
Applied egg-rr84.7%
*-commutative83.9%
clear-num84.0%
un-div-inv84.0%
Applied egg-rr84.7%
associate-/r/84.1%
Simplified84.9%
if -2.05000000000000008e-73 < b < 4.50000000000000009e-69Initial program 70.1%
Taylor expanded in b around 0 62.6%
if 4.50000000000000009e-69 < b Initial program 9.8%
Taylor expanded in b around inf 93.1%
*-commutative93.1%
associate-*l/93.1%
Simplified93.1%
Final simplification81.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2.8e-74)
(+ (* b (/ -0.6666666666666666 a)) (* 0.5 (/ c b)))
(if (<= b 5.5e-76)
(/ (- (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 <= -2.8e-74) {
tmp = (b * (-0.6666666666666666 / a)) + (0.5 * (c / b));
} else if (b <= 5.5e-76) {
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 <= (-2.8d-74)) then
tmp = (b * ((-0.6666666666666666d0) / a)) + (0.5d0 * (c / b))
else if (b <= 5.5d-76) 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 <= -2.8e-74) {
tmp = (b * (-0.6666666666666666 / a)) + (0.5 * (c / b));
} else if (b <= 5.5e-76) {
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 <= -2.8e-74: tmp = (b * (-0.6666666666666666 / a)) + (0.5 * (c / b)) elif b <= 5.5e-76: 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 <= -2.8e-74) tmp = Float64(Float64(b * Float64(-0.6666666666666666 / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 5.5e-76) 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 <= -2.8e-74) tmp = (b * (-0.6666666666666666 / a)) + (0.5 * (c / b)); elseif (b <= 5.5e-76) 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, -2.8e-74], N[(N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.5e-76], 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 -2.8 \cdot 10^{-74}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-76}:\\
\;\;\;\;\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 < -2.79999999999999988e-74Initial program 65.2%
Taylor expanded in b around -inf 84.7%
fma-def84.7%
associate-*r/84.7%
Simplified84.7%
fma-udef84.7%
*-commutative84.7%
*-un-lft-identity84.7%
times-frac84.7%
metadata-eval84.7%
Applied egg-rr84.7%
*-commutative83.9%
clear-num84.0%
un-div-inv84.0%
Applied egg-rr84.7%
associate-/r/84.1%
Simplified84.9%
if -2.79999999999999988e-74 < b < 5.50000000000000014e-76Initial program 70.1%
Taylor expanded in b around 0 62.6%
associate-*r*62.7%
*-commutative62.7%
*-commutative62.7%
Simplified62.7%
if 5.50000000000000014e-76 < b Initial program 9.8%
Taylor expanded in b around inf 93.1%
*-commutative93.1%
associate-*l/93.1%
Simplified93.1%
Final simplification81.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2.4e-73)
(/ (fma b -2.0 (* (* (/ a b) c) 1.5)) (* a 3.0))
(if (<= b 5.7e-68)
(/ (- (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 <= -2.4e-73) {
tmp = fma(b, -2.0, (((a / b) * c) * 1.5)) / (a * 3.0);
} else if (b <= 5.7e-68) {
tmp = (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 <= -2.4e-73) tmp = Float64(fma(b, -2.0, Float64(Float64(Float64(a / b) * c) * 1.5)) / Float64(a * 3.0)); elseif (b <= 5.7e-68) 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
code[a_, b_, c_] := If[LessEqual[b, -2.4e-73], N[(N[(b * -2.0 + N[(N[(N[(a / b), $MachinePrecision] * c), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.7e-68], 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 -2.4 \cdot 10^{-73}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, \left(\frac{a}{b} \cdot c\right) \cdot 1.5\right)}{a \cdot 3}\\
\mathbf{elif}\;b \leq 5.7 \cdot 10^{-68}:\\
\;\;\;\;\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 < -2.40000000000000006e-73Initial program 65.2%
Taylor expanded in b around -inf 81.5%
*-commutative81.5%
fma-def81.5%
*-commutative81.5%
associate-/l*84.9%
associate-/r/84.9%
Simplified84.9%
if -2.40000000000000006e-73 < b < 5.7000000000000002e-68Initial program 70.1%
Taylor expanded in b around 0 62.6%
associate-*r*62.7%
*-commutative62.7%
*-commutative62.7%
Simplified62.7%
if 5.7000000000000002e-68 < b Initial program 9.8%
Taylor expanded in b around inf 93.1%
*-commutative93.1%
associate-*l/93.1%
Simplified93.1%
Final simplification81.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (0.5 * (c / b)) + (-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 <= (-5d-310)) then
tmp = (0.5d0 * (c / b)) + ((-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 <= -5e-310) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(0.5 * Float64(c / b)) + 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 <= -5e-310) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $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.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 68.5%
Taylor expanded in b around -inf 70.4%
if -4.999999999999985e-310 < b Initial program 26.2%
Taylor expanded in b around inf 70.9%
*-commutative70.9%
associate-*l/70.9%
Simplified70.9%
Final simplification70.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* b (/ -0.6666666666666666 a)) (* 0.5 (/ c b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * (-0.6666666666666666 / 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 = (b * ((-0.6666666666666666d0) / 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 = (b * (-0.6666666666666666 / 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 = (b * (-0.6666666666666666 / 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(b * Float64(-0.6666666666666666 / 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 = (b * (-0.6666666666666666 / 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[(b * N[(-0.6666666666666666 / 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}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{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 68.5%
Taylor expanded in b around -inf 70.4%
fma-def70.4%
associate-*r/70.4%
Simplified70.4%
fma-udef70.4%
*-commutative70.4%
*-un-lft-identity70.4%
times-frac70.4%
metadata-eval70.4%
Applied egg-rr70.4%
*-commutative69.6%
clear-num69.6%
un-div-inv69.6%
Applied egg-rr70.4%
associate-/r/69.7%
Simplified70.5%
if -4.999999999999985e-310 < b Initial program 26.2%
Taylor expanded in b around inf 70.9%
*-commutative70.9%
associate-*l/70.9%
Simplified70.9%
Final simplification70.7%
(FPCore (a b c) :precision binary64 (if (<= b 8.8e+74) (* b (/ -0.6666666666666666 a)) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8.8e+74) {
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 <= 8.8d+74) 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 <= 8.8e+74) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8.8e+74: tmp = b * (-0.6666666666666666 / a) else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8.8e+74) 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 <= 8.8e+74) tmp = b * (-0.6666666666666666 / a); else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8.8e+74], 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 8.8 \cdot 10^{+74}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 8.8000000000000005e74Initial program 58.5%
Taylor expanded in b around -inf 44.9%
*-commutative44.9%
Simplified44.9%
*-commutative44.9%
clear-num44.9%
un-div-inv44.9%
Applied egg-rr44.9%
associate-/r/44.9%
Simplified44.9%
if 8.8000000000000005e74 < b Initial program 9.4%
Taylor expanded in b around -inf 2.1%
fma-def2.1%
associate-*r/2.1%
Simplified2.1%
Taylor expanded in b around 0 33.6%
Final simplification42.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* b (/ -0.6666666666666666 a)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 / (b / c);
}
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)
else
tmp = (-0.5d0) / (b / c)
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);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 68.5%
Taylor expanded in b around -inf 69.6%
*-commutative69.6%
Simplified69.6%
*-commutative69.6%
clear-num69.6%
un-div-inv69.6%
Applied egg-rr69.6%
associate-/r/69.7%
Simplified69.7%
if -4.999999999999985e-310 < b Initial program 26.2%
Taylor expanded in b around inf 57.3%
associate-/l*61.1%
associate-/r/53.2%
Simplified53.2%
log1p-expm1-u44.4%
log1p-udef20.1%
times-frac20.1%
metadata-eval20.1%
associate-*l/19.5%
associate-/l*20.8%
Applied egg-rr20.8%
*-un-lft-identity20.8%
log-prod20.8%
metadata-eval20.8%
log1p-def49.5%
log1p-expm1-u61.0%
associate-/l/60.6%
Applied egg-rr60.6%
+-lft-identity60.6%
associate-/r*70.3%
*-inverses70.3%
associate-*r/70.3%
metadata-eval70.3%
Simplified70.3%
Final simplification70.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* a -1.5)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = b / (a * (-1.5d0))
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (a * -1.5) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b / (a * -1.5); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 68.5%
Taylor expanded in b around -inf 69.6%
*-commutative69.6%
Simplified69.6%
*-commutative69.6%
clear-num69.6%
un-div-inv69.6%
Applied egg-rr69.6%
associate-/r/69.7%
Simplified69.7%
*-commutative69.7%
clear-num69.6%
un-div-inv69.6%
div-inv69.8%
metadata-eval69.8%
Applied egg-rr69.8%
if -4.999999999999985e-310 < b Initial program 26.2%
Taylor expanded in b around inf 57.3%
associate-/l*61.1%
associate-/r/53.2%
Simplified53.2%
log1p-expm1-u44.4%
log1p-udef20.1%
times-frac20.1%
metadata-eval20.1%
associate-*l/19.5%
associate-/l*20.8%
Applied egg-rr20.8%
*-un-lft-identity20.8%
log-prod20.8%
metadata-eval20.8%
log1p-def49.5%
log1p-expm1-u61.0%
associate-/l/60.6%
Applied egg-rr60.6%
+-lft-identity60.6%
associate-/r*70.3%
*-inverses70.3%
associate-*r/70.3%
metadata-eval70.3%
Simplified70.3%
Final simplification70.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -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 <= (-5d-310)) then
tmp = b / (a * (-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 <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(a * -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 <= -5e-310) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 68.5%
Taylor expanded in b around -inf 69.6%
*-commutative69.6%
Simplified69.6%
*-commutative69.6%
clear-num69.6%
un-div-inv69.6%
Applied egg-rr69.6%
associate-/r/69.7%
Simplified69.7%
*-commutative69.7%
clear-num69.6%
un-div-inv69.6%
div-inv69.8%
metadata-eval69.8%
Applied egg-rr69.8%
if -4.999999999999985e-310 < b Initial program 26.2%
Taylor expanded in b around inf 70.9%
*-commutative70.9%
associate-*l/70.9%
Simplified70.9%
Final simplification70.4%
(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 46.0%
Taylor expanded in b around -inf 34.2%
fma-def34.2%
associate-*r/34.2%
Simplified34.2%
Taylor expanded in b around 0 10.8%
Final simplification10.8%
herbie shell --seed 2023301
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))