
(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 12 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 -1.26e+129)
(/ (* b -0.6666666666666666) a)
(if (<= b 4e-94)
(/ (- (sqrt (fma (* a -3.0) c (* b b))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.26e+129) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4e-94) {
tmp = (sqrt(fma((a * -3.0), c, (b * b))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.26e+129) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4e-94) tmp = Float64(Float64(sqrt(fma(Float64(a * -3.0), c, Float64(b * b))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.26e+129], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4e-94], N[(N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.26 \cdot 10^{+129}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-94}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.26e129Initial program 63.6%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6497.5
Applied rewrites97.5%
if -1.26e129 < b < 3.9999999999999998e-94Initial program 85.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-eval85.3
Applied rewrites85.3%
if 3.9999999999999998e-94 < b Initial program 18.0%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6489.7
Applied rewrites89.7%
Final simplification88.8%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+154)
(/ (* b -0.6666666666666666) a)
(if (<= b 4e-94)
(/ (* (- (sqrt (fma b b (* a (* c -3.0)))) b) 0.3333333333333333) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+154) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4e-94) {
tmp = ((sqrt(fma(b, b, (a * (c * -3.0)))) - b) * 0.3333333333333333) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+154) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4e-94) tmp = Float64(Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -3.0)))) - b) * 0.3333333333333333) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+154], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4e-94], N[(N[(N[(N[Sqrt[N[(b * b + N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+154}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-94}:\\
\;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b\right) \cdot 0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.00000000000000004e154Initial program 52.1%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.7
Applied rewrites96.7%
if -5.00000000000000004e154 < b < 3.9999999999999998e-94Initial program 86.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-eval86.3
Applied rewrites86.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites86.3%
if 3.9999999999999998e-94 < b Initial program 18.0%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6489.7
Applied rewrites89.7%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -3.2e+129)
(/ (* b -0.6666666666666666) a)
(if (<= b 4e-94)
(* (- (sqrt (fma b b (* a (* c -3.0)))) b) (/ 0.3333333333333333 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.2e+129) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4e-94) {
tmp = (sqrt(fma(b, b, (a * (c * -3.0)))) - b) * (0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.2e+129) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4e-94) tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -3.0)))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.2e+129], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4e-94], N[(N[(N[Sqrt[N[(b * b + N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.2 \cdot 10^{+129}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-94}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.2000000000000002e129Initial program 62.6%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6497.5
Applied rewrites97.5%
if -3.2000000000000002e129 < b < 3.9999999999999998e-94Initial program 85.4%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-eval85.4
Applied rewrites85.4%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6485.3
lift-+.f64N/A
+-commutativeN/A
lift-sqrt.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-neg.f64N/A
unsub-negN/A
lower--.f64N/A
Applied rewrites85.3%
if 3.9999999999999998e-94 < b Initial program 18.0%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6489.7
Applied rewrites89.7%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -3.2e+129)
(/ (* b -0.6666666666666666) a)
(if (<= b 4e-94)
(* (/ -0.3333333333333333 a) (- b (sqrt (fma a (* c -3.0) (* b b)))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.2e+129) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4e-94) {
tmp = (-0.3333333333333333 / a) * (b - sqrt(fma(a, (c * -3.0), (b * b))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.2e+129) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4e-94) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(fma(a, Float64(c * -3.0), Float64(b * b))))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.2e+129], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4e-94], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.2 \cdot 10^{+129}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-94}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.2000000000000002e129Initial program 62.6%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6497.5
Applied rewrites97.5%
if -3.2000000000000002e129 < b < 3.9999999999999998e-94Initial program 85.4%
Applied rewrites85.3%
if 3.9999999999999998e-94 < b Initial program 18.0%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6489.7
Applied rewrites89.7%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -6.4e-121)
(/ (/ b -1.5) a)
(if (<= b 3.8e-94)
(/ (* 0.3333333333333333 (- (sqrt (* c (* a -3.0))) b)) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.4e-121) {
tmp = (b / -1.5) / a;
} else if (b <= 3.8e-94) {
tmp = (0.3333333333333333 * (sqrt((c * (a * -3.0))) - 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 <= (-6.4d-121)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 3.8d-94) then
tmp = (0.3333333333333333d0 * (sqrt((c * (a * (-3.0d0)))) - 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 <= -6.4e-121) {
tmp = (b / -1.5) / a;
} else if (b <= 3.8e-94) {
tmp = (0.3333333333333333 * (Math.sqrt((c * (a * -3.0))) - b)) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.4e-121: tmp = (b / -1.5) / a elif b <= 3.8e-94: tmp = (0.3333333333333333 * (math.sqrt((c * (a * -3.0))) - b)) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.4e-121) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 3.8e-94) tmp = Float64(Float64(0.3333333333333333 * Float64(sqrt(Float64(c * Float64(a * -3.0))) - b)) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.4e-121) tmp = (b / -1.5) / a; elseif (b <= 3.8e-94) tmp = (0.3333333333333333 * (sqrt((c * (a * -3.0))) - b)) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.4e-121], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.8e-94], N[(N[(0.3333333333333333 * N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.4 \cdot 10^{-121}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-94}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot \left(\sqrt{c \cdot \left(a \cdot -3\right)} - b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.40000000000000038e-121Initial program 83.6%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6483.6
Applied rewrites83.6%
Applied rewrites83.7%
if -6.40000000000000038e-121 < b < 3.79999999999999999e-94Initial program 74.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-eval74.8
Applied rewrites74.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites74.7%
Taylor expanded in b around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6473.1
Applied rewrites73.1%
if 3.79999999999999999e-94 < b Initial program 18.0%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6489.7
Applied rewrites89.7%
Final simplification83.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.2e-308) (/ (/ b -1.5) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.2e-308) {
tmp = (b / -1.5) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.2d-308) then
tmp = (b / (-1.5d0)) / a
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.2e-308) {
tmp = (b / -1.5) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.2e-308: tmp = (b / -1.5) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.2e-308) tmp = Float64(Float64(b / -1.5) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.2e-308) tmp = (b / -1.5) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.2e-308], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.2 \cdot 10^{-308}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.1999999999999998e-308Initial program 80.5%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.9
Applied rewrites69.9%
Applied rewrites70.0%
if 1.1999999999999998e-308 < b Initial program 34.9%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.0
Applied rewrites69.0%
(FPCore (a b c) :precision binary64 (if (<= b 1.2e-308) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.2e-308) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.2d-308) then
tmp = (b * (-0.6666666666666666d0)) / a
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.2e-308) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.2e-308: tmp = (b * -0.6666666666666666) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.2e-308) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.2e-308) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.2e-308], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.2 \cdot 10^{-308}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.1999999999999998e-308Initial program 80.5%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.9
Applied rewrites69.9%
if 1.1999999999999998e-308 < b Initial program 34.9%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.0
Applied rewrites69.0%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e+42) (/ (* b -0.6666666666666666) a) (/ (* c 0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e+42) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 3.1d+42) then
tmp = (b * (-0.6666666666666666d0)) / a
else
tmp = (c * 0.5d0) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e+42) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e+42: tmp = (b * -0.6666666666666666) / a else: tmp = (c * 0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e+42) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c * 0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.1e+42) tmp = (b * -0.6666666666666666) / a; else tmp = (c * 0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e+42], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{+42}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 3.1000000000000002e42Initial program 73.3%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6447.9
Applied rewrites47.9%
if 3.1000000000000002e42 < b Initial program 16.9%
Applied rewrites5.8%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f6438.4
Applied rewrites38.4%
Final simplification45.0%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e+42) (/ b (* a -1.5)) (/ (* c 0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e+42) {
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 <= 3.1d+42) 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 <= 3.1e+42) {
tmp = b / (a * -1.5);
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e+42: tmp = b / (a * -1.5) else: tmp = (c * 0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e+42) 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 <= 3.1e+42) tmp = b / (a * -1.5); else tmp = (c * 0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e+42], 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 3.1 \cdot 10^{+42}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 3.1000000000000002e42Initial program 73.3%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6447.9
Applied rewrites47.9%
Applied rewrites47.9%
if 3.1000000000000002e42 < b Initial program 16.9%
Applied rewrites5.8%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f6438.4
Applied rewrites38.4%
Final simplification45.0%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e+42) (* b (/ -0.6666666666666666 a)) (/ (* c 0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e+42) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 3.1d+42) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = (c * 0.5d0) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e+42) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e+42: tmp = b * (-0.6666666666666666 / a) else: tmp = (c * 0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e+42) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(c * 0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.1e+42) tmp = b * (-0.6666666666666666 / a); else tmp = (c * 0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e+42], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{+42}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 3.1000000000000002e42Initial program 73.3%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6447.9
Applied rewrites47.9%
Applied rewrites47.8%
if 3.1000000000000002e42 < b Initial program 16.9%
Applied rewrites5.8%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f6438.4
Applied rewrites38.4%
Final simplification45.0%
(FPCore (a b c) :precision binary64 (/ (* c 0.5) b))
double code(double a, double b, double c) {
return (c * 0.5) / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c * 0.5d0) / b
end function
public static double code(double a, double b, double c) {
return (c * 0.5) / b;
}
def code(a, b, c): return (c * 0.5) / b
function code(a, b, c) return Float64(Float64(c * 0.5) / b) end
function tmp = code(a, b, c) tmp = (c * 0.5) / b; end
code[a_, b_, c_] := N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot 0.5}{b}
\end{array}
Initial program 56.1%
Applied rewrites31.6%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f6413.8
Applied rewrites13.8%
Final simplification13.8%
(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 56.1%
Applied rewrites31.6%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f642.5
Applied rewrites2.5%
Applied rewrites2.5%
Final simplification2.5%
herbie shell --seed 2024227
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))