
(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 -7.6e+77)
(/ (/ (* 2.0 b) a) -3.0)
(if (<= b 4700000.0)
(/ (+ (- b) (sqrt (fma (* -3.0 a) c (* b b)))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.6e+77) {
tmp = ((2.0 * b) / a) / -3.0;
} else if (b <= 4700000.0) {
tmp = (-b + sqrt(fma((-3.0 * a), c, (b * b)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -7.6e+77) tmp = Float64(Float64(Float64(2.0 * b) / a) / -3.0); elseif (b <= 4700000.0) tmp = Float64(Float64(Float64(-b) + sqrt(fma(Float64(-3.0 * a), c, Float64(b * b)))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -7.6e+77], N[(N[(N[(2.0 * b), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 4700000.0], N[(N[((-b) + N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{\frac{2 \cdot b}{a}}{-3}\\
\mathbf{elif}\;b \leq 4700000:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.6000000000000002e77Initial program 61.7%
Applied rewrites61.7%
Taylor expanded in b around -inf
lower-*.f6494.1
Applied rewrites94.1%
if -7.6000000000000002e77 < b < 4.7e6Initial program 82.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval82.8
Applied rewrites82.8%
if 4.7e6 < b Initial program 10.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.3
Applied rewrites87.3%
(FPCore (a b c)
:precision binary64
(if (<= b -8e-20)
(* (fma (/ (/ c b) b) -0.5 (/ 0.6666666666666666 a)) (- b))
(if (<= b 9e-13)
(/ (+ (- b) (sqrt (* (* c a) -3.0))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8e-20) {
tmp = fma(((c / b) / b), -0.5, (0.6666666666666666 / a)) * -b;
} else if (b <= 9e-13) {
tmp = (-b + sqrt(((c * a) * -3.0))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -8e-20) tmp = Float64(fma(Float64(Float64(c / b) / b), -0.5, Float64(0.6666666666666666 / a)) * Float64(-b)); elseif (b <= 9e-13) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(c * a) * -3.0))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -8e-20], N[(N[(N[(N[(c / b), $MachinePrecision] / b), $MachinePrecision] * -0.5 + N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision] * (-b)), $MachinePrecision], If[LessEqual[b, 9e-13], N[(N[((-b) + N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{c}{b}}{b}, -0.5, \frac{0.6666666666666666}{a}\right) \cdot \left(-b\right)\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-13}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\left(c \cdot a\right) \cdot -3}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.99999999999999956e-20Initial program 69.8%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.8
Applied rewrites92.8%
if -7.99999999999999956e-20 < b < 9e-13Initial program 80.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.6
Applied rewrites74.6%
if 9e-13 < b Initial program 11.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.5
Applied rewrites86.5%
(FPCore (a b c)
:precision binary64
(if (<= b -8e-20)
(fma 0.5 (/ c b) (* (/ b a) -0.6666666666666666))
(if (<= b 9e-13)
(/ (+ (- b) (sqrt (* (* c a) -3.0))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8e-20) {
tmp = fma(0.5, (c / b), ((b / a) * -0.6666666666666666));
} else if (b <= 9e-13) {
tmp = (-b + sqrt(((c * a) * -3.0))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -8e-20) tmp = fma(0.5, Float64(c / b), Float64(Float64(b / a) * -0.6666666666666666)); elseif (b <= 9e-13) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(c * a) * -3.0))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -8e-20], N[(0.5 * N[(c / b), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9e-13], N[(N[((-b) + N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-13}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\left(c \cdot a\right) \cdot -3}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.99999999999999956e-20Initial program 69.8%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.8
Applied rewrites92.8%
Taylor expanded in a around inf
Applied rewrites92.8%
if -7.99999999999999956e-20 < b < 9e-13Initial program 80.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.6
Applied rewrites74.6%
if 9e-13 < b Initial program 11.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.5
Applied rewrites86.5%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (fma 0.5 (/ c b) (* (/ b a) -0.6666666666666666)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = fma(0.5, (c / b), ((b / a) * -0.6666666666666666));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = fma(0.5, Float64(c / b), Float64(Float64(b / a) * -0.6666666666666666)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(0.5 * N[(c / b), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 74.5%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.8
Applied rewrites67.8%
Taylor expanded in a around inf
Applied rewrites67.9%
if -3.999999999999988e-310 < b Initial program 34.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6462.7
Applied rewrites62.7%
(FPCore (a b c) :precision binary64 (if (<= b 7e-305) (/ (/ (* 2.0 b) a) -3.0) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7e-305) {
tmp = ((2.0 * b) / a) / -3.0;
} 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 <= 7d-305) then
tmp = ((2.0d0 * b) / a) / (-3.0d0)
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 <= 7e-305) {
tmp = ((2.0 * b) / a) / -3.0;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7e-305: tmp = ((2.0 * b) / a) / -3.0 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7e-305) tmp = Float64(Float64(Float64(2.0 * b) / a) / -3.0); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7e-305) tmp = ((2.0 * b) / a) / -3.0; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7e-305], N[(N[(N[(2.0 * b), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7 \cdot 10^{-305}:\\
\;\;\;\;\frac{\frac{2 \cdot b}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 6.9999999999999996e-305Initial program 74.7%
Applied rewrites49.5%
Taylor expanded in b around -inf
lower-*.f6467.1
Applied rewrites67.1%
if 6.9999999999999996e-305 < b Initial program 33.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6463.2
Applied rewrites63.2%
(FPCore (a b c) :precision binary64 (if (<= b 7e-305) (* (/ 0.6666666666666666 a) (- b)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7e-305) {
tmp = (0.6666666666666666 / 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 <= 7d-305) then
tmp = (0.6666666666666666d0 / 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 <= 7e-305) {
tmp = (0.6666666666666666 / a) * -b;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7e-305: tmp = (0.6666666666666666 / a) * -b else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7e-305) tmp = Float64(Float64(0.6666666666666666 / a) * Float64(-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 <= 7e-305) tmp = (0.6666666666666666 / a) * -b; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7e-305], N[(N[(0.6666666666666666 / a), $MachinePrecision] * (-b)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7 \cdot 10^{-305}:\\
\;\;\;\;\frac{0.6666666666666666}{a} \cdot \left(-b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 6.9999999999999996e-305Initial program 74.7%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6467.3
Applied rewrites67.3%
Taylor expanded in a around 0
Applied rewrites67.1%
if 6.9999999999999996e-305 < b Initial program 33.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6463.2
Applied rewrites63.2%
(FPCore (a b c) :precision binary64 (if (<= b 7e-305) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7e-305) {
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 <= 7d-305) 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 <= 7e-305) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7e-305: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7e-305) 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 <= 7e-305) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7e-305], 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 7 \cdot 10^{-305}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 6.9999999999999996e-305Initial program 74.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6467.0
Applied rewrites67.0%
if 6.9999999999999996e-305 < b Initial program 33.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6463.2
Applied rewrites63.2%
(FPCore (a b c) :precision binary64 (if (<= b 7e-305) (* -0.6666666666666666 (/ b a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7e-305) {
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 <= 7d-305) 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 <= 7e-305) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7e-305: tmp = -0.6666666666666666 * (b / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7e-305) 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 <= 7e-305) tmp = -0.6666666666666666 * (b / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7e-305], 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 7 \cdot 10^{-305}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 6.9999999999999996e-305Initial program 74.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6467.0
Applied rewrites67.0%
if 6.9999999999999996e-305 < b Initial program 33.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6463.2
Applied rewrites63.2%
Applied rewrites62.9%
(FPCore (a b c) :precision binary64 (if (<= b -3.3e-302) (* -0.6666666666666666 (/ b a)) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.3e-302) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.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 <= (-3.3d-302)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.3e-302) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.3e-302: tmp = -0.6666666666666666 * (b / a) else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.3e-302) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.3e-302) tmp = -0.6666666666666666 * (b / a); else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.3e-302], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.3 \cdot 10^{-302}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -3.3000000000000002e-302Initial program 75.1%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6468.0
Applied rewrites68.0%
if -3.3000000000000002e-302 < b Initial program 33.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval33.8
Applied rewrites33.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6433.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6433.8
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6433.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.8
Applied rewrites33.8%
Applied rewrites32.0%
Taylor expanded in a around 0
associate-*r/N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
+-inverses14.6
Applied rewrites14.6%
Final simplification41.3%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 54.4%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval54.5
Applied rewrites54.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6454.5
lift-+.f64N/A
+-commutativeN/A
lower-+.f6454.5
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6454.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6454.5
Applied rewrites54.5%
Applied rewrites53.5%
Taylor expanded in a around 0
associate-*r/N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
+-inverses8.6
Applied rewrites8.6%
Final simplification8.6%
herbie shell --seed 2024340
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))