
(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 -9e+139)
(/ (* b -0.6666666666666666) a)
(if (<= b 2.85e+140)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (- b b) (* a 3.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e+139) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.85e+140) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (b - b) / (a * 3.0);
}
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 <= (-9d+139)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 2.85d+140) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (b - b) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9e+139) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.85e+140) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (b - b) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9e+139: tmp = (b * -0.6666666666666666) / a elif b <= 2.85e+140: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (b - b) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9e+139) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 2.85e+140) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(b - b) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9e+139) tmp = (b * -0.6666666666666666) / a; elseif (b <= 2.85e+140) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (b - b) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9e+139], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.85e+140], 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[(b - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{+139}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2.85 \cdot 10^{+140}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot 3}\\
\end{array}
\end{array}
if b < -8.9999999999999999e139Initial program 52.5%
Taylor expanded in b around -inf 99.6%
*-commutative99.6%
Simplified99.6%
associate-*l/99.8%
Applied egg-rr99.8%
if -8.9999999999999999e139 < b < 2.85000000000000007e140Initial program 80.3%
if 2.85000000000000007e140 < b Initial program 8.5%
Taylor expanded in b around inf 93.2%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(if (<= b -5.3e-58)
(+ (/ (* b -0.6666666666666666) a) (* 0.5 (/ c b)))
(if (<= b 3.75e+21)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(/ (- b b) (* a 3.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.3e-58) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 3.75e+21) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (b - b) / (a * 3.0);
}
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.3d-58)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + (0.5d0 * (c / b))
else if (b <= 3.75d+21) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (b - b) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.3e-58) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 3.75e+21) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (b - b) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.3e-58: tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)) elif b <= 3.75e+21: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = (b - b) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.3e-58) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(0.5 * Float64(c / b))); elseif (b <= 3.75e+21) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(b - b) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.3e-58) tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)); elseif (b <= 3.75e+21) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = (b - b) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.3e-58], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.75e+21], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.3 \cdot 10^{-58}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 3.75 \cdot 10^{+21}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot 3}\\
\end{array}
\end{array}
if b < -5.3000000000000003e-58Initial program 70.2%
Taylor expanded in b around -inf 87.8%
associate-*r/87.8%
Applied egg-rr87.8%
if -5.3000000000000003e-58 < b < 3.75e21Initial program 76.5%
Taylor expanded in b around 0 66.9%
*-commutative66.9%
associate-*l*67.0%
Simplified67.0%
if 3.75e21 < b Initial program 38.7%
Taylor expanded in b around inf 83.0%
Final simplification78.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.05e-56)
(+ (/ (* b -0.6666666666666666) a) (* 0.5 (/ c b)))
(if (<= b 2.7e+21)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (- b b) (* a 3.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-56) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 2.7e+21) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (b - b) / (a * 3.0);
}
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.05d-56)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + (0.5d0 * (c / b))
else if (b <= 2.7d+21) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (b - b) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-56) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else if (b <= 2.7e+21) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (b - b) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-56: tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)) elif b <= 2.7e+21: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (b - b) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.05e-56) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(0.5 * Float64(c / b))); elseif (b <= 2.7e+21) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(b - b) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.05e-56) tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)); elseif (b <= 2.7e+21) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (b - b) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-56], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.7e+21], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-56}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{+21}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot 3}\\
\end{array}
\end{array}
if b < -1.05000000000000003e-56Initial program 70.2%
Taylor expanded in b around -inf 87.8%
associate-*r/87.8%
Applied egg-rr87.8%
if -1.05000000000000003e-56 < b < 2.7e21Initial program 76.5%
Taylor expanded in b around 0 66.9%
associate-*r*67.1%
*-commutative67.1%
*-commutative67.1%
Simplified67.1%
if 2.7e21 < b Initial program 38.7%
Taylor expanded in b around inf 83.0%
Final simplification78.8%
(FPCore (a b c) :precision binary64 (if (<= b -1.36e-307) (+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a))) (/ (- b b) (* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.36e-307) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else {
tmp = (b - b) / (a * 3.0);
}
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.36d-307)) then
tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / a))
else
tmp = (b - b) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.36e-307) {
tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
} else {
tmp = (b - b) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.36e-307: tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)) else: tmp = (b - b) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.36e-307) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / a))); else tmp = Float64(Float64(b - b) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.36e-307) tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a)); else tmp = (b - b) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.36e-307], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.36 \cdot 10^{-307}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot 3}\\
\end{array}
\end{array}
if b < -1.36e-307Initial program 73.0%
Taylor expanded in b around -inf 65.0%
if -1.36e-307 < b Initial program 53.4%
Taylor expanded in b around inf 53.5%
Final simplification59.4%
(FPCore (a b c) :precision binary64 (if (<= b -1.55e-307) (+ (/ (* b -0.6666666666666666) a) (* 0.5 (/ c b))) (/ (- b b) (* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.55e-307) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else {
tmp = (b - b) / (a * 3.0);
}
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.55d-307)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + (0.5d0 * (c / b))
else
tmp = (b - b) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.55e-307) {
tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b));
} else {
tmp = (b - b) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.55e-307: tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)) else: tmp = (b - b) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.55e-307) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(0.5 * Float64(c / b))); else tmp = Float64(Float64(b - b) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.55e-307) tmp = ((b * -0.6666666666666666) / a) + (0.5 * (c / b)); else tmp = (b - b) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.55e-307], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.55 \cdot 10^{-307}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot 3}\\
\end{array}
\end{array}
if b < -1.5499999999999999e-307Initial program 73.0%
Taylor expanded in b around -inf 65.0%
associate-*r/65.0%
Applied egg-rr65.0%
if -1.5499999999999999e-307 < b Initial program 53.4%
Taylor expanded in b around inf 53.5%
Final simplification59.4%
(FPCore (a b c) :precision binary64 (if (<= b 2.6e-299) (/ 1.0 (* -1.5 (/ a b))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.6e-299) {
tmp = 1.0 / (-1.5 * (a / b));
} else {
tmp = (c / b) * -0.5;
}
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.6d-299) then
tmp = 1.0d0 / ((-1.5d0) * (a / b))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.6e-299) {
tmp = 1.0 / (-1.5 * (a / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.6e-299: tmp = 1.0 / (-1.5 * (a / b)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.6e-299) tmp = Float64(1.0 / Float64(-1.5 * Float64(a / b))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.6e-299) tmp = 1.0 / (-1.5 * (a / b)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.6e-299], N[(1.0 / N[(-1.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{-299}:\\
\;\;\;\;\frac{1}{-1.5 \cdot \frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.5999999999999999e-299Initial program 73.3%
Taylor expanded in b around -inf 63.9%
*-commutative63.9%
Simplified63.9%
associate-*l/63.9%
*-commutative63.9%
clear-num63.8%
*-un-lft-identity63.8%
times-frac64.0%
metadata-eval64.0%
Applied egg-rr64.0%
if 2.5999999999999999e-299 < b Initial program 52.7%
Taylor expanded in b around inf 27.3%
Final simplification46.3%
(FPCore (a b c) :precision binary64 (if (<= b -1.5e-305) (/ 1.0 (* -1.5 (/ a b))) (/ (- b b) (* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-305) {
tmp = 1.0 / (-1.5 * (a / b));
} else {
tmp = (b - b) / (a * 3.0);
}
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-305)) then
tmp = 1.0d0 / ((-1.5d0) * (a / b))
else
tmp = (b - b) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-305) {
tmp = 1.0 / (-1.5 * (a / b));
} else {
tmp = (b - b) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e-305: tmp = 1.0 / (-1.5 * (a / b)) else: tmp = (b - b) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e-305) tmp = Float64(1.0 / Float64(-1.5 * Float64(a / b))); else tmp = Float64(Float64(b - b) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.5e-305) tmp = 1.0 / (-1.5 * (a / b)); else tmp = (b - b) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-305], N[(1.0 / N[(-1.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-305}:\\
\;\;\;\;\frac{1}{-1.5 \cdot \frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot 3}\\
\end{array}
\end{array}
if b < -1.5000000000000001e-305Initial program 73.5%
Taylor expanded in b around -inf 65.3%
*-commutative65.3%
Simplified65.3%
associate-*l/65.3%
*-commutative65.3%
clear-num65.2%
*-un-lft-identity65.2%
times-frac65.4%
metadata-eval65.4%
Applied egg-rr65.4%
if -1.5000000000000001e-305 < b Initial program 53.1%
Taylor expanded in b around inf 53.1%
Final simplification59.3%
(FPCore (a b c) :precision binary64 (if (<= b 2.05e-299) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.05e-299) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
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-299) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.05e-299) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.05e-299: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.05e-299) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.05e-299) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.05e-299], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.05 \cdot 10^{-299}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.05e-299Initial program 73.3%
Applied egg-rr62.4%
sub-neg62.4%
distribute-rgt-out--62.4%
Simplified62.4%
Taylor expanded in b around -inf 63.9%
*-commutative63.9%
associate-*l/63.9%
associate-*r/63.8%
Simplified63.8%
if 2.05e-299 < b Initial program 52.7%
Taylor expanded in b around inf 27.3%
Final simplification46.2%
(FPCore (a b c) :precision binary64 (if (<= b 2.15e-299) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.15e-299) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
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.15d-299) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.15e-299) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.15e-299: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.15e-299) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.15e-299) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.15e-299], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.15 \cdot 10^{-299}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.1499999999999999e-299Initial program 73.3%
Taylor expanded in b around -inf 63.9%
*-commutative63.9%
Simplified63.9%
if 2.1499999999999999e-299 < b Initial program 52.7%
Taylor expanded in b around inf 27.3%
Final simplification46.3%
(FPCore (a b c) :precision binary64 (* (/ c b) -0.5))
double code(double a, double b, double c) {
return (c / b) * -0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * (-0.5d0)
end function
public static double code(double a, double b, double c) {
return (c / b) * -0.5;
}
def code(a, b, c): return (c / b) * -0.5
function code(a, b, c) return Float64(Float64(c / b) * -0.5) end
function tmp = code(a, b, c) tmp = (c / b) * -0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot -0.5
\end{array}
Initial program 63.4%
Taylor expanded in b around inf 14.1%
Final simplification14.1%
herbie shell --seed 2024018
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))