
(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 -8.5e+143)
(/ (/ b -1.5) a)
(if (<= b 1.42e-98)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.5e+143) {
tmp = (b / -1.5) / a;
} else if (b <= 1.42e-98) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-8.5d+143)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 1.42d-98) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.5e+143) {
tmp = (b / -1.5) / a;
} else if (b <= 1.42e-98) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.5e+143: tmp = (b / -1.5) / a elif b <= 1.42e-98: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.5e+143) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 1.42e-98) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.5e+143) tmp = (b / -1.5) / a; elseif (b <= 1.42e-98) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.5e+143], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.42e-98], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.5 \cdot 10^{+143}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 1.42 \cdot 10^{-98}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -8.4999999999999998e143Initial program 45.4%
Taylor expanded in b around -inf 99.6%
*-commutative99.6%
Simplified99.6%
*-commutative99.6%
clear-num99.6%
un-div-inv99.7%
Applied egg-rr99.7%
associate-/r/99.7%
Simplified99.7%
associate-*l/99.7%
*-un-lft-identity99.7%
times-frac99.6%
metadata-eval99.6%
metadata-eval99.6%
times-frac99.8%
*-commutative99.8%
associate-/r*99.9%
associate-/l*99.9%
metadata-eval99.9%
Applied egg-rr99.9%
if -8.4999999999999998e143 < b < 1.41999999999999999e-98Initial program 86.8%
if 1.41999999999999999e-98 < b Initial program 19.0%
Taylor expanded in b around inf 93.5%
associate-*r/93.5%
Simplified93.5%
Final simplification91.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1e-70)
(fma b (/ -0.6666666666666666 a) (* (* (/ c b) -3.0) -0.16666666666666666))
(if (<= b 6.5e-99)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-70) {
tmp = fma(b, (-0.6666666666666666 / a), (((c / b) * -3.0) * -0.16666666666666666));
} else if (b <= 6.5e-99) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1e-70) tmp = fma(b, Float64(-0.6666666666666666 / a), Float64(Float64(Float64(c / b) * -3.0) * -0.16666666666666666)); elseif (b <= 6.5e-99) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1e-70], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision] + N[(N[(N[(c / b), $MachinePrecision] * -3.0), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e-99], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-70}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{-0.6666666666666666}{a}, \left(\frac{c}{b} \cdot -3\right) \cdot -0.16666666666666666\right)\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-99}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.99999999999999996e-71Initial program 73.7%
Applied egg-rr61.7%
div-inv61.6%
unpow-prod-down61.6%
inv-pow61.6%
clear-num61.6%
inv-pow61.6%
clear-num61.7%
times-frac61.7%
*-un-lft-identity61.7%
associate-/r*61.6%
frac-2neg61.6%
metadata-eval61.6%
Applied egg-rr61.6%
distribute-neg-frac61.6%
sub-neg61.6%
+-commutative61.6%
distribute-neg-in61.6%
remove-double-neg61.6%
sub-neg61.6%
Simplified61.6%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
associate-*l/0.0%
*-commutative0.0%
fma-def0.0%
*-commutative0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt92.2%
associate-/r/92.2%
Simplified92.2%
if -9.99999999999999996e-71 < b < 6.50000000000000033e-99Initial program 76.5%
Taylor expanded in b around 0 70.6%
if 6.50000000000000033e-99 < b Initial program 19.0%
Taylor expanded in b around inf 93.5%
associate-*r/93.5%
Simplified93.5%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-70)
(fma b (/ -0.6666666666666666 a) (* (* (/ c b) -3.0) -0.16666666666666666))
(if (<= b 1.05e-98)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-70) {
tmp = fma(b, (-0.6666666666666666 / a), (((c / b) * -3.0) * -0.16666666666666666));
} else if (b <= 1.05e-98) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.25e-70) tmp = fma(b, Float64(-0.6666666666666666 / a), Float64(Float64(Float64(c / b) * -3.0) * -0.16666666666666666)); elseif (b <= 1.05e-98) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.25e-70], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision] + N[(N[(N[(c / b), $MachinePrecision] * -3.0), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-98], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-70}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{-0.6666666666666666}{a}, \left(\frac{c}{b} \cdot -3\right) \cdot -0.16666666666666666\right)\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-98}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.25e-70Initial program 73.7%
Applied egg-rr61.7%
div-inv61.6%
unpow-prod-down61.6%
inv-pow61.6%
clear-num61.6%
inv-pow61.6%
clear-num61.7%
times-frac61.7%
*-un-lft-identity61.7%
associate-/r*61.6%
frac-2neg61.6%
metadata-eval61.6%
Applied egg-rr61.6%
distribute-neg-frac61.6%
sub-neg61.6%
+-commutative61.6%
distribute-neg-in61.6%
remove-double-neg61.6%
sub-neg61.6%
Simplified61.6%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
associate-*l/0.0%
*-commutative0.0%
fma-def0.0%
*-commutative0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt92.2%
associate-/r/92.2%
Simplified92.2%
if -1.25e-70 < b < 1.04999999999999996e-98Initial program 76.5%
Taylor expanded in b around 0 70.6%
associate-*r*70.7%
*-commutative70.7%
Simplified70.7%
if 1.04999999999999996e-98 < b Initial program 19.0%
Taylor expanded in b around inf 93.5%
associate-*r/93.5%
Simplified93.5%
Final simplification87.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-312) (fma b (/ -0.6666666666666666 a) (* (* (/ c b) -3.0) -0.16666666666666666)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
tmp = fma(b, (-0.6666666666666666 / a), (((c / b) * -3.0) * -0.16666666666666666));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e-312) tmp = fma(b, Float64(-0.6666666666666666 / a), Float64(Float64(Float64(c / b) * -3.0) * -0.16666666666666666)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e-312], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision] + N[(N[(N[(c / b), $MachinePrecision] * -3.0), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{-0.6666666666666666}{a}, \left(\frac{c}{b} \cdot -3\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.0000000000022e-312Initial program 75.7%
Applied egg-rr66.1%
div-inv66.0%
unpow-prod-down66.0%
inv-pow66.0%
clear-num66.0%
inv-pow66.0%
clear-num66.0%
times-frac66.1%
*-un-lft-identity66.1%
associate-/r*66.1%
frac-2neg66.1%
metadata-eval66.1%
Applied egg-rr66.1%
distribute-neg-frac66.1%
sub-neg66.1%
+-commutative66.1%
distribute-neg-in66.1%
remove-double-neg66.1%
sub-neg66.1%
Simplified66.1%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
associate-*l/0.0%
*-commutative0.0%
fma-def0.0%
*-commutative0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt71.8%
associate-/r/71.8%
Simplified71.8%
if -5.0000000000022e-312 < b Initial program 28.4%
Taylor expanded in b around inf 77.3%
associate-*r/77.3%
Simplified77.3%
Final simplification74.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-312) (+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-312)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-312: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-312) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-312) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-312], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-312}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.0000000000022e-312Initial program 75.7%
Taylor expanded in b around -inf 71.7%
if -5.0000000000022e-312 < b Initial program 28.4%
Taylor expanded in b around inf 77.3%
associate-*r/77.3%
Simplified77.3%
Final simplification74.3%
(FPCore (a b c) :precision binary64 (if (<= b 2.5e+75) (* b (/ -0.6666666666666666 a)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.5e+75) {
tmp = b * (-0.6666666666666666 / 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 <= 2.5d+75) then
tmp = b * ((-0.6666666666666666d0) / 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 <= 2.5e+75) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.5e+75: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.5e+75) tmp = Float64(b * Float64(-0.6666666666666666 / 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 <= 2.5e+75) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.5e+75], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.5 \cdot 10^{+75}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 2.5000000000000001e75Initial program 65.0%
Taylor expanded in b around -inf 51.9%
*-commutative51.9%
Simplified51.9%
*-commutative51.9%
clear-num51.9%
un-div-inv51.9%
Applied egg-rr51.9%
associate-/r/51.9%
Simplified51.9%
if 2.5000000000000001e75 < b Initial program 19.7%
Taylor expanded in b around -inf 2.3%
Taylor expanded in b around 0 42.6%
Final simplification49.6%
(FPCore (a b c) :precision binary64 (if (<= b 2.5e+75) (/ -0.6666666666666666 (/ a b)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.5e+75) {
tmp = -0.6666666666666666 / (a / 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 <= 2.5d+75) then
tmp = (-0.6666666666666666d0) / (a / 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 <= 2.5e+75) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.5e+75: tmp = -0.6666666666666666 / (a / b) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.5e+75) tmp = Float64(-0.6666666666666666 / Float64(a / 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 <= 2.5e+75) tmp = -0.6666666666666666 / (a / b); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.5e+75], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.5 \cdot 10^{+75}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 2.5000000000000001e75Initial program 65.0%
Taylor expanded in b around -inf 51.9%
*-commutative51.9%
Simplified51.9%
*-commutative51.9%
clear-num51.9%
un-div-inv51.9%
Applied egg-rr51.9%
if 2.5000000000000001e75 < b Initial program 19.7%
Taylor expanded in b around -inf 2.3%
Taylor expanded in b around 0 42.6%
Final simplification49.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-312) (/ -0.6666666666666666 (/ a b)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = -0.5 / (b / c);
}
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-312)) then
tmp = (-0.6666666666666666d0) / (a / b)
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-312: tmp = -0.6666666666666666 / (a / b) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-312) tmp = Float64(-0.6666666666666666 / Float64(a / b)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-312) tmp = -0.6666666666666666 / (a / b); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-312], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -5.0000000000022e-312Initial program 75.7%
Taylor expanded in b around -inf 71.2%
*-commutative71.2%
Simplified71.2%
*-commutative71.2%
clear-num71.2%
un-div-inv71.3%
Applied egg-rr71.3%
if -5.0000000000022e-312 < b Initial program 28.4%
Taylor expanded in b around inf 77.3%
associate-*r/77.3%
associate-/l*76.5%
Simplified76.5%
Final simplification73.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-312) (/ b (* -1.5 a)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
tmp = b / (-1.5 * a);
} else {
tmp = -0.5 / (b / c);
}
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-312)) then
tmp = b / ((-1.5d0) * a)
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
tmp = b / (-1.5 * a);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-312: tmp = b / (-1.5 * a) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-312) tmp = Float64(b / Float64(-1.5 * a)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-312) tmp = b / (-1.5 * a); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-312], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -5.0000000000022e-312Initial program 75.7%
Taylor expanded in b around -inf 71.2%
*-commutative71.2%
Simplified71.2%
*-commutative71.2%
clear-num71.2%
un-div-inv71.3%
Applied egg-rr71.3%
associate-/r/71.2%
Simplified71.2%
*-commutative71.2%
clear-num71.2%
un-div-inv71.3%
div-inv71.4%
metadata-eval71.4%
Applied egg-rr71.4%
if -5.0000000000022e-312 < b Initial program 28.4%
Taylor expanded in b around inf 77.3%
associate-*r/77.3%
associate-/l*76.5%
Simplified76.5%
Final simplification73.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-312) (/ b (* -1.5 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
tmp = b / (-1.5 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-312)) then
tmp = b / ((-1.5d0) * a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
tmp = b / (-1.5 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-312: tmp = b / (-1.5 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-312) tmp = Float64(b / Float64(-1.5 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-312) tmp = b / (-1.5 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-312], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.0000000000022e-312Initial program 75.7%
Taylor expanded in b around -inf 71.2%
*-commutative71.2%
Simplified71.2%
*-commutative71.2%
clear-num71.2%
un-div-inv71.3%
Applied egg-rr71.3%
associate-/r/71.2%
Simplified71.2%
*-commutative71.2%
clear-num71.2%
un-div-inv71.3%
div-inv71.4%
metadata-eval71.4%
Applied egg-rr71.4%
if -5.0000000000022e-312 < b Initial program 28.4%
Taylor expanded in b around inf 77.3%
associate-*r/77.3%
Simplified77.3%
Final simplification74.1%
(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 54.1%
Taylor expanded in b around -inf 39.0%
Taylor expanded in b around 0 12.8%
Final simplification12.8%
herbie shell --seed 2023306
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))