
(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
(let* ((t_0 (* -0.5 (/ c b))))
(if (<= b -1.16e+154)
(- (* (/ b a) (- 0.6666666666666666)) t_0)
(if (<= b 3e-63)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
t_0))))
double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -1.16e+154) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else if (b <= 3e-63) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * (c / b)
if (b <= (-1.16d+154)) then
tmp = ((b / a) * -0.6666666666666666d0) - t_0
else if (b <= 3d-63) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -1.16e+154) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else if (b <= 3e-63) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c): t_0 = -0.5 * (c / b) tmp = 0 if b <= -1.16e+154: tmp = ((b / a) * -0.6666666666666666) - t_0 elif b <= 3e-63: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = t_0 return tmp
function code(a, b, c) t_0 = Float64(-0.5 * Float64(c / b)) tmp = 0.0 if (b <= -1.16e+154) tmp = Float64(Float64(Float64(b / a) * Float64(-0.6666666666666666)) - t_0); elseif (b <= 3e-63) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c) t_0 = -0.5 * (c / b); tmp = 0.0; if (b <= -1.16e+154) tmp = ((b / a) * -0.6666666666666666) - t_0; elseif (b <= 3e-63) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.16e+154], N[(N[(N[(b / a), $MachinePrecision] * (-0.6666666666666666)), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[b, 3e-63], 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], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{c}{b}\\
\mathbf{if}\;b \leq -1.16 \cdot 10^{+154}:\\
\;\;\;\;\frac{b}{a} \cdot \left(-0.6666666666666666\right) - t\_0\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-63}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -1.16000000000000001e154Initial program 32.5%
sqr-neg32.5%
sqr-neg32.5%
associate-*l*32.5%
Simplified32.5%
Taylor expanded in b around -inf 96.5%
Taylor expanded in c around 0 97.5%
if -1.16000000000000001e154 < b < 2.99999999999999979e-63Initial program 88.7%
if 2.99999999999999979e-63 < b Initial program 15.6%
sqr-neg15.6%
sqr-neg15.6%
associate-*l*15.6%
Simplified15.6%
Taylor expanded in b around inf 84.9%
*-commutative84.9%
Simplified84.9%
Final simplification88.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* -0.5 (/ c b))))
(if (<= b -4e+151)
(- (* (/ b a) (- 0.6666666666666666)) t_0)
(if (<= b 7.5e-65)
(/ (- (sqrt (- (* b b) (* 3.0 (* c a)))) b) (* a 3.0))
t_0))))
double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -4e+151) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else if (b <= 7.5e-65) {
tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0);
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * (c / b)
if (b <= (-4d+151)) then
tmp = ((b / a) * -0.6666666666666666d0) - t_0
else if (b <= 7.5d-65) then
tmp = (sqrt(((b * b) - (3.0d0 * (c * a)))) - b) / (a * 3.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -4e+151) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else if (b <= 7.5e-65) {
tmp = (Math.sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c): t_0 = -0.5 * (c / b) tmp = 0 if b <= -4e+151: tmp = ((b / a) * -0.6666666666666666) - t_0 elif b <= 7.5e-65: tmp = (math.sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0) else: tmp = t_0 return tmp
function code(a, b, c) t_0 = Float64(-0.5 * Float64(c / b)) tmp = 0.0 if (b <= -4e+151) tmp = Float64(Float64(Float64(b / a) * Float64(-0.6666666666666666)) - t_0); elseif (b <= 7.5e-65) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(c * a)))) - b) / Float64(a * 3.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c) t_0 = -0.5 * (c / b); tmp = 0.0; if (b <= -4e+151) tmp = ((b / a) * -0.6666666666666666) - t_0; elseif (b <= 7.5e-65) tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4e+151], N[(N[(N[(b / a), $MachinePrecision] * (-0.6666666666666666)), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[b, 7.5e-65], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{c}{b}\\
\mathbf{if}\;b \leq -4 \cdot 10^{+151}:\\
\;\;\;\;\frac{b}{a} \cdot \left(-0.6666666666666666\right) - t\_0\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -4.00000000000000007e151Initial program 32.5%
sqr-neg32.5%
sqr-neg32.5%
associate-*l*32.5%
Simplified32.5%
Taylor expanded in b around -inf 96.5%
Taylor expanded in c around 0 97.5%
if -4.00000000000000007e151 < b < 7.5000000000000002e-65Initial program 88.7%
sqr-neg88.7%
sqr-neg88.7%
associate-*l*88.6%
Simplified88.6%
if 7.5000000000000002e-65 < b Initial program 15.6%
sqr-neg15.6%
sqr-neg15.6%
associate-*l*15.6%
Simplified15.6%
Taylor expanded in b around inf 84.9%
*-commutative84.9%
Simplified84.9%
Final simplification88.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* -0.5 (/ c b))))
(if (<= b -5.3e-82)
(- (* (/ b a) (- 0.6666666666666666)) t_0)
(if (<= b 4.4e-66) (/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0)) t_0))))
double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -5.3e-82) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else if (b <= 4.4e-66) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * (c / b)
if (b <= (-5.3d-82)) then
tmp = ((b / a) * -0.6666666666666666d0) - t_0
else if (b <= 4.4d-66) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -5.3e-82) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else if (b <= 4.4e-66) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c): t_0 = -0.5 * (c / b) tmp = 0 if b <= -5.3e-82: tmp = ((b / a) * -0.6666666666666666) - t_0 elif b <= 4.4e-66: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = t_0 return tmp
function code(a, b, c) t_0 = Float64(-0.5 * Float64(c / b)) tmp = 0.0 if (b <= -5.3e-82) tmp = Float64(Float64(Float64(b / a) * Float64(-0.6666666666666666)) - t_0); elseif (b <= 4.4e-66) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c) t_0 = -0.5 * (c / b); tmp = 0.0; if (b <= -5.3e-82) tmp = ((b / a) * -0.6666666666666666) - t_0; elseif (b <= 4.4e-66) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5.3e-82], N[(N[(N[(b / a), $MachinePrecision] * (-0.6666666666666666)), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[b, 4.4e-66], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{c}{b}\\
\mathbf{if}\;b \leq -5.3 \cdot 10^{-82}:\\
\;\;\;\;\frac{b}{a} \cdot \left(-0.6666666666666666\right) - t\_0\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -5.29999999999999956e-82Initial program 68.8%
sqr-neg68.8%
sqr-neg68.8%
associate-*l*68.8%
Simplified68.8%
Taylor expanded in b around -inf 88.5%
Taylor expanded in c around 0 89.0%
if -5.29999999999999956e-82 < b < 4.4000000000000002e-66Initial program 82.2%
sqr-neg82.2%
sqr-neg82.2%
associate-*l*82.1%
Simplified82.1%
Taylor expanded in b around 0 72.8%
*-commutative72.8%
*-commutative72.8%
associate-*r*73.0%
Simplified73.0%
if 4.4000000000000002e-66 < b Initial program 15.6%
sqr-neg15.6%
sqr-neg15.6%
associate-*l*15.6%
Simplified15.6%
Taylor expanded in b around inf 84.9%
*-commutative84.9%
Simplified84.9%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* -0.5 (/ c b))))
(if (<= b -6.5e-82)
(- (* (/ b a) (- 0.6666666666666666)) t_0)
(if (<= b 4.2e-63) (/ (- (sqrt (* (* c a) -3.0)) b) (* a 3.0)) t_0))))
double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -6.5e-82) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else if (b <= 4.2e-63) {
tmp = (sqrt(((c * a) * -3.0)) - b) / (a * 3.0);
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * (c / b)
if (b <= (-6.5d-82)) then
tmp = ((b / a) * -0.6666666666666666d0) - t_0
else if (b <= 4.2d-63) then
tmp = (sqrt(((c * a) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -6.5e-82) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else if (b <= 4.2e-63) {
tmp = (Math.sqrt(((c * a) * -3.0)) - b) / (a * 3.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c): t_0 = -0.5 * (c / b) tmp = 0 if b <= -6.5e-82: tmp = ((b / a) * -0.6666666666666666) - t_0 elif b <= 4.2e-63: tmp = (math.sqrt(((c * a) * -3.0)) - b) / (a * 3.0) else: tmp = t_0 return tmp
function code(a, b, c) t_0 = Float64(-0.5 * Float64(c / b)) tmp = 0.0 if (b <= -6.5e-82) tmp = Float64(Float64(Float64(b / a) * Float64(-0.6666666666666666)) - t_0); elseif (b <= 4.2e-63) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -3.0)) - b) / Float64(a * 3.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c) t_0 = -0.5 * (c / b); tmp = 0.0; if (b <= -6.5e-82) tmp = ((b / a) * -0.6666666666666666) - t_0; elseif (b <= 4.2e-63) tmp = (sqrt(((c * a) * -3.0)) - b) / (a * 3.0); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -6.5e-82], N[(N[(N[(b / a), $MachinePrecision] * (-0.6666666666666666)), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[b, 4.2e-63], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{c}{b}\\
\mathbf{if}\;b \leq -6.5 \cdot 10^{-82}:\\
\;\;\;\;\frac{b}{a} \cdot \left(-0.6666666666666666\right) - t\_0\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-63}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -6.4999999999999997e-82Initial program 68.8%
sqr-neg68.8%
sqr-neg68.8%
associate-*l*68.8%
Simplified68.8%
Taylor expanded in b around -inf 88.5%
Taylor expanded in c around 0 89.0%
if -6.4999999999999997e-82 < b < 4.2e-63Initial program 82.2%
sqr-neg82.2%
sqr-neg82.2%
associate-*l*82.1%
Simplified82.1%
Taylor expanded in b around 0 72.8%
if 4.2e-63 < b Initial program 15.6%
sqr-neg15.6%
sqr-neg15.6%
associate-*l*15.6%
Simplified15.6%
Taylor expanded in b around inf 84.9%
*-commutative84.9%
Simplified84.9%
Final simplification83.8%
(FPCore (a b c) :precision binary64 (let* ((t_0 (* -0.5 (/ c b)))) (if (<= b -5e-310) (- (* (/ b a) (- 0.6666666666666666)) t_0) t_0)))
double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -5e-310) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * (c / b)
if (b <= (-5d-310)) then
tmp = ((b / a) * -0.6666666666666666d0) - t_0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -0.5 * (c / b);
double tmp;
if (b <= -5e-310) {
tmp = ((b / a) * -0.6666666666666666) - t_0;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c): t_0 = -0.5 * (c / b) tmp = 0 if b <= -5e-310: tmp = ((b / a) * -0.6666666666666666) - t_0 else: tmp = t_0 return tmp
function code(a, b, c) t_0 = Float64(-0.5 * Float64(c / b)) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(b / a) * Float64(-0.6666666666666666)) - t_0); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c) t_0 = -0.5 * (c / b); tmp = 0.0; if (b <= -5e-310) tmp = ((b / a) * -0.6666666666666666) - t_0; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5e-310], N[(N[(N[(b / a), $MachinePrecision] * (-0.6666666666666666)), $MachinePrecision] - t$95$0), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{c}{b}\\
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot \left(-0.6666666666666666\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.5%
sqr-neg72.5%
sqr-neg72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around -inf 72.9%
Taylor expanded in c around 0 75.0%
if -4.999999999999985e-310 < b Initial program 30.4%
sqr-neg30.4%
sqr-neg30.4%
associate-*l*30.3%
Simplified30.3%
Taylor expanded in b around inf 67.9%
*-commutative67.9%
Simplified67.9%
Final simplification71.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (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 <= (-5d-310)) then
tmp = b / (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 <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / 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 <= -5e-310) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / N[(a * -1.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}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.5%
sqr-neg72.5%
sqr-neg72.5%
associate-*l*72.5%
Simplified72.5%
+-commutative72.5%
add-sqr-sqrt72.3%
fma-define72.4%
Applied egg-rr61.0%
associate-*r*61.0%
*-commutative61.0%
associate-*r*61.0%
Simplified61.0%
Taylor expanded in b around -inf 74.5%
*-commutative74.5%
associate-*l/74.5%
associate-/l*74.5%
Simplified74.5%
clear-num74.4%
div-inv74.5%
metadata-eval74.5%
*-commutative74.5%
un-div-inv74.6%
*-commutative74.6%
Applied egg-rr74.6%
if -4.999999999999985e-310 < b Initial program 30.4%
sqr-neg30.4%
sqr-neg30.4%
associate-*l*30.3%
Simplified30.3%
Taylor expanded in b around inf 67.9%
*-commutative67.9%
Simplified67.9%
Final simplification71.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.5%
sqr-neg72.5%
sqr-neg72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around -inf 74.5%
*-commutative74.5%
Simplified74.5%
if -4.999999999999985e-310 < b Initial program 30.4%
sqr-neg30.4%
sqr-neg30.4%
associate-*l*30.3%
Simplified30.3%
Taylor expanded in b around inf 67.9%
*-commutative67.9%
Simplified67.9%
Final simplification71.4%
(FPCore (a b c) :precision binary64 (if (<= b 5e-310) (* (/ b a) -0.6666666666666666) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5e-310) {
tmp = (b / a) * -0.6666666666666666;
} 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-310) then
tmp = (b / a) * (-0.6666666666666666d0)
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-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5e-310) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5e-310) tmp = (b / a) * -0.6666666666666666; else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 4.999999999999985e-310Initial program 72.5%
sqr-neg72.5%
sqr-neg72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in b around -inf 74.5%
*-commutative74.5%
Simplified74.5%
if 4.999999999999985e-310 < b Initial program 30.4%
sqr-neg30.4%
sqr-neg30.4%
associate-*l*30.3%
Simplified30.3%
Taylor expanded in b around inf 51.7%
associate-/l*58.4%
Simplified58.4%
associate-/l*58.4%
*-commutative58.4%
Applied egg-rr58.4%
Taylor expanded in a around 0 67.9%
associate-*r/67.9%
*-commutative67.9%
associate-*r/67.7%
Simplified67.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / 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-310)) then
tmp = b * ((-0.6666666666666666d0) / 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-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.5%
sqr-neg72.5%
sqr-neg72.5%
associate-*l*72.5%
Simplified72.5%
+-commutative72.5%
add-sqr-sqrt72.3%
fma-define72.4%
Applied egg-rr61.0%
associate-*r*61.0%
*-commutative61.0%
associate-*r*61.0%
Simplified61.0%
Taylor expanded in b around -inf 74.5%
*-commutative74.5%
associate-*l/74.5%
associate-/l*74.5%
Simplified74.5%
if -4.999999999999985e-310 < b Initial program 30.4%
sqr-neg30.4%
sqr-neg30.4%
associate-*l*30.3%
Simplified30.3%
Taylor expanded in b around inf 51.7%
associate-/l*58.4%
Simplified58.4%
associate-/l*58.4%
*-commutative58.4%
Applied egg-rr58.4%
Taylor expanded in a around 0 67.9%
associate-*r/67.9%
*-commutative67.9%
associate-*r/67.7%
Simplified67.7%
(FPCore (a b c) :precision binary64 (if (<= b 2700000.0) (* b (/ -0.6666666666666666 a)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2700000.0) {
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 <= 2700000.0d0) 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 <= 2700000.0) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2700000.0: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2700000.0) 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 <= 2700000.0) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2700000.0], 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 2700000:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 2.7e6Initial program 71.0%
sqr-neg71.0%
sqr-neg71.0%
associate-*l*70.9%
Simplified70.9%
+-commutative70.9%
add-sqr-sqrt70.7%
fma-define70.7%
Applied egg-rr62.2%
associate-*r*62.2%
*-commutative62.2%
associate-*r*62.2%
Simplified62.2%
Taylor expanded in b around -inf 57.3%
*-commutative57.3%
associate-*l/57.3%
associate-/l*57.3%
Simplified57.3%
if 2.7e6 < b Initial program 10.4%
sqr-neg10.4%
sqr-neg10.4%
associate-*l*10.4%
Simplified10.4%
Taylor expanded in b around inf 74.0%
associate-/l*80.4%
Simplified80.4%
associate-/l*80.5%
*-commutative80.5%
Applied egg-rr80.5%
associate-*r/80.4%
associate-*l*80.6%
*-commutative80.6%
*-commutative80.6%
add-sqr-sqrt39.5%
sqrt-unprod38.3%
swap-sqr38.2%
metadata-eval38.2%
metadata-eval38.2%
swap-sqr38.3%
sqrt-unprod10.5%
add-sqr-sqrt24.9%
Applied egg-rr24.9%
associate-*r/24.7%
*-rgt-identity24.7%
associate-*r/24.7%
*-commutative24.7%
associate-*r/24.7%
*-rgt-identity24.7%
*-commutative24.7%
*-commutative24.7%
times-frac24.7%
metadata-eval24.7%
*-inverses24.7%
metadata-eval24.7%
Simplified24.7%
Final simplification47.5%
(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%
sqr-neg52.8%
sqr-neg52.8%
associate-*l*52.7%
Simplified52.7%
Taylor expanded in b around inf 25.5%
associate-/l*28.7%
Simplified28.7%
associate-/l*28.7%
*-commutative28.7%
Applied egg-rr28.7%
associate-*r/28.7%
associate-*l*28.8%
*-commutative28.8%
*-commutative28.8%
add-sqr-sqrt14.2%
sqrt-unprod17.2%
swap-sqr17.2%
metadata-eval17.2%
metadata-eval17.2%
swap-sqr17.2%
sqrt-unprod4.2%
add-sqr-sqrt9.5%
Applied egg-rr9.5%
associate-*r/9.5%
*-rgt-identity9.5%
associate-*r/9.5%
*-commutative9.5%
associate-*r/9.5%
*-rgt-identity9.5%
*-commutative9.5%
*-commutative9.5%
times-frac9.5%
metadata-eval9.5%
*-inverses9.5%
metadata-eval9.5%
Simplified9.5%
Final simplification9.5%
herbie shell --seed 2024092
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))