
(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 13 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+153)
(/ (/ 1.0 (/ a (* b 2.0))) -3.0)
(if (<= b 1.2e-143)
(/ (- (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 <= -5e+153) {
tmp = (1.0 / (a / (b * 2.0))) / -3.0;
} else if (b <= 1.2e-143) {
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 <= (-5d+153)) then
tmp = (1.0d0 / (a / (b * 2.0d0))) / (-3.0d0)
else if (b <= 1.2d-143) 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 <= -5e+153) {
tmp = (1.0 / (a / (b * 2.0))) / -3.0;
} else if (b <= 1.2e-143) {
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 <= -5e+153: tmp = (1.0 / (a / (b * 2.0))) / -3.0 elif b <= 1.2e-143: 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 <= -5e+153) tmp = Float64(Float64(1.0 / Float64(a / Float64(b * 2.0))) / -3.0); elseif (b <= 1.2e-143) 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 <= -5e+153) tmp = (1.0 / (a / (b * 2.0))) / -3.0; elseif (b <= 1.2e-143) 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, -5e+153], N[(N[(1.0 / N[(a / N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 1.2e-143], 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 -5 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{1}{\frac{a}{b \cdot 2}}}{-3}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-143}:\\
\;\;\;\;\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 < -5.00000000000000018e153Initial program 33.7%
Applied egg-rr18.1%
expm1-def18.1%
expm1-log1p33.8%
*-lft-identity33.8%
*-commutative33.8%
times-frac33.8%
metadata-eval33.8%
Simplified33.8%
*-commutative33.8%
metadata-eval33.8%
div-inv33.8%
Applied egg-rr33.8%
clear-num33.8%
inv-pow33.8%
Applied egg-rr33.8%
unpow-133.8%
Simplified33.8%
Taylor expanded in b around -inf 99.7%
*-commutative99.7%
Simplified99.7%
if -5.00000000000000018e153 < b < 1.1999999999999999e-143Initial program 83.1%
if 1.1999999999999999e-143 < b Initial program 20.9%
Taylor expanded in b around inf 85.4%
*-commutative85.4%
associate-*l/85.4%
Simplified85.4%
Final simplification86.4%
(FPCore (a b c)
:precision binary64
(if (<= b -3e-147)
(+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a)))
(if (<= b 1.55e-142)
(/ (- (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 <= -3e-147) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 1.55e-142) {
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 <= (-3d-147)) then
tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / a))
else if (b <= 1.55d-142) 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 <= -3e-147) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 1.55e-142) {
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 <= -3e-147: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) elif b <= 1.55e-142: 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 <= -3e-147) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / a))); elseif (b <= 1.55e-142) 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 <= -3e-147) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); elseif (b <= 1.55e-142) 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, -3e-147], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.55e-142], 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 -3 \cdot 10^{-147}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\
\;\;\;\;\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 < -3.0000000000000002e-147Initial program 70.0%
Taylor expanded in b around -inf 83.3%
if -3.0000000000000002e-147 < b < 1.55e-142Initial program 73.2%
prod-diff73.0%
*-commutative73.0%
fma-def73.0%
associate-+l+73.0%
pow273.0%
*-commutative73.0%
distribute-rgt-neg-in73.0%
*-commutative73.0%
distribute-rgt-neg-in73.0%
metadata-eval73.0%
*-commutative73.0%
fma-udef73.0%
distribute-lft-neg-in73.0%
distribute-rgt-neg-in73.0%
*-commutative73.0%
distribute-rgt-neg-in73.0%
metadata-eval73.0%
associate-*l*72.8%
Applied egg-rr72.8%
Taylor expanded in b around 0 72.9%
mul-1-neg72.9%
unsub-neg72.9%
distribute-rgt-out73.2%
metadata-eval73.2%
*-commutative73.2%
associate-*r*73.4%
Simplified73.4%
if 1.55e-142 < b Initial program 20.9%
Taylor expanded in b around inf 85.4%
*-commutative85.4%
associate-*l/85.4%
Simplified85.4%
Final simplification82.0%
(FPCore (a b c)
:precision binary64
(if (<= b -3e-147)
(/ (fma b -2.0 (* (* c (/ a b)) 1.5)) (* a 3.0))
(if (<= b 1.55e-142)
(/ (- (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 <= -3e-147) {
tmp = fma(b, -2.0, ((c * (a / b)) * 1.5)) / (a * 3.0);
} else if (b <= 1.55e-142) {
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 <= -3e-147) tmp = Float64(fma(b, -2.0, Float64(Float64(c * Float64(a / b)) * 1.5)) / Float64(a * 3.0)); elseif (b <= 1.55e-142) 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, -3e-147], N[(N[(b * -2.0 + N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.55e-142], 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 -3 \cdot 10^{-147}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, \left(c \cdot \frac{a}{b}\right) \cdot 1.5\right)}{a \cdot 3}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\
\;\;\;\;\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 < -3.0000000000000002e-147Initial program 70.0%
Taylor expanded in b around -inf 76.1%
*-commutative76.1%
fma-def76.1%
*-commutative76.1%
associate-/l*83.3%
associate-/r/83.3%
Simplified83.3%
if -3.0000000000000002e-147 < b < 1.55e-142Initial program 73.2%
prod-diff73.0%
*-commutative73.0%
fma-def73.0%
associate-+l+73.0%
pow273.0%
*-commutative73.0%
distribute-rgt-neg-in73.0%
*-commutative73.0%
distribute-rgt-neg-in73.0%
metadata-eval73.0%
*-commutative73.0%
fma-udef73.0%
distribute-lft-neg-in73.0%
distribute-rgt-neg-in73.0%
*-commutative73.0%
distribute-rgt-neg-in73.0%
metadata-eval73.0%
associate-*l*72.8%
Applied egg-rr72.8%
Taylor expanded in b around 0 72.9%
mul-1-neg72.9%
unsub-neg72.9%
distribute-rgt-out73.2%
metadata-eval73.2%
*-commutative73.2%
associate-*r*73.4%
Simplified73.4%
if 1.55e-142 < b Initial program 20.9%
Taylor expanded in b around inf 85.4%
*-commutative85.4%
associate-*l/85.4%
Simplified85.4%
Final simplification82.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e-168)
(+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a)))
(if (<= b 1.55e-142)
(* 0.3333333333333333 (/ (sqrt (* c (* a -3.0))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e-168) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 1.55e-142) {
tmp = 0.3333333333333333 * (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 <= (-1.6d-168)) then
tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / a))
else if (b <= 1.55d-142) then
tmp = 0.3333333333333333d0 * (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 <= -1.6e-168) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else if (b <= 1.55e-142) {
tmp = 0.3333333333333333 * (Math.sqrt((c * (a * -3.0))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.6e-168: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) elif b <= 1.55e-142: tmp = 0.3333333333333333 * (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 <= -1.6e-168) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / a))); elseif (b <= 1.55e-142) tmp = Float64(0.3333333333333333 * Float64(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 <= -1.6e-168) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); elseif (b <= 1.55e-142) tmp = 0.3333333333333333 * (sqrt((c * (a * -3.0))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.6e-168], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.55e-142], N[(0.3333333333333333 * N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{-168}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.60000000000000003e-168Initial program 69.7%
Taylor expanded in b around -inf 82.6%
if -1.60000000000000003e-168 < b < 1.55e-142Initial program 73.8%
prod-diff73.5%
*-commutative73.5%
fma-def73.5%
associate-+l+73.5%
pow273.5%
*-commutative73.5%
distribute-rgt-neg-in73.5%
*-commutative73.5%
distribute-rgt-neg-in73.5%
metadata-eval73.5%
*-commutative73.5%
fma-udef73.5%
distribute-lft-neg-in73.5%
distribute-rgt-neg-in73.5%
*-commutative73.5%
distribute-rgt-neg-in73.5%
metadata-eval73.5%
associate-*l*73.3%
Applied egg-rr73.3%
Taylor expanded in b around 0 72.0%
associate-*l/72.2%
*-lft-identity72.2%
distribute-rgt-out72.5%
metadata-eval72.5%
*-commutative72.5%
associate-*r*72.7%
Simplified72.7%
if 1.55e-142 < b Initial program 20.9%
Taylor expanded in b around inf 85.4%
*-commutative85.4%
associate-*l/85.4%
Simplified85.4%
Final simplification81.7%
(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 70.8%
Taylor expanded in b around -inf 64.9%
if -4.999999999999985e-310 < b Initial program 30.2%
Taylor expanded in b around inf 72.7%
*-commutative72.7%
associate-*l/72.7%
Simplified72.7%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ 1.0 (* (/ a b) -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = 1.0 / ((a / b) * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: 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 <= -5e-310) 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 <= -5e-310) 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, -5e-310], 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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.8%
Applied egg-rr20.9%
expm1-def41.9%
expm1-log1p70.8%
*-lft-identity70.8%
*-commutative70.8%
times-frac70.7%
metadata-eval70.7%
Simplified70.7%
Taylor expanded in b around -inf 64.8%
associate-*r/64.7%
associate-/l*64.7%
Simplified64.7%
clear-num64.7%
inv-pow64.7%
div-inv64.8%
metadata-eval64.8%
Applied egg-rr64.8%
unpow-164.8%
Simplified64.8%
if -4.999999999999985e-310 < b Initial program 30.2%
Taylor expanded in b around inf 72.7%
*-commutative72.7%
associate-*l/72.7%
Simplified72.7%
Final simplification68.8%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* b -2.0) (* a 3.0)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: 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 <= -5e-310) 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 <= -5e-310) 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, -5e-310], 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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.8%
Taylor expanded in b around -inf 64.8%
*-commutative64.8%
Simplified64.8%
if -4.999999999999985e-310 < b Initial program 30.2%
Taylor expanded in b around inf 72.7%
*-commutative72.7%
associate-*l/72.7%
Simplified72.7%
Final simplification68.8%
(FPCore (a b c) :precision binary64 (if (<= b 1.95e-305) (/ (/ (* b 2.0) a) -3.0) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.95e-305) {
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.95d-305) 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.95e-305) {
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.95e-305: 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.95e-305) tmp = Float64(Float64(Float64(b * 2.0) / 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.95e-305) 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.95e-305], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95 \cdot 10^{-305}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.95000000000000013e-305Initial program 70.8%
Applied egg-rr20.9%
expm1-def41.9%
expm1-log1p70.8%
*-lft-identity70.8%
*-commutative70.8%
times-frac70.7%
metadata-eval70.7%
Simplified70.7%
*-commutative70.7%
metadata-eval70.7%
div-inv70.8%
Applied egg-rr70.8%
Taylor expanded in b around -inf 64.8%
*-commutative64.8%
Simplified64.8%
if 1.95000000000000013e-305 < b Initial program 30.2%
Taylor expanded in b around inf 72.7%
*-commutative72.7%
associate-*l/72.7%
Simplified72.7%
Final simplification68.8%
(FPCore (a b c) :precision binary64 (if (<= b 3e-309) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3e-309) {
tmp = b * (-0.6666666666666666 / 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 <= 3d-309) then
tmp = b * ((-0.6666666666666666d0) / 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 <= 3e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3e-309: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3e-309) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3e-309) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3e-309], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3 \cdot 10^{-309}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 3.000000000000001e-309Initial program 70.8%
Applied egg-rr20.9%
expm1-def41.9%
expm1-log1p70.8%
*-lft-identity70.8%
*-commutative70.8%
times-frac70.7%
metadata-eval70.7%
Simplified70.7%
Taylor expanded in b around -inf 64.8%
associate-*r/64.7%
associate-/l*64.7%
Simplified64.7%
associate-/r/64.7%
Applied egg-rr64.7%
if 3.000000000000001e-309 < b Initial program 30.2%
Applied egg-rr12.6%
expm1-def22.6%
expm1-log1p30.2%
*-lft-identity30.2%
*-commutative30.2%
times-frac30.1%
metadata-eval30.1%
Simplified30.1%
Taylor expanded in b around inf 72.7%
metadata-eval72.7%
times-frac72.7%
*-commutative72.7%
times-frac72.4%
/-rgt-identity72.4%
Simplified72.4%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = -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.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(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(c * Float64(-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); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.8%
Taylor expanded in b around -inf 64.8%
*-commutative64.8%
Simplified64.8%
if -4.999999999999985e-310 < b Initial program 30.2%
Applied egg-rr12.6%
expm1-def22.6%
expm1-log1p30.2%
*-lft-identity30.2%
*-commutative30.2%
times-frac30.1%
metadata-eval30.1%
Simplified30.1%
Taylor expanded in b around inf 72.7%
metadata-eval72.7%
times-frac72.7%
*-commutative72.7%
times-frac72.4%
/-rgt-identity72.4%
Simplified72.4%
Final simplification68.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = -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.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(-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.6666666666666666 * (b / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], 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 -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.8%
Taylor expanded in b around -inf 64.8%
*-commutative64.8%
Simplified64.8%
if -4.999999999999985e-310 < b Initial program 30.2%
Taylor expanded in b around inf 72.7%
*-commutative72.7%
associate-*l/72.7%
Simplified72.7%
Final simplification68.8%
(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 50.2%
Applied egg-rr16.7%
expm1-def32.1%
expm1-log1p50.2%
*-lft-identity50.2%
*-commutative50.2%
times-frac50.1%
metadata-eval50.1%
Simplified50.1%
Taylor expanded in b around -inf 33.2%
Taylor expanded in c around inf 10.3%
Final simplification10.3%
(FPCore (a b c) :precision binary64 (* c (/ -0.5 b)))
double code(double a, double b, double c) {
return c * (-0.5 / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c * ((-0.5d0) / b)
end function
public static double code(double a, double b, double c) {
return c * (-0.5 / b);
}
def code(a, b, c): return c * (-0.5 / b)
function code(a, b, c) return Float64(c * Float64(-0.5 / b)) end
function tmp = code(a, b, c) tmp = c * (-0.5 / b); end
code[a_, b_, c_] := N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{-0.5}{b}
\end{array}
Initial program 50.2%
Applied egg-rr16.7%
expm1-def32.1%
expm1-log1p50.2%
*-lft-identity50.2%
*-commutative50.2%
times-frac50.1%
metadata-eval50.1%
Simplified50.1%
Taylor expanded in b around inf 37.9%
metadata-eval37.9%
times-frac37.9%
*-commutative37.9%
times-frac37.8%
/-rgt-identity37.8%
Simplified37.8%
Final simplification37.8%
herbie shell --seed 2023311
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))