
(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 -15500000.0)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 4e-77)
(* (- b (hypot b (sqrt (* c (* a -3.0))))) (/ -0.3333333333333333 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -15500000.0) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 4e-77) {
tmp = (b - hypot(b, sqrt((c * (a * -3.0))))) * (-0.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
public static double code(double a, double b, double c) {
double tmp;
if (b <= -15500000.0) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 4e-77) {
tmp = (b - Math.hypot(b, Math.sqrt((c * (a * -3.0))))) * (-0.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -15500000.0: tmp = (b * -2.0) / (3.0 * a) elif b <= 4e-77: tmp = (b - math.hypot(b, math.sqrt((c * (a * -3.0))))) * (-0.3333333333333333 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -15500000.0) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 4e-77) tmp = Float64(Float64(b - hypot(b, sqrt(Float64(c * Float64(a * -3.0))))) * Float64(-0.3333333333333333 / 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 <= -15500000.0) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 4e-77) tmp = (b - hypot(b, sqrt((c * (a * -3.0))))) * (-0.3333333333333333 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -15500000.0], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e-77], N[(N[(b - N[Sqrt[b ^ 2 + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -15500000:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-77}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.55e7Initial program 66.9%
Taylor expanded in b around -inf 97.4%
*-commutative97.4%
Simplified97.4%
if -1.55e7 < b < 3.9999999999999997e-77Initial program 75.6%
/-rgt-identity75.6%
metadata-eval75.6%
associate-/r/75.6%
metadata-eval75.6%
metadata-eval75.6%
times-frac75.6%
*-commutative75.6%
times-frac75.5%
*-commutative75.5%
associate-/r*75.4%
associate-*l/75.4%
Simplified75.4%
expm1-log1p-u50.0%
expm1-udef27.2%
Applied egg-rr28.0%
expm1-def52.5%
expm1-log1p77.9%
associate-*r/77.9%
*-commutative77.9%
associate-*r/78.0%
/-rgt-identity78.0%
/-rgt-identity78.0%
associate-*r*77.9%
*-commutative77.9%
associate-*l*77.9%
Simplified77.9%
if 3.9999999999999997e-77 < b Initial program 17.5%
Taylor expanded in b around inf 87.3%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e+135)
(* (- (- (* (/ c b) (* a 1.5)) b) b) (/ 1.0 (/ a 0.3333333333333333)))
(if (<= b 2.5e-77)
(* (/ 0.3333333333333333 a) (- (sqrt (- (* b b) (* 3.0 (* a c)))) b))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e+135) {
tmp = ((((c / b) * (a * 1.5)) - b) - b) * (1.0 / (a / 0.3333333333333333));
} else if (b <= 2.5e-77) {
tmp = (0.3333333333333333 / a) * (sqrt(((b * b) - (3.0 * (a * c)))) - b);
} 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 <= (-7.5d+135)) then
tmp = ((((c / b) * (a * 1.5d0)) - b) - b) * (1.0d0 / (a / 0.3333333333333333d0))
else if (b <= 2.5d-77) then
tmp = (0.3333333333333333d0 / a) * (sqrt(((b * b) - (3.0d0 * (a * c)))) - b)
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 <= -7.5e+135) {
tmp = ((((c / b) * (a * 1.5)) - b) - b) * (1.0 / (a / 0.3333333333333333));
} else if (b <= 2.5e-77) {
tmp = (0.3333333333333333 / a) * (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e+135: tmp = ((((c / b) * (a * 1.5)) - b) - b) * (1.0 / (a / 0.3333333333333333)) elif b <= 2.5e-77: tmp = (0.3333333333333333 / a) * (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e+135) tmp = Float64(Float64(Float64(Float64(Float64(c / b) * Float64(a * 1.5)) - b) - b) * Float64(1.0 / Float64(a / 0.3333333333333333))); elseif (b <= 2.5e-77) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.5e+135) tmp = ((((c / b) * (a * 1.5)) - b) - b) * (1.0 / (a / 0.3333333333333333)); elseif (b <= 2.5e-77) tmp = (0.3333333333333333 / a) * (sqrt(((b * b) - (3.0 * (a * c)))) - b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e+135], N[(N[(N[(N[(N[(c / b), $MachinePrecision] * N[(a * 1.5), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] * N[(1.0 / N[(a / 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-77], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{+135}:\\
\;\;\;\;\left(\left(\frac{c}{b} \cdot \left(a \cdot 1.5\right) - b\right) - b\right) \cdot \frac{1}{\frac{a}{0.3333333333333333}}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-77}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -7.49999999999999947e135Initial program 41.2%
neg-sub041.2%
associate-+l-41.2%
sub0-neg41.2%
neg-mul-141.2%
associate-*r/41.2%
*-commutative41.2%
metadata-eval41.2%
metadata-eval41.2%
times-frac41.2%
*-commutative41.2%
times-frac41.2%
Simplified41.2%
fma-udef41.2%
associate-*r*41.2%
*-commutative41.2%
metadata-eval41.2%
cancel-sign-sub-inv41.2%
Applied egg-rr41.2%
Taylor expanded in b around -inf 84.8%
neg-mul-184.8%
unsub-neg84.8%
associate-*l/99.6%
*-commutative99.6%
associate-*l*99.6%
Simplified99.6%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
Simplified99.7%
if -7.49999999999999947e135 < b < 2.49999999999999982e-77Initial program 82.1%
neg-sub082.1%
associate-+l-82.1%
sub0-neg82.1%
neg-mul-182.1%
associate-*r/82.1%
*-commutative82.1%
metadata-eval82.1%
metadata-eval82.1%
times-frac82.1%
*-commutative82.1%
times-frac82.0%
Simplified82.0%
fma-udef82.0%
associate-*r*81.9%
*-commutative81.9%
metadata-eval81.9%
cancel-sign-sub-inv81.9%
Applied egg-rr81.9%
if 2.49999999999999982e-77 < b Initial program 17.5%
Taylor expanded in b around inf 87.3%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e+150)
(* (- (- (* (/ c b) (* a 1.5)) b) b) (/ 0.3333333333333333 a))
(if (<= b 2.9e-77)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e+150) {
tmp = ((((c / b) * (a * 1.5)) - b) - b) * (0.3333333333333333 / a);
} else if (b <= 2.9e-77) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (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 <= (-4.6d+150)) then
tmp = ((((c / b) * (a * 1.5d0)) - b) - b) * (0.3333333333333333d0 / a)
else if (b <= 2.9d-77) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (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 <= -4.6e+150) {
tmp = ((((c / b) * (a * 1.5)) - b) - b) * (0.3333333333333333 / a);
} else if (b <= 2.9e-77) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e+150: tmp = ((((c / b) * (a * 1.5)) - b) - b) * (0.3333333333333333 / a) elif b <= 2.9e-77: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e+150) tmp = Float64(Float64(Float64(Float64(Float64(c / b) * Float64(a * 1.5)) - b) - b) * Float64(0.3333333333333333 / a)); elseif (b <= 2.9e-77) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(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 <= -4.6e+150) tmp = ((((c / b) * (a * 1.5)) - b) - b) * (0.3333333333333333 / a); elseif (b <= 2.9e-77) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e+150], N[(N[(N[(N[(N[(c / b), $MachinePrecision] * N[(a * 1.5), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.9e-77], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{+150}:\\
\;\;\;\;\left(\left(\frac{c}{b} \cdot \left(a \cdot 1.5\right) - b\right) - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-77}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.60000000000000002e150Initial program 34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
associate-*r/34.1%
*-commutative34.1%
metadata-eval34.1%
metadata-eval34.1%
times-frac34.1%
*-commutative34.1%
times-frac34.1%
Simplified34.1%
fma-udef34.1%
associate-*r*34.1%
*-commutative34.1%
metadata-eval34.1%
cancel-sign-sub-inv34.1%
Applied egg-rr34.1%
Taylor expanded in b around -inf 82.9%
neg-mul-182.9%
unsub-neg82.9%
associate-*l/99.6%
*-commutative99.6%
associate-*l*99.6%
Simplified99.6%
if -4.60000000000000002e150 < b < 2.8999999999999999e-77Initial program 82.8%
neg-sub082.8%
associate-+l-82.8%
sub0-neg82.8%
neg-mul-182.8%
associate-*r/82.8%
metadata-eval82.8%
metadata-eval82.8%
times-frac82.8%
*-commutative82.8%
times-frac82.6%
associate-*l/82.8%
Simplified82.7%
if 2.8999999999999999e-77 < b Initial program 17.5%
Taylor expanded in b around inf 87.3%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.12e+151)
(* (- (- (* (/ c b) (* a 1.5)) b) b) (/ 0.3333333333333333 a))
(if (<= b 4.5e-78)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.12e+151) {
tmp = ((((c / b) * (a * 1.5)) - b) - b) * (0.3333333333333333 / a);
} else if (b <= 4.5e-78) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (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 <= (-1.12d+151)) then
tmp = ((((c / b) * (a * 1.5d0)) - b) - b) * (0.3333333333333333d0 / a)
else if (b <= 4.5d-78) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (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 <= -1.12e+151) {
tmp = ((((c / b) * (a * 1.5)) - b) - b) * (0.3333333333333333 / a);
} else if (b <= 4.5e-78) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.12e+151: tmp = ((((c / b) * (a * 1.5)) - b) - b) * (0.3333333333333333 / a) elif b <= 4.5e-78: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.12e+151) tmp = Float64(Float64(Float64(Float64(Float64(c / b) * Float64(a * 1.5)) - b) - b) * Float64(0.3333333333333333 / a)); elseif (b <= 4.5e-78) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(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 <= -1.12e+151) tmp = ((((c / b) * (a * 1.5)) - b) - b) * (0.3333333333333333 / a); elseif (b <= 4.5e-78) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.12e+151], N[(N[(N[(N[(N[(c / b), $MachinePrecision] * N[(a * 1.5), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-78], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.12 \cdot 10^{+151}:\\
\;\;\;\;\left(\left(\frac{c}{b} \cdot \left(a \cdot 1.5\right) - b\right) - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-78}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.12000000000000004e151Initial program 34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
associate-*r/34.1%
*-commutative34.1%
metadata-eval34.1%
metadata-eval34.1%
times-frac34.1%
*-commutative34.1%
times-frac34.1%
Simplified34.1%
fma-udef34.1%
associate-*r*34.1%
*-commutative34.1%
metadata-eval34.1%
cancel-sign-sub-inv34.1%
Applied egg-rr34.1%
Taylor expanded in b around -inf 82.9%
neg-mul-182.9%
unsub-neg82.9%
associate-*l/99.6%
*-commutative99.6%
associate-*l*99.6%
Simplified99.6%
if -1.12000000000000004e151 < b < 4.5e-78Initial program 82.8%
if 4.5e-78 < b Initial program 17.5%
Taylor expanded in b around inf 87.3%
Final simplification86.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.66e-195)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 4.8e-78)
(* (/ 0.3333333333333333 a) (- (sqrt (* a (* c -3.0))) b))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.66e-195) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 4.8e-78) {
tmp = (0.3333333333333333 / a) * (sqrt((a * (c * -3.0))) - b);
} 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.66d-195)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 4.8d-78) then
tmp = (0.3333333333333333d0 / a) * (sqrt((a * (c * (-3.0d0)))) - b)
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.66e-195) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 4.8e-78) {
tmp = (0.3333333333333333 / a) * (Math.sqrt((a * (c * -3.0))) - b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.66e-195: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 4.8e-78: tmp = (0.3333333333333333 / a) * (math.sqrt((a * (c * -3.0))) - b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.66e-195) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 4.8e-78) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(a * Float64(c * -3.0))) - b)); 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.66e-195) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 4.8e-78) tmp = (0.3333333333333333 / a) * (sqrt((a * (c * -3.0))) - b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.66e-195], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.8e-78], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.66 \cdot 10^{-195}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-78}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{a \cdot \left(c \cdot -3\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.66e-195Initial program 71.5%
Taylor expanded in b around -inf 84.8%
if -1.66e-195 < b < 4.79999999999999999e-78Initial program 71.0%
Taylor expanded in b around 0 69.1%
expm1-log1p-u43.7%
expm1-udef19.9%
neg-mul-119.9%
fma-def19.9%
*-commutative19.9%
*-commutative19.9%
*-commutative19.9%
associate-*r*20.0%
Applied egg-rr20.0%
expm1-def43.9%
expm1-log1p69.3%
*-lft-identity69.3%
associate-*l/69.2%
associate-/r*69.1%
metadata-eval69.1%
fma-udef69.1%
neg-mul-169.1%
+-commutative69.1%
unsub-neg69.1%
associate-*r*69.1%
*-commutative69.1%
associate-*l*69.2%
Simplified69.2%
if 4.79999999999999999e-78 < b Initial program 17.5%
Taylor expanded in b around inf 87.3%
Final simplification82.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.66e-195)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 1.25e-77)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.66e-195) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 1.25e-77) {
tmp = (sqrt((c * (a * -3.0))) - b) / (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 <= (-1.66d-195)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 1.25d-77) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (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 <= -1.66e-195) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 1.25e-77) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.66e-195: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 1.25e-77: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.66e-195) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 1.25e-77) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(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 <= -1.66e-195) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 1.25e-77) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.66e-195], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.25e-77], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.66 \cdot 10^{-195}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-77}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.66e-195Initial program 71.5%
Taylor expanded in b around -inf 84.8%
if -1.66e-195 < b < 1.24999999999999991e-77Initial program 71.0%
Taylor expanded in b around 0 69.1%
*-commutative69.1%
*-commutative69.1%
*-commutative69.1%
associate-*l*69.3%
Simplified69.3%
if 1.24999999999999991e-77 < b Initial program 17.5%
Taylor expanded in b around inf 87.3%
Final simplification82.3%
(FPCore (a b c) :precision binary64 (if (<= b -4e-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 <= -4e-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 <= (-4d-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 <= -4e-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 <= -4e-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 <= -4e-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 <= -4e-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, -4e-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 -4 \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 < -3.999999999999988e-310Initial program 72.0%
Taylor expanded in b around -inf 70.6%
if -3.999999999999988e-310 < b Initial program 30.5%
Taylor expanded in b around inf 71.6%
Final simplification71.1%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (* b (/ 1.0 (* a -1.5))) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = b * (1.0 / (a * -1.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 <= (-4d-310)) then
tmp = b * (1.0d0 / (a * (-1.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 <= -4e-310) {
tmp = b * (1.0 / (a * -1.5));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = b * (1.0 / (a * -1.5)) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(b * Float64(1.0 / Float64(a * -1.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 <= -4e-310) tmp = b * (1.0 / (a * -1.5)); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(b * N[(1.0 / N[(a * -1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{1}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.0%
/-rgt-identity72.0%
metadata-eval72.0%
associate-/r/72.0%
metadata-eval72.0%
metadata-eval72.0%
times-frac72.0%
*-commutative72.0%
times-frac71.9%
*-commutative71.9%
associate-/r*71.8%
associate-*l/71.8%
Simplified71.8%
clear-num71.8%
inv-pow71.8%
*-commutative71.8%
fma-udef71.8%
associate-*r*71.8%
add-sqr-sqrt56.6%
hypot-def66.6%
Applied egg-rr66.6%
unpow-166.6%
*-commutative66.6%
associate-*r*66.6%
*-commutative66.6%
associate-*l*66.6%
Simplified66.6%
Taylor expanded in b around -inf 70.3%
*-commutative70.3%
associate-*l/70.3%
Simplified70.3%
associate-/r/70.4%
Applied egg-rr70.4%
if -3.999999999999988e-310 < b Initial program 30.5%
Taylor expanded in b around inf 71.6%
Final simplification70.9%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (* (/ b 3.0) (/ -2.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (b / 3.0) * (-2.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 <= (-4d-310)) then
tmp = (b / 3.0d0) * ((-2.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 <= -4e-310) {
tmp = (b / 3.0) * (-2.0 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (b / 3.0) * (-2.0 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(b / 3.0) * Float64(-2.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 <= -4e-310) tmp = (b / 3.0) * (-2.0 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(b / 3.0), $MachinePrecision] * N[(-2.0 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{3} \cdot \frac{-2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.0%
Taylor expanded in b around -inf 70.4%
*-commutative70.4%
Simplified70.4%
times-frac70.4%
Applied egg-rr70.4%
if -3.999999999999988e-310 < b Initial program 30.5%
Taylor expanded in b around inf 71.6%
Final simplification70.9%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ (* b -2.0) (* 3.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (b * -2.0) / (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 <= (-4d-310)) then
tmp = (b * (-2.0d0)) / (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 <= -4e-310) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (b * -2.0) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(b * -2.0) / Float64(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 <= -4e-310) tmp = (b * -2.0) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.0%
Taylor expanded in b around -inf 70.4%
*-commutative70.4%
Simplified70.4%
if -3.999999999999988e-310 < b Initial program 30.5%
Taylor expanded in b around inf 71.6%
Final simplification70.9%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = b * (-0.6666666666666666 / 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 <= (-4d-310)) then
tmp = b * ((-0.6666666666666666d0) / 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 <= -4e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(b * Float64(-0.6666666666666666 / 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 <= -4e-310) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.0%
Taylor expanded in b around -inf 70.4%
*-commutative70.4%
Simplified70.4%
expm1-log1p-u48.5%
expm1-udef33.9%
times-frac33.9%
Applied egg-rr33.9%
expm1-def48.5%
expm1-log1p70.4%
associate-*r/70.4%
associate-*l/70.4%
associate-/r*70.4%
*-rgt-identity70.4%
associate-*r/70.4%
associate-*l*70.4%
associate-/r*70.3%
metadata-eval70.3%
associate-*r/70.3%
metadata-eval70.3%
Simplified70.3%
if -3.999999999999988e-310 < b Initial program 30.5%
Taylor expanded in b around inf 71.6%
Final simplification70.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 54.3%
Taylor expanded in b around inf 31.8%
Final simplification31.8%
herbie shell --seed 2023213
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))