
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -1e+110)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 5.4e-94)
(/ (- (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 <= -1e+110) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 5.4e-94) {
tmp = (sqrt(((b * b) - (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 <= (-1d+110)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 5.4d-94) then
tmp = (sqrt(((b * b) - (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 <= -1e+110) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 5.4e-94) {
tmp = (Math.sqrt(((b * b) - (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 <= -1e+110: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 5.4e-94: tmp = (math.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 <= -1e+110) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 5.4e-94) 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
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e+110) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 5.4e-94) tmp = (sqrt(((b * b) - (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, -1e+110], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.4e-94], 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 -1 \cdot 10^{+110}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-94}:\\
\;\;\;\;\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 < -1e110Initial program 50.0%
Taylor expanded in b around -inf 95.7%
if -1e110 < b < 5.4000000000000002e-94Initial program 84.6%
if 5.4000000000000002e-94 < b Initial program 18.4%
Taylor expanded in b around inf 89.9%
*-commutative89.9%
associate-*l/89.9%
Simplified89.9%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -8e-18)
(* -0.3333333333333333 (+ (* (/ c b) -1.5) (* (/ b a) 2.0)))
(if (<= b 3.2e-93)
(/ (- (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 <= -8e-18) {
tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0));
} else if (b <= 3.2e-93) {
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 <= (-8d-18)) then
tmp = (-0.3333333333333333d0) * (((c / b) * (-1.5d0)) + ((b / a) * 2.0d0))
else if (b <= 3.2d-93) 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 <= -8e-18) {
tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0));
} else if (b <= 3.2e-93) {
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 <= -8e-18: tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0)) elif b <= 3.2e-93: 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 <= -8e-18) tmp = Float64(-0.3333333333333333 * Float64(Float64(Float64(c / b) * -1.5) + Float64(Float64(b / a) * 2.0))); elseif (b <= 3.2e-93) 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 <= -8e-18) tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0)); elseif (b <= 3.2e-93) 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, -8e-18], N[(-0.3333333333333333 * N[(N[(N[(c / b), $MachinePrecision] * -1.5), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.2e-93], 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 -8 \cdot 10^{-18}:\\
\;\;\;\;-0.3333333333333333 \cdot \left(\frac{c}{b} \cdot -1.5 + \frac{b}{a} \cdot 2\right)\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-93}:\\
\;\;\;\;\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 < -8.0000000000000006e-18Initial program 65.9%
Applied egg-rr23.3%
expm1-def37.3%
expm1-log1p65.9%
*-lft-identity65.9%
*-commutative65.9%
times-frac65.9%
metadata-eval65.9%
Simplified65.9%
Taylor expanded in b around -inf 89.3%
if -8.0000000000000006e-18 < b < 3.1999999999999999e-93Initial program 82.9%
Taylor expanded in b around 0 74.9%
if 3.1999999999999999e-93 < b Initial program 18.4%
Taylor expanded in b around inf 89.9%
*-commutative89.9%
associate-*l/89.9%
Simplified89.9%
Final simplification85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e-18)
(* -0.3333333333333333 (+ (* (/ c b) -1.5) (* (/ b a) 2.0)))
(if (<= b 8e-90)
(/ (- (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.5e-18) {
tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0));
} else if (b <= 8e-90) {
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.5d-18)) then
tmp = (-0.3333333333333333d0) * (((c / b) * (-1.5d0)) + ((b / a) * 2.0d0))
else if (b <= 8d-90) 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.5e-18) {
tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0));
} else if (b <= 8e-90) {
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.5e-18: tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0)) elif b <= 8e-90: 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.5e-18) tmp = Float64(-0.3333333333333333 * Float64(Float64(Float64(c / b) * -1.5) + Float64(Float64(b / a) * 2.0))); elseif (b <= 8e-90) 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.5e-18) tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0)); elseif (b <= 8e-90) 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.5e-18], N[(-0.3333333333333333 * N[(N[(N[(c / b), $MachinePrecision] * -1.5), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-90], 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.5 \cdot 10^{-18}:\\
\;\;\;\;-0.3333333333333333 \cdot \left(\frac{c}{b} \cdot -1.5 + \frac{b}{a} \cdot 2\right)\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-90}:\\
\;\;\;\;\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.49999999999999991e-18Initial program 65.9%
Applied egg-rr23.3%
expm1-def37.3%
expm1-log1p65.9%
*-lft-identity65.9%
*-commutative65.9%
times-frac65.9%
metadata-eval65.9%
Simplified65.9%
Taylor expanded in b around -inf 89.3%
if -1.49999999999999991e-18 < b < 7.99999999999999996e-90Initial program 82.9%
Taylor expanded in b around 0 74.9%
associate-*r*75.1%
*-commutative75.1%
*-commutative75.1%
Simplified75.1%
if 7.99999999999999996e-90 < b Initial program 18.4%
Taylor expanded in b around inf 89.9%
*-commutative89.9%
associate-*l/89.9%
Simplified89.9%
Final simplification85.4%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* -0.3333333333333333 (+ (* (/ c b) -1.5) (* (/ b a) 2.0))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.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 <= (-2d-310)) then
tmp = (-0.3333333333333333d0) * (((c / b) * (-1.5d0)) + ((b / a) * 2.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 <= -2e-310) {
tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(-0.3333333333333333 * Float64(Float64(Float64(c / b) * -1.5) + Float64(Float64(b / a) * 2.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 <= -2e-310) tmp = -0.3333333333333333 * (((c / b) * -1.5) + ((b / a) * 2.0)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(-0.3333333333333333 * N[(N[(N[(c / b), $MachinePrecision] * -1.5), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-0.3333333333333333 \cdot \left(\frac{c}{b} \cdot -1.5 + \frac{b}{a} \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 74.4%
Applied egg-rr23.9%
expm1-def44.0%
expm1-log1p74.4%
*-lft-identity74.4%
*-commutative74.4%
times-frac74.3%
metadata-eval74.3%
Simplified74.3%
Taylor expanded in b around -inf 66.9%
if -1.999999999999994e-310 < b Initial program 31.9%
Taylor expanded in b around inf 70.1%
*-commutative70.1%
associate-*l/70.1%
Simplified70.1%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-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 <= -2e-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 <= (-2d-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 <= -2e-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 <= -2e-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 <= -2e-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 <= -2e-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, -2e-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 -2 \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 < -1.999999999999994e-310Initial program 74.4%
Taylor expanded in b around -inf 66.9%
if -1.999999999999994e-310 < b Initial program 31.9%
Taylor expanded in b around inf 70.1%
*-commutative70.1%
associate-*l/70.1%
Simplified70.1%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b 4.6e-17) (* b (/ -0.6666666666666666 a)) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.6e-17) {
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 <= 4.6d-17) 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 <= 4.6e-17) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.6e-17: tmp = b * (-0.6666666666666666 / a) else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.6e-17) 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 <= 4.6e-17) tmp = b * (-0.6666666666666666 / a); else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.6e-17], 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 4.6 \cdot 10^{-17}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 4.60000000000000018e-17Initial program 71.9%
Applied egg-rr21.2%
expm1-def44.7%
expm1-log1p71.9%
*-lft-identity71.9%
*-commutative71.9%
times-frac71.8%
metadata-eval71.8%
Simplified71.8%
associate-*r/71.9%
Applied egg-rr71.9%
Taylor expanded in b around -inf 50.2%
associate-*r/50.2%
*-commutative50.2%
*-rgt-identity50.2%
associate-*r/50.2%
associate-*l*50.2%
associate-*r/50.2%
metadata-eval50.2%
Simplified50.2%
if 4.60000000000000018e-17 < b Initial program 16.7%
Applied egg-rr10.8%
expm1-def15.1%
expm1-log1p16.7%
*-lft-identity16.7%
*-commutative16.7%
times-frac16.7%
metadata-eval16.7%
Simplified16.7%
associate-*r/16.7%
Applied egg-rr16.7%
Taylor expanded in b around -inf 2.0%
Taylor expanded in a around inf 29.3%
*-commutative29.3%
Simplified29.3%
Final simplification42.9%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* b (/ -0.6666666666666666 a)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-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 <= -2e-310) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-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 -2 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 74.4%
Applied egg-rr23.9%
expm1-def44.0%
expm1-log1p74.4%
*-lft-identity74.4%
*-commutative74.4%
times-frac74.3%
metadata-eval74.3%
Simplified74.3%
associate-*r/74.4%
Applied egg-rr74.4%
Taylor expanded in b around -inf 66.3%
associate-*r/66.3%
*-commutative66.3%
*-rgt-identity66.3%
associate-*r/66.3%
associate-*l*66.2%
associate-*r/66.3%
metadata-eval66.3%
Simplified66.3%
if -1.999999999999994e-310 < b Initial program 31.9%
Applied egg-rr31.2%
sub-neg31.2%
distribute-rgt-out--31.9%
Simplified31.9%
Taylor expanded in a around 0 51.9%
associate-/l*54.4%
associate-*r/54.4%
Simplified54.4%
expm1-log1p-u50.4%
expm1-udef27.3%
*-commutative27.3%
associate-/l*27.4%
frac-times27.4%
metadata-eval27.4%
Applied egg-rr27.4%
expm1-def49.7%
expm1-log1p53.8%
*-commutative53.8%
associate-*r/61.3%
associate-*l/68.0%
*-inverses68.0%
associate-*r/68.0%
*-lft-identity68.0%
Simplified68.0%
Final simplification67.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (* a -1.5)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / (a * -1.5) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-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 <= -2e-310) tmp = b / (a * -1.5); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-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 -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 74.4%
Applied egg-rr23.9%
expm1-def44.0%
expm1-log1p74.4%
*-lft-identity74.4%
*-commutative74.4%
times-frac74.3%
metadata-eval74.3%
Simplified74.3%
associate-*r/74.4%
Applied egg-rr74.4%
Taylor expanded in b around -inf 66.3%
associate-*r/66.3%
*-commutative66.3%
*-rgt-identity66.3%
associate-*r/66.3%
associate-*l*66.2%
associate-*r/66.3%
metadata-eval66.3%
Simplified66.3%
clear-num66.2%
un-div-inv66.3%
div-inv66.4%
metadata-eval66.4%
Applied egg-rr66.4%
if -1.999999999999994e-310 < b Initial program 31.9%
Applied egg-rr31.2%
sub-neg31.2%
distribute-rgt-out--31.9%
Simplified31.9%
Taylor expanded in a around 0 51.9%
associate-/l*54.4%
associate-*r/54.4%
Simplified54.4%
expm1-log1p-u50.4%
expm1-udef27.3%
*-commutative27.3%
associate-/l*27.4%
frac-times27.4%
metadata-eval27.4%
Applied egg-rr27.4%
expm1-def49.7%
expm1-log1p53.8%
*-commutative53.8%
associate-*r/61.3%
associate-*l/68.0%
*-inverses68.0%
associate-*r/68.0%
*-lft-identity68.0%
Simplified68.0%
Final simplification67.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-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 <= -2e-310) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-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 -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 74.4%
Applied egg-rr23.9%
expm1-def44.0%
expm1-log1p74.4%
*-lft-identity74.4%
*-commutative74.4%
times-frac74.3%
metadata-eval74.3%
Simplified74.3%
associate-*r/74.4%
Applied egg-rr74.4%
Taylor expanded in b around -inf 66.3%
associate-*r/66.3%
*-commutative66.3%
*-rgt-identity66.3%
associate-*r/66.3%
associate-*l*66.2%
associate-*r/66.3%
metadata-eval66.3%
Simplified66.3%
clear-num66.2%
un-div-inv66.3%
div-inv66.4%
metadata-eval66.4%
Applied egg-rr66.4%
if -1.999999999999994e-310 < b Initial program 31.9%
Taylor expanded in b around inf 70.1%
*-commutative70.1%
associate-*l/70.1%
Simplified70.1%
Final simplification68.3%
(FPCore (a b c) :precision binary64 (* b (/ -0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (-0.6666666666666666 / 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 * ((-0.6666666666666666d0) / a)
end function
public static double code(double a, double b, double c) {
return b * (-0.6666666666666666 / a);
}
def code(a, b, c): return b * (-0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(-0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (-0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{-0.6666666666666666}{a}
\end{array}
Initial program 52.5%
Applied egg-rr17.6%
expm1-def34.3%
expm1-log1p52.5%
*-lft-identity52.5%
*-commutative52.5%
times-frac52.4%
metadata-eval52.4%
Simplified52.4%
associate-*r/52.5%
Applied egg-rr52.5%
Taylor expanded in b around -inf 33.3%
associate-*r/33.3%
*-commutative33.3%
*-rgt-identity33.3%
associate-*r/33.3%
associate-*l*33.3%
associate-*r/33.3%
metadata-eval33.3%
Simplified33.3%
Final simplification33.3%
herbie shell --seed 2023313
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))