
(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 -8e+136)
(/ (/ (fma b -2.0 (* (/ a b) (* c 1.5))) a) 3.0)
(if (<= b 1.35e-111)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8e+136) {
tmp = (fma(b, -2.0, ((a / b) * (c * 1.5))) / a) / 3.0;
} else if (b <= 1.35e-111) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -8e+136) tmp = Float64(Float64(fma(b, -2.0, Float64(Float64(a / b) * Float64(c * 1.5))) / a) / 3.0); elseif (b <= 1.35e-111) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -8e+136], N[(N[(N[(b * -2.0 + N[(N[(a / b), $MachinePrecision] * N[(c * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 1.35e-111], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8 \cdot 10^{+136}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, -2, \frac{a}{b} \cdot \left(c \cdot 1.5\right)\right)}{a}}{3}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-111}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -8.00000000000000047e136Initial program 37.8%
Taylor expanded in b around -inf 92.6%
add-cube-cbrt91.6%
*-commutative91.6%
times-frac91.7%
pow291.7%
*-commutative91.7%
fma-def91.7%
associate-*r/91.7%
*-commutative91.7%
associate-*r*91.7%
Applied egg-rr91.7%
associate-*r/91.6%
associate-*l/91.6%
unpow291.6%
rem-3cbrt-lft92.7%
*-commutative92.7%
*-rgt-identity92.7%
times-frac93.1%
associate-*r/93.1%
/-rgt-identity93.1%
*-commutative93.1%
Simplified93.1%
if -8.00000000000000047e136 < b < 1.34999999999999994e-111Initial program 81.0%
if 1.34999999999999994e-111 < b Initial program 16.6%
Taylor expanded in b around inf 85.1%
Final simplification84.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.02e-106)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 1.02e-111)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.02e-106) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 1.02e-111) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} 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 <= (-1.02d-106)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 1.02d-111) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (a * 3.0d0)
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 <= -1.02e-106) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 1.02e-111) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.02e-106: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 1.02e-111: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.02e-106) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 1.02e-111) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.02e-106) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 1.02e-111) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.02e-106], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.02e-111], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.02 \cdot 10^{-106}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{-111}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.02e-106Initial program 64.9%
Taylor expanded in b around -inf 83.8%
if -1.02e-106 < b < 1.02000000000000003e-111Initial program 71.7%
prod-diff71.4%
distribute-rgt-neg-in71.4%
*-commutative71.4%
distribute-rgt-neg-in71.4%
metadata-eval71.4%
*-commutative71.4%
fma-udef71.4%
distribute-lft-neg-in71.4%
distribute-rgt-neg-in71.4%
*-commutative71.4%
distribute-rgt-neg-in71.4%
metadata-eval71.4%
*-commutative71.4%
associate-*l*71.3%
Applied egg-rr71.3%
Taylor expanded in b around 0 67.1%
distribute-rgt-out67.4%
*-commutative67.4%
metadata-eval67.4%
associate-*r*67.5%
neg-mul-167.5%
unsub-neg67.5%
associate-*r*67.4%
*-commutative67.4%
associate-*r*67.3%
Simplified67.3%
if 1.02000000000000003e-111 < b Initial program 16.6%
Taylor expanded in b around inf 85.1%
Final simplification80.3%
(FPCore (a b c)
:precision binary64
(if (<= b -9.8e-107)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 3.9e-112)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.8e-107) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 3.9e-112) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} 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 <= (-9.8d-107)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 3.9d-112) then
tmp = (sqrt(((-3.0d0) * (a * c))) - b) / (a * 3.0d0)
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 <= -9.8e-107) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 3.9e-112) {
tmp = (Math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.8e-107: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 3.9e-112: tmp = (math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.8e-107) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 3.9e-112) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.8e-107) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 3.9e-112) tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.8e-107], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.9e-112], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.8 \cdot 10^{-107}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-112}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -9.79999999999999959e-107Initial program 64.9%
Taylor expanded in b around -inf 83.8%
if -9.79999999999999959e-107 < b < 3.9000000000000001e-112Initial program 71.7%
Taylor expanded in b around 0 67.4%
if 3.9000000000000001e-112 < b Initial program 16.6%
Taylor expanded in b around inf 85.1%
Final simplification80.3%
(FPCore (a b c)
:precision binary64
(if (<= b -8.2e-106)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 8.5e-112)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e-106) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 8.5e-112) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} 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 <= (-8.2d-106)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 8.5d-112) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
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 <= -8.2e-106) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 8.5e-112) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.2e-106: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 8.5e-112: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.2e-106) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 8.5e-112) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.2e-106) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 8.5e-112) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.2e-106], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-112], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.2 \cdot 10^{-106}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-112}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -8.1999999999999998e-106Initial program 64.9%
Taylor expanded in b around -inf 83.8%
if -8.1999999999999998e-106 < b < 8.49999999999999992e-112Initial program 71.7%
Taylor expanded in b around 0 67.4%
associate-*r*67.5%
*-commutative67.5%
*-commutative67.5%
Simplified67.5%
if 8.49999999999999992e-112 < b Initial program 16.6%
Taylor expanded in b around inf 85.1%
Final simplification80.3%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-106)
(/ (/ (fma b -2.0 (* (/ a b) (* c 1.5))) a) 3.0)
(if (<= b 1.25e-112)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-106) {
tmp = (fma(b, -2.0, ((a / b) * (c * 1.5))) / a) / 3.0;
} else if (b <= 1.25e-112) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e-106) tmp = Float64(Float64(fma(b, -2.0, Float64(Float64(a / b) * Float64(c * 1.5))) / a) / 3.0); elseif (b <= 1.25e-112) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e-106], N[(N[(N[(b * -2.0 + N[(N[(a / b), $MachinePrecision] * N[(c * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 1.25e-112], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-106}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, -2, \frac{a}{b} \cdot \left(c \cdot 1.5\right)\right)}{a}}{3}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-112}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.99999999999999983e-106Initial program 64.9%
Taylor expanded in b around -inf 83.5%
add-cube-cbrt82.5%
*-commutative82.5%
times-frac82.4%
pow282.4%
*-commutative82.4%
fma-def82.4%
associate-*r/82.4%
*-commutative82.4%
associate-*r*82.4%
Applied egg-rr82.4%
associate-*r/82.4%
associate-*l/82.5%
unpow282.5%
rem-3cbrt-lft83.7%
*-commutative83.7%
*-rgt-identity83.7%
times-frac83.8%
associate-*r/83.8%
/-rgt-identity83.8%
*-commutative83.8%
Simplified83.8%
if -4.99999999999999983e-106 < b < 1.25000000000000011e-112Initial program 71.7%
Taylor expanded in b around 0 67.4%
associate-*r*67.5%
*-commutative67.5%
*-commutative67.5%
Simplified67.5%
if 1.25000000000000011e-112 < b Initial program 16.6%
Taylor expanded in b around inf 85.1%
Final simplification80.3%
(FPCore (a b c)
:precision binary64
(if (<= b -6.6e-106)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 1.35e-111)
(* 0.3333333333333333 (/ (sqrt (* a (* c -3.0))) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e-106) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 1.35e-111) {
tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / 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 <= (-6.6d-106)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 1.35d-111) then
tmp = 0.3333333333333333d0 * (sqrt((a * (c * (-3.0d0)))) / 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 <= -6.6e-106) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 1.35e-111) {
tmp = 0.3333333333333333 * (Math.sqrt((a * (c * -3.0))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.6e-106: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 1.35e-111: tmp = 0.3333333333333333 * (math.sqrt((a * (c * -3.0))) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.6e-106) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 1.35e-111) tmp = Float64(0.3333333333333333 * Float64(sqrt(Float64(a * Float64(c * -3.0))) / 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 <= -6.6e-106) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 1.35e-111) tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.6e-106], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-111], N[(0.3333333333333333 * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{-106}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-111}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -6.60000000000000031e-106Initial program 64.9%
Taylor expanded in b around -inf 83.8%
if -6.60000000000000031e-106 < b < 1.34999999999999994e-111Initial program 71.7%
prod-diff71.4%
distribute-rgt-neg-in71.4%
*-commutative71.4%
distribute-rgt-neg-in71.4%
metadata-eval71.4%
*-commutative71.4%
fma-udef71.4%
distribute-lft-neg-in71.4%
distribute-rgt-neg-in71.4%
*-commutative71.4%
distribute-rgt-neg-in71.4%
metadata-eval71.4%
*-commutative71.4%
associate-*l*71.3%
Applied egg-rr71.3%
Taylor expanded in b around 0 66.1%
associate-*l/66.1%
distribute-rgt-out66.3%
*-commutative66.3%
metadata-eval66.3%
associate-*r*66.2%
*-lft-identity66.2%
associate-*r*66.3%
*-commutative66.3%
associate-*r*66.3%
Simplified66.3%
if 1.34999999999999994e-111 < b Initial program 16.6%
Taylor expanded in b around inf 85.1%
Final simplification80.1%
(FPCore (a b c)
:precision binary64
(if (<= b -6.2e-106)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 7.4e-112)
(/ (sqrt (* c (* a -3.0))) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.2e-106) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 7.4e-112) {
tmp = sqrt((c * (a * -3.0))) / (a * 3.0);
} 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 <= (-6.2d-106)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 7.4d-112) then
tmp = sqrt((c * (a * (-3.0d0)))) / (a * 3.0d0)
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 <= -6.2e-106) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 7.4e-112) {
tmp = Math.sqrt((c * (a * -3.0))) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.2e-106: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 7.4e-112: tmp = math.sqrt((c * (a * -3.0))) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.2e-106) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 7.4e-112) tmp = Float64(sqrt(Float64(c * Float64(a * -3.0))) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.2e-106) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 7.4e-112) tmp = sqrt((c * (a * -3.0))) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.2e-106], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.4e-112], N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.2 \cdot 10^{-106}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 7.4 \cdot 10^{-112}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)}}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -6.19999999999999971e-106Initial program 64.9%
Taylor expanded in b around -inf 83.8%
if -6.19999999999999971e-106 < b < 7.3999999999999996e-112Initial program 71.7%
prod-diff71.4%
distribute-rgt-neg-in71.4%
*-commutative71.4%
distribute-rgt-neg-in71.4%
metadata-eval71.4%
*-commutative71.4%
fma-udef71.4%
distribute-lft-neg-in71.4%
distribute-rgt-neg-in71.4%
*-commutative71.4%
distribute-rgt-neg-in71.4%
metadata-eval71.4%
*-commutative71.4%
associate-*l*71.3%
Applied egg-rr71.3%
+-commutative71.3%
add-sqr-sqrt70.9%
fma-def70.9%
Applied egg-rr70.9%
Taylor expanded in b around 0 66.2%
distribute-rgt-out66.5%
*-commutative66.5%
metadata-eval66.5%
associate-*r*66.6%
*-commutative66.6%
Simplified66.6%
if 7.3999999999999996e-112 < b Initial program 16.6%
Taylor expanded in b around inf 85.1%
Final simplification80.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} 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 <= (-5d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
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 <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.8%
Taylor expanded in b around -inf 71.2%
if -4.999999999999985e-310 < b Initial program 30.7%
Taylor expanded in b around inf 67.0%
Final simplification69.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* (* b 2.0) (/ (/ 1.0 a) -3.0)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * 2.0) * ((1.0 / a) / -3.0);
} 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 <= (-5d-310)) then
tmp = (b * 2.0d0) * ((1.0d0 / a) / (-3.0d0))
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 <= -5e-310) {
tmp = (b * 2.0) * ((1.0 / a) / -3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * 2.0) * ((1.0 / a) / -3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b * 2.0) * Float64(Float64(1.0 / a) / -3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b * 2.0) * ((1.0 / a) / -3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b * 2.0), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] / -3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(b \cdot 2\right) \cdot \frac{\frac{1}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.8%
Applied egg-rr61.8%
associate-/r*61.9%
Simplified61.9%
Taylor expanded in b around -inf 70.6%
*-commutative70.6%
Simplified70.6%
if -4.999999999999985e-310 < b Initial program 30.7%
Taylor expanded in b around inf 67.0%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) 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 <= -5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], 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 -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.8%
Taylor expanded in b around -inf 70.6%
*-commutative70.6%
Simplified70.6%
if -4.999999999999985e-310 < b Initial program 30.7%
Taylor expanded in b around inf 67.0%
Final simplification68.9%
(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 50.9%
Taylor expanded in b around inf 31.9%
Final simplification31.9%
herbie shell --seed 2023333
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))