
(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 8 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 -5.5e+138)
(/ (* b -2.0) (* 3.0 a))
(if (<= b -2.5e-232)
(* (- b (sqrt (fma b b (* (* a c) -3.0)))) (/ -0.3333333333333333 a))
(if (<= b 1.1e-16)
(/ (- c) (+ b (hypot b (sqrt (* a (* c -3.0))))))
(* -0.5 (/ c b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e+138) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= -2.5e-232) {
tmp = (b - sqrt(fma(b, b, ((a * c) * -3.0)))) * (-0.3333333333333333 / a);
} else if (b <= 1.1e-16) {
tmp = -c / (b + hypot(b, sqrt((a * (c * -3.0)))));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.5e+138) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= -2.5e-232) tmp = Float64(Float64(b - sqrt(fma(b, b, Float64(Float64(a * c) * -3.0)))) * Float64(-0.3333333333333333 / a)); elseif (b <= 1.1e-16) tmp = Float64(Float64(-c) / Float64(b + hypot(b, sqrt(Float64(a * Float64(c * -3.0)))))); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.5e+138], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -2.5e-232], N[(N[(b - N[Sqrt[N[(b * b + N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-16], N[((-c) / N[(b + N[Sqrt[b ^ 2 + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{+138}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq -2.5 \cdot 10^{-232}:\\
\;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -3\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-16}:\\
\;\;\;\;\frac{-c}{b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.4999999999999999e138Initial program 46.6%
Taylor expanded in b around -inf 99.9%
*-commutative99.9%
Simplified99.9%
if -5.4999999999999999e138 < b < -2.5e-232Initial program 81.5%
/-rgt-identity81.5%
metadata-eval81.5%
associate-/r/81.5%
metadata-eval81.5%
metadata-eval81.5%
times-frac81.5%
*-commutative81.5%
times-frac81.5%
associate-/r*81.4%
Simplified81.5%
if -2.5e-232 < b < 1.1e-16Initial program 70.1%
/-rgt-identity70.1%
metadata-eval70.1%
associate-/l*70.1%
associate-*r/69.9%
*-commutative69.9%
associate-*l/70.1%
associate-*r/70.1%
metadata-eval70.1%
metadata-eval70.1%
times-frac70.1%
neg-mul-170.1%
distribute-rgt-neg-in70.1%
times-frac70.2%
metadata-eval70.2%
neg-mul-170.2%
Simplified70.2%
associate-*r/70.1%
associate-*r*70.1%
*-commutative70.1%
associate-*r/69.9%
*-commutative69.9%
clear-num69.8%
associate-*r*69.7%
flip--69.5%
frac-times56.6%
Applied egg-rr56.7%
associate-/r*69.9%
fma-udef69.9%
+-commutative69.9%
fma-def69.9%
Simplified69.9%
Taylor expanded in b around 0 87.0%
mul-1-neg87.0%
Simplified87.0%
if 1.1e-16 < b Initial program 7.9%
Taylor expanded in b around inf 94.1%
Final simplification89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4e+145)
(/ (* b -2.0) (* 3.0 a))
(if (<= b -2.5e-232)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(if (<= b 1.85e-16)
(/ (- c) (+ b (hypot b (sqrt (* a (* c -3.0))))))
(* -0.5 (/ c b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+145) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= -2.5e-232) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else if (b <= 1.85e-16) {
tmp = -c / (b + hypot(b, sqrt((a * (c * -3.0)))));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e+145) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= -2.5e-232) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else if (b <= 1.85e-16) {
tmp = -c / (b + Math.hypot(b, Math.sqrt((a * (c * -3.0)))));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e+145: tmp = (b * -2.0) / (3.0 * a) elif b <= -2.5e-232: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) elif b <= 1.85e-16: tmp = -c / (b + math.hypot(b, math.sqrt((a * (c * -3.0))))) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e+145) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= -2.5e-232) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); elseif (b <= 1.85e-16) tmp = Float64(Float64(-c) / Float64(b + hypot(b, sqrt(Float64(a * Float64(c * -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 <= -4e+145) tmp = (b * -2.0) / (3.0 * a); elseif (b <= -2.5e-232) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); elseif (b <= 1.85e-16) tmp = -c / (b + hypot(b, sqrt((a * (c * -3.0))))); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e+145], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -2.5e-232], 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], If[LessEqual[b, 1.85e-16], N[((-c) / N[(b + N[Sqrt[b ^ 2 + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+145}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq -2.5 \cdot 10^{-232}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{-16}:\\
\;\;\;\;\frac{-c}{b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4e145Initial program 45.4%
Taylor expanded in b around -inf 99.9%
*-commutative99.9%
Simplified99.9%
if -4e145 < b < -2.5e-232Initial program 81.7%
if -2.5e-232 < b < 1.85e-16Initial program 70.1%
/-rgt-identity70.1%
metadata-eval70.1%
associate-/l*70.1%
associate-*r/69.9%
*-commutative69.9%
associate-*l/70.1%
associate-*r/70.1%
metadata-eval70.1%
metadata-eval70.1%
times-frac70.1%
neg-mul-170.1%
distribute-rgt-neg-in70.1%
times-frac70.2%
metadata-eval70.2%
neg-mul-170.2%
Simplified70.2%
associate-*r/70.1%
associate-*r*70.1%
*-commutative70.1%
associate-*r/69.9%
*-commutative69.9%
clear-num69.8%
associate-*r*69.7%
flip--69.5%
frac-times56.6%
Applied egg-rr56.7%
associate-/r*69.9%
fma-udef69.9%
+-commutative69.9%
fma-def69.9%
Simplified69.9%
Taylor expanded in b around 0 87.0%
mul-1-neg87.0%
Simplified87.0%
if 1.85e-16 < b Initial program 7.9%
Taylor expanded in b around inf 94.1%
Final simplification89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -6e+150)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.2e-60)
(/ (- (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 <= -6e+150) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.2e-60) {
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 <= (-6d+150)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.2d-60) 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 <= -6e+150) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.2e-60) {
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 <= -6e+150: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.2e-60: 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 <= -6e+150) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.2e-60) 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 <= -6e+150) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.2e-60) 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, -6e+150], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.2e-60], 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 -6 \cdot 10^{+150}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-60}:\\
\;\;\;\;\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 < -6.00000000000000025e150Initial program 45.4%
Taylor expanded in b around -inf 99.9%
*-commutative99.9%
Simplified99.9%
if -6.00000000000000025e150 < b < 1.20000000000000005e-60Initial program 79.4%
neg-sub079.4%
associate-+l-79.4%
sub0-neg79.4%
neg-mul-179.4%
associate-*r/79.4%
metadata-eval79.4%
metadata-eval79.4%
times-frac79.4%
*-commutative79.4%
times-frac79.4%
associate-*l/79.4%
Simplified79.4%
if 1.20000000000000005e-60 < b Initial program 10.9%
Taylor expanded in b around inf 91.4%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2e+151)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 7.5e-61)
(/ (- (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 <= -5.2e+151) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.5e-61) {
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 <= (-5.2d+151)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 7.5d-61) 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 <= -5.2e+151) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.5e-61) {
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 <= -5.2e+151: tmp = (b * -2.0) / (3.0 * a) elif b <= 7.5e-61: 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 <= -5.2e+151) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 7.5e-61) 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 <= -5.2e+151) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 7.5e-61) 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, -5.2e+151], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-61], 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 -5.2 \cdot 10^{+151}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-61}:\\
\;\;\;\;\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 < -5.20000000000000026e151Initial program 45.4%
Taylor expanded in b around -inf 99.9%
*-commutative99.9%
Simplified99.9%
if -5.20000000000000026e151 < b < 7.50000000000000047e-61Initial program 79.4%
if 7.50000000000000047e-61 < b Initial program 10.9%
Taylor expanded in b around inf 91.4%
Final simplification87.2%
(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 69.2%
Taylor expanded in b around -inf 66.5%
if -4.999999999999985e-310 < b Initial program 30.0%
Taylor expanded in b around inf 68.3%
Final simplification67.4%
(FPCore (a b c) :precision binary64 (if (<= b 6.1e-297) (/ (* b -2.0) (* 3.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.1e-297) {
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 <= 6.1d-297) 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 <= 6.1e-297) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.1e-297: 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 <= 6.1e-297) 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 <= 6.1e-297) 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, 6.1e-297], 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 6.1 \cdot 10^{-297}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.1e-297Initial program 69.6%
Taylor expanded in b around -inf 63.6%
*-commutative63.6%
Simplified63.6%
if 6.1e-297 < b Initial program 27.9%
Taylor expanded in b around inf 71.0%
Final simplification67.1%
(FPCore (a b c) :precision binary64 (if (<= b 6.1e-297) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.1e-297) {
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 <= 6.1d-297) 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 <= 6.1e-297) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.1e-297: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.1e-297) 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 <= 6.1e-297) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.1e-297], 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 6.1 \cdot 10^{-297}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.1e-297Initial program 69.6%
Taylor expanded in b around -inf 63.6%
*-commutative63.6%
Simplified63.6%
if 6.1e-297 < b Initial program 27.9%
Taylor expanded in b around inf 71.0%
Final simplification67.1%
(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 49.9%
Taylor expanded in b around inf 34.7%
Final simplification34.7%
herbie shell --seed 2023228
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))