
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e+85)
(/ (- b) (* 1.5 a))
(if (<= b 1.35e-68)
(/ (- (sqrt (fma (* -3.0 a) c (* b b))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e+85) {
tmp = -b / (1.5 * a);
} else if (b <= 1.35e-68) {
tmp = (sqrt(fma((-3.0 * a), c, (b * b))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.8e+85) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 1.35e-68) tmp = Float64(Float64(sqrt(fma(Float64(-3.0 * a), c, Float64(b * b))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.8e+85], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-68], N[(N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{+85}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-68}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.79999999999999993e85Initial program 58.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6493.2
Applied rewrites93.2%
Applied rewrites93.3%
if -4.79999999999999993e85 < b < 1.3500000000000001e-68Initial program 81.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval81.9
Applied rewrites81.9%
if 1.3500000000000001e-68 < b Initial program 15.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e+85)
(/ (- b) (* 1.5 a))
(if (<= b 1.35e-68)
(/ (- (sqrt (fma (* -3.0 c) a (* b b))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e+85) {
tmp = -b / (1.5 * a);
} else if (b <= 1.35e-68) {
tmp = (sqrt(fma((-3.0 * c), a, (b * b))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.8e+85) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 1.35e-68) tmp = Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.8e+85], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-68], N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{+85}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-68}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.79999999999999993e85Initial program 58.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6493.2
Applied rewrites93.2%
Applied rewrites93.3%
if -4.79999999999999993e85 < b < 1.3500000000000001e-68Initial program 81.9%
Applied rewrites81.8%
if 1.3500000000000001e-68 < b Initial program 15.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e+85)
(/ (- b) (* 1.5 a))
(if (<= b 1.35e-68)
(* (/ 0.3333333333333333 a) (- (sqrt (fma (* -3.0 c) a (* b b))) b))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e+85) {
tmp = -b / (1.5 * a);
} else if (b <= 1.35e-68) {
tmp = (0.3333333333333333 / a) * (sqrt(fma((-3.0 * c), a, (b * b))) - b);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.8e+85) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 1.35e-68) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.8e+85], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-68], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{+85}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-68}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.79999999999999993e85Initial program 58.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6493.2
Applied rewrites93.2%
Applied rewrites93.3%
if -4.79999999999999993e85 < b < 1.3500000000000001e-68Initial program 81.9%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval81.7
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6481.7
Applied rewrites81.8%
if 1.3500000000000001e-68 < b Initial program 15.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-40)
(/ (- b) (* 1.5 a))
(if (<= b 1.35e-68)
(/ (- (sqrt (* (* -3.0 a) c)) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-40) {
tmp = -b / (1.5 * a);
} else if (b <= 1.35e-68) {
tmp = (sqrt(((-3.0 * a) * c)) - 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 <= (-1.25d-40)) then
tmp = -b / (1.5d0 * a)
else if (b <= 1.35d-68) then
tmp = (sqrt((((-3.0d0) * a) * c)) - 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 <= -1.25e-40) {
tmp = -b / (1.5 * a);
} else if (b <= 1.35e-68) {
tmp = (Math.sqrt(((-3.0 * a) * c)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e-40: tmp = -b / (1.5 * a) elif b <= 1.35e-68: tmp = (math.sqrt(((-3.0 * a) * c)) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e-40) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 1.35e-68) tmp = Float64(Float64(sqrt(Float64(Float64(-3.0 * a) * c)) - b) / Float64(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 <= -1.25e-40) tmp = -b / (1.5 * a); elseif (b <= 1.35e-68) tmp = (sqrt(((-3.0 * a) * c)) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e-40], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-68], N[(N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-40}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-68}:\\
\;\;\;\;\frac{\sqrt{\left(-3 \cdot a\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.24999999999999991e-40Initial program 70.3%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6487.7
Applied rewrites87.7%
Applied rewrites87.9%
if -1.24999999999999991e-40 < b < 1.3500000000000001e-68Initial program 76.8%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
Applied rewrites67.4%
Taylor expanded in a around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6467.6
Applied rewrites67.6%
if 1.3500000000000001e-68 < b Initial program 15.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
Final simplification80.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-40)
(/ (- b) (* 1.5 a))
(if (<= b 1.35e-68)
(* (- (sqrt (* (* -3.0 c) a)) b) (/ 0.3333333333333333 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-40) {
tmp = -b / (1.5 * a);
} else if (b <= 1.35e-68) {
tmp = (sqrt(((-3.0 * c) * a)) - b) * (0.3333333333333333 / 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 <= (-1.25d-40)) then
tmp = -b / (1.5d0 * a)
else if (b <= 1.35d-68) then
tmp = (sqrt((((-3.0d0) * c) * a)) - b) * (0.3333333333333333d0 / 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 <= -1.25e-40) {
tmp = -b / (1.5 * a);
} else if (b <= 1.35e-68) {
tmp = (Math.sqrt(((-3.0 * c) * a)) - b) * (0.3333333333333333 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e-40: tmp = -b / (1.5 * a) elif b <= 1.35e-68: tmp = (math.sqrt(((-3.0 * c) * a)) - b) * (0.3333333333333333 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e-40) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 1.35e-68) tmp = Float64(Float64(sqrt(Float64(Float64(-3.0 * c) * a)) - b) * Float64(0.3333333333333333 / 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 <= -1.25e-40) tmp = -b / (1.5 * a); elseif (b <= 1.35e-68) tmp = (sqrt(((-3.0 * c) * a)) - b) * (0.3333333333333333 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e-40], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-68], N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-40}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-68}:\\
\;\;\;\;\left(\sqrt{\left(-3 \cdot c\right) \cdot a} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.24999999999999991e-40Initial program 70.3%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6487.7
Applied rewrites87.7%
Applied rewrites87.9%
if -1.24999999999999991e-40 < b < 1.3500000000000001e-68Initial program 76.8%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
Applied rewrites67.4%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval67.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6467.5
Applied rewrites67.5%
if 1.3500000000000001e-68 < b Initial program 15.6%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
Final simplification80.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (fma 0.5 (/ c b) (* -0.6666666666666666 (/ b a))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = fma(0.5, (c / b), (-0.6666666666666666 * (b / a)));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = fma(0.5, Float64(c / b), Float64(-0.6666666666666666 * Float64(b / a))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(0.5 * N[(c / b), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, -0.6666666666666666 \cdot \frac{b}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 75.6%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.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-/.f6465.3
Applied rewrites65.3%
Taylor expanded in a around inf
Applied rewrites65.4%
if -4.999999999999985e-310 < b Initial program 28.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6467.3
Applied rewrites67.3%
Final simplification66.3%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-308) (/ (- b) (* 1.5 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-308) {
tmp = -b / (1.5 * 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.7d-308) then
tmp = -b / (1.5d0 * 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.7e-308) {
tmp = -b / (1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-308: tmp = -b / (1.5 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-308) tmp = Float64(Float64(-b) / Float64(1.5 * 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.7e-308) tmp = -b / (1.5 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-308], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-308}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.70000000000000015e-308Initial program 75.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6464.9
Applied rewrites64.9%
Applied rewrites65.0%
if 2.70000000000000015e-308 < b Initial program 28.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6467.3
Applied rewrites67.3%
Final simplification66.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-308) (/ (* -0.6666666666666666 b) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-308) {
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.7d-308) 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.7e-308) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-308: tmp = (-0.6666666666666666 * b) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-308) tmp = Float64(Float64(-0.6666666666666666 * 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.7e-308) tmp = (-0.6666666666666666 * b) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-308], N[(N[(-0.6666666666666666 * b), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-308}:\\
\;\;\;\;\frac{-0.6666666666666666 \cdot b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.70000000000000015e-308Initial program 75.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6464.9
Applied rewrites64.9%
Applied rewrites64.9%
if 2.70000000000000015e-308 < b Initial program 28.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6467.3
Applied rewrites67.3%
Final simplification66.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-308) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-308) {
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.7d-308) 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.7e-308) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-308: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-308) 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.7e-308) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-308], 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.7 \cdot 10^{-308}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.70000000000000015e-308Initial program 75.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6464.9
Applied rewrites64.9%
if 2.70000000000000015e-308 < b Initial program 28.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6467.3
Applied rewrites67.3%
Final simplification66.0%
(FPCore (a b c) :precision binary64 (if (<= b 4.4e-8) (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.4e-8) {
tmp = -0.6666666666666666 * (b / 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.4d-8) then
tmp = (-0.6666666666666666d0) * (b / 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.4e-8) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.4e-8: tmp = -0.6666666666666666 * (b / a) else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.4e-8) tmp = Float64(-0.6666666666666666 * Float64(b / 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.4e-8) tmp = -0.6666666666666666 * (b / a); else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.4e-8], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.4 \cdot 10^{-8}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 4.3999999999999997e-8Initial program 69.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6449.3
Applied rewrites49.3%
if 4.3999999999999997e-8 < b Initial program 14.7%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.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-/.f642.4
Applied rewrites2.4%
Taylor expanded in a around inf
Applied rewrites26.2%
(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 53.1%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.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-/.f6435.2
Applied rewrites35.2%
Taylor expanded in a around inf
Applied rewrites10.1%
herbie shell --seed 2024283
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))