
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e+136)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 6.8e-38)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e+136) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 6.8e-38) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4.6d+136)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 6.8d-38) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e+136) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 6.8e-38) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e+136: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 6.8e-38: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e+136) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 6.8e-38) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - 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 <= -4.6e+136) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 6.8e-38) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e+136], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.8e-38], 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[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{+136}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.6e136Initial program 43.4%
Taylor expanded in b around -inf 97.9%
if -4.6e136 < b < 6.8000000000000004e-38Initial program 81.8%
if 6.8000000000000004e-38 < b Initial program 12.6%
Taylor expanded in b around inf 94.4%
Final simplification88.8%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e+137)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 8.5e-38)
(* -0.3333333333333333 (/ (- b (sqrt (- (* b b) (* 3.0 (* a c))))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e+137) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 8.5e-38) {
tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / 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 <= (-3.6d+137)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 8.5d-38) then
tmp = (-0.3333333333333333d0) * ((b - sqrt(((b * b) - (3.0d0 * (a * c))))) / 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 <= -3.6e+137) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 8.5e-38) {
tmp = -0.3333333333333333 * ((b - Math.sqrt(((b * b) - (3.0 * (a * c))))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.6e+137: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 8.5e-38: tmp = -0.3333333333333333 * ((b - math.sqrt(((b * b) - (3.0 * (a * c))))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.6e+137) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 8.5e-38) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c))))) / 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 <= -3.6e+137) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 8.5e-38) tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.6e+137], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-38], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{+137}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-38}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.6e137Initial program 43.4%
Taylor expanded in b around -inf 97.9%
if -3.6e137 < b < 8.50000000000000046e-38Initial program 81.8%
/-rgt-identity81.8%
metadata-eval81.8%
associate-/l*81.8%
associate-*r/81.8%
*-commutative81.8%
associate-*l/81.8%
associate-*r/81.8%
metadata-eval81.8%
metadata-eval81.8%
times-frac81.8%
neg-mul-181.8%
distribute-rgt-neg-in81.8%
times-frac81.8%
metadata-eval81.8%
neg-mul-181.8%
Simplified81.7%
fma-udef81.7%
associate-*r*81.7%
*-commutative81.7%
metadata-eval81.7%
cancel-sign-sub-inv81.7%
Applied egg-rr81.7%
if 8.50000000000000046e-38 < b Initial program 12.6%
Taylor expanded in b around inf 94.4%
Final simplification88.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+137)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 2.2e-37)
(* (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (/ 0.3333333333333333 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+137) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.2e-37) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - 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 <= (-1d+137)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 2.2d-37) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - 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 <= -1e+137) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.2e-37) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) * (0.3333333333333333 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e+137: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 2.2e-37: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) * (0.3333333333333333 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e+137) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 2.2e-37) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - 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 <= -1e+137) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 2.2e-37) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) * (0.3333333333333333 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e+137], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.2e-37], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $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 \cdot 10^{+137}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-37}:\\
\;\;\;\;\left(\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1e137Initial program 43.4%
Taylor expanded in b around -inf 97.9%
if -1e137 < b < 2.20000000000000002e-37Initial program 81.8%
neg-sub081.8%
associate-+l-81.8%
sub0-neg81.8%
neg-mul-181.8%
associate-*r/81.8%
*-commutative81.8%
metadata-eval81.8%
metadata-eval81.8%
times-frac81.8%
*-commutative81.8%
times-frac81.8%
Simplified81.8%
fma-udef81.7%
associate-*r*81.7%
*-commutative81.7%
metadata-eval81.7%
cancel-sign-sub-inv81.7%
Applied egg-rr81.7%
if 2.20000000000000002e-37 < b Initial program 12.6%
Taylor expanded in b around inf 94.4%
Final simplification88.8%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e-30)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 7.2e-45)
(* -0.3333333333333333 (/ (- b (sqrt (* (* a c) -3.0))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 7.2e-45) {
tmp = -0.3333333333333333 * ((b - sqrt(((a * c) * -3.0))) / 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 <= (-7.5d-30)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 7.2d-45) then
tmp = (-0.3333333333333333d0) * ((b - sqrt(((a * c) * (-3.0d0)))) / 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 <= -7.5e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 7.2e-45) {
tmp = -0.3333333333333333 * ((b - Math.sqrt(((a * c) * -3.0))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e-30: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 7.2e-45: tmp = -0.3333333333333333 * ((b - math.sqrt(((a * c) * -3.0))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e-30) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 7.2e-45) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(Float64(a * c) * -3.0))) / 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 <= -7.5e-30) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 7.2e-45) tmp = -0.3333333333333333 * ((b - sqrt(((a * c) * -3.0))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e-30], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.2e-45], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{-30}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 7.2 \cdot 10^{-45}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{\left(a \cdot c\right) \cdot -3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.5000000000000006e-30Initial program 67.5%
Taylor expanded in b around -inf 91.7%
if -7.5000000000000006e-30 < b < 7.20000000000000001e-45Initial program 75.0%
/-rgt-identity75.0%
metadata-eval75.0%
associate-/l*75.0%
associate-*r/74.9%
*-commutative74.9%
associate-*l/75.0%
associate-*r/75.0%
metadata-eval75.0%
metadata-eval75.0%
times-frac75.0%
neg-mul-175.0%
distribute-rgt-neg-in75.0%
times-frac74.9%
metadata-eval74.9%
neg-mul-174.9%
Simplified74.8%
fma-udef74.8%
associate-*r*74.8%
*-commutative74.8%
metadata-eval74.8%
cancel-sign-sub-inv74.8%
Applied egg-rr74.8%
Taylor expanded in b around 0 67.9%
if 7.20000000000000001e-45 < b Initial program 13.4%
Taylor expanded in b around inf 93.7%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5.1e-30)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 5.2e-43)
(* -0.3333333333333333 (/ (- b (sqrt (* a (* c -3.0)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.1e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 5.2e-43) {
tmp = -0.3333333333333333 * ((b - sqrt((a * (c * -3.0)))) / 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 <= (-5.1d-30)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 5.2d-43) then
tmp = (-0.3333333333333333d0) * ((b - sqrt((a * (c * (-3.0d0))))) / 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 <= -5.1e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 5.2e-43) {
tmp = -0.3333333333333333 * ((b - Math.sqrt((a * (c * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.1e-30: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 5.2e-43: tmp = -0.3333333333333333 * ((b - math.sqrt((a * (c * -3.0)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.1e-30) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 5.2e-43) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(a * Float64(c * -3.0)))) / 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 <= -5.1e-30) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 5.2e-43) tmp = -0.3333333333333333 * ((b - sqrt((a * (c * -3.0)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.1e-30], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.2e-43], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.1 \cdot 10^{-30}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-43}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.09999999999999972e-30Initial program 67.5%
Taylor expanded in b around -inf 91.7%
if -5.09999999999999972e-30 < b < 5.2e-43Initial program 75.0%
/-rgt-identity75.0%
metadata-eval75.0%
associate-/l*75.0%
associate-*r/74.9%
*-commutative74.9%
associate-*l/75.0%
associate-*r/75.0%
metadata-eval75.0%
metadata-eval75.0%
times-frac75.0%
neg-mul-175.0%
distribute-rgt-neg-in75.0%
times-frac74.9%
metadata-eval74.9%
neg-mul-174.9%
Simplified74.8%
fma-udef74.8%
associate-*r*74.8%
*-commutative74.8%
metadata-eval74.8%
cancel-sign-sub-inv74.8%
Applied egg-rr74.8%
Taylor expanded in b around 0 67.9%
*-commutative67.9%
*-commutative67.9%
associate-*l*68.0%
Simplified68.0%
if 5.2e-43 < b Initial program 13.4%
Taylor expanded in b around inf 93.7%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -6e-30)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 9e-45)
(* -0.3333333333333333 (/ (- b (sqrt (* c (* a -3.0)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 9e-45) {
tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / 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 <= (-6d-30)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 9d-45) then
tmp = (-0.3333333333333333d0) * ((b - sqrt((c * (a * (-3.0d0))))) / 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 <= -6e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 9e-45) {
tmp = -0.3333333333333333 * ((b - Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-30: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 9e-45: tmp = -0.3333333333333333 * ((b - math.sqrt((c * (a * -3.0)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-30) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 9e-45) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(c * Float64(a * -3.0)))) / 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 <= -6e-30) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 9e-45) tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-30], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9e-45], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-30}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-45}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.9999999999999998e-30Initial program 67.5%
Taylor expanded in b around -inf 91.7%
if -5.9999999999999998e-30 < b < 8.9999999999999997e-45Initial program 75.0%
/-rgt-identity75.0%
metadata-eval75.0%
associate-/l*75.0%
associate-*r/74.9%
*-commutative74.9%
associate-*l/75.0%
associate-*r/75.0%
metadata-eval75.0%
metadata-eval75.0%
times-frac75.0%
neg-mul-175.0%
distribute-rgt-neg-in75.0%
times-frac74.9%
metadata-eval74.9%
neg-mul-174.9%
Simplified74.8%
fma-udef74.8%
associate-*r*74.8%
*-commutative74.8%
metadata-eval74.8%
cancel-sign-sub-inv74.8%
Applied egg-rr74.8%
Taylor expanded in b around 0 67.9%
expm1-log1p-u65.7%
expm1-udef37.7%
*-commutative37.7%
associate-*r*37.7%
Applied egg-rr37.7%
expm1-def65.7%
expm1-log1p68.1%
Simplified68.1%
if 8.9999999999999997e-45 < b Initial program 13.4%
Taylor expanded in b around inf 93.7%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2e-30)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 2.5e-41)
(* (/ 0.3333333333333333 a) (- (sqrt (* c (* a -3.0))) b))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.5e-41) {
tmp = (0.3333333333333333 / a) * (sqrt((c * (a * -3.0))) - b);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.2d-30)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 2.5d-41) then
tmp = (0.3333333333333333d0 / a) * (sqrt((c * (a * (-3.0d0)))) - b)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 2.5e-41) {
tmp = (0.3333333333333333 / a) * (Math.sqrt((c * (a * -3.0))) - b);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2e-30: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 2.5e-41: tmp = (0.3333333333333333 / a) * (math.sqrt((c * (a * -3.0))) - b) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2e-30) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 2.5e-41) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(c * Float64(a * -3.0))) - b)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.2e-30) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 2.5e-41) tmp = (0.3333333333333333 / a) * (sqrt((c * (a * -3.0))) - b); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2e-30], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-41], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{-30}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-41}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{c \cdot \left(a \cdot -3\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.19999999999999973e-30Initial program 67.5%
Taylor expanded in b around -inf 91.7%
if -5.19999999999999973e-30 < b < 2.4999999999999998e-41Initial program 75.0%
neg-sub075.0%
associate-+l-75.0%
sub0-neg75.0%
neg-mul-175.0%
associate-*r/75.0%
*-commutative75.0%
metadata-eval75.0%
metadata-eval75.0%
times-frac75.0%
*-commutative75.0%
times-frac74.9%
Simplified74.9%
fma-udef74.8%
associate-*r*74.8%
*-commutative74.8%
metadata-eval74.8%
cancel-sign-sub-inv74.8%
Applied egg-rr74.8%
Taylor expanded in b around 0 68.0%
*-commutative67.9%
*-commutative67.9%
associate-*l*68.0%
Simplified68.1%
expm1-log1p-u50.4%
expm1-udef21.6%
*-commutative21.6%
Applied egg-rr21.6%
expm1-def50.4%
expm1-log1p68.1%
*-commutative68.1%
associate-*r*68.1%
*-commutative68.1%
Simplified68.1%
if 2.4999999999999998e-41 < b Initial program 13.4%
Taylor expanded in b around inf 93.7%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e-30)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 6.2e-45)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 6.2e-45) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-7.5d-30)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 6.2d-45) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-30) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 6.2e-45) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e-30: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 6.2e-45: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e-30) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 6.2e-45) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - 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 <= -7.5e-30) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 6.2e-45) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e-30], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.2e-45], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $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 -7.5 \cdot 10^{-30}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-45}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.5000000000000006e-30Initial program 67.5%
Taylor expanded in b around -inf 91.7%
if -7.5000000000000006e-30 < b < 6.2000000000000002e-45Initial program 75.0%
Taylor expanded in b around 0 68.0%
*-commutative68.0%
*-commutative68.0%
*-commutative68.0%
associate-*l*68.1%
Simplified68.1%
if 6.2000000000000002e-45 < b Initial program 13.4%
Taylor expanded in b around inf 93.7%
Final simplification84.7%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) 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 <= -2e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], 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 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 73.4%
Taylor expanded in b around -inf 68.8%
*-commutative68.8%
Simplified68.8%
if -1.999999999999994e-310 < b Initial program 29.2%
Taylor expanded in b around inf 71.1%
Final simplification69.9%
(FPCore (a b c) :precision binary64 (* (/ c b) -0.5))
double code(double a, double b, double c) {
return (c / b) * -0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * (-0.5d0)
end function
public static double code(double a, double b, double c) {
return (c / b) * -0.5;
}
def code(a, b, c): return (c / b) * -0.5
function code(a, b, c) return Float64(Float64(c / b) * -0.5) end
function tmp = code(a, b, c) tmp = (c / b) * -0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot -0.5
\end{array}
Initial program 52.8%
Taylor expanded in b around inf 34.3%
Final simplification34.3%
herbie shell --seed 2023200
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))