
(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 -5.5e+130)
(/ (fma -2.0 (/ b a) (* (/ -0.5 b) (* c -3.0))) 3.0)
(if (<= b 4e-101)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/ (* -0.5 c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e+130) {
tmp = fma(-2.0, (b / a), ((-0.5 / b) * (c * -3.0))) / 3.0;
} else if (b <= 4e-101) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (-0.5 * c) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.5e+130) tmp = Float64(fma(-2.0, Float64(b / a), Float64(Float64(-0.5 / b) * Float64(c * -3.0))) / 3.0); elseif (b <= 4e-101) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(-0.5 * c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.5e+130], N[(N[(-2.0 * N[(b / a), $MachinePrecision] + N[(N[(-0.5 / b), $MachinePrecision] * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 4e-101], 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[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{+130}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, \frac{b}{a}, \frac{-0.5}{b} \cdot \left(c \cdot -3\right)\right)}{3}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-101}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b}\\
\end{array}
\end{array}
if b < -5.4999999999999997e130Initial program 44.7%
Applied egg-rr44.7%
div-inv44.7%
associate-/r*44.9%
frac-2neg44.9%
metadata-eval44.9%
Applied egg-rr44.9%
distribute-neg-frac44.9%
sub-neg44.9%
+-commutative44.9%
distribute-neg-in44.9%
remove-double-neg44.9%
sub-neg44.9%
Simplified44.9%
Taylor expanded in b around -inf 0.0%
fma-def0.0%
associate-*r/0.0%
*-rgt-identity0.0%
times-frac0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt97.8%
associate-*r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
Simplified97.8%
if -5.4999999999999997e130 < b < 4.00000000000000021e-101Initial program 80.6%
if 4.00000000000000021e-101 < b Initial program 14.4%
Taylor expanded in b around inf 83.5%
associate-*r/83.5%
Simplified83.5%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.05e-113)
(/ (/ (* b -2.0) a) 3.0)
(if (<= b 2e-89)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(/ (* -0.5 c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e-113) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 2e-89) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} 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 <= (-2.05d-113)) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
else if (b <= 2d-89) then
tmp = (sqrt(((-3.0d0) * (a * c))) - b) / (a * 3.0d0)
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 <= -2.05e-113) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 2e-89) {
tmp = (Math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (-0.5 * c) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.05e-113: tmp = ((b * -2.0) / a) / 3.0 elif b <= 2e-89: tmp = (math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0) else: tmp = (-0.5 * c) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.05e-113) tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0); elseif (b <= 2e-89) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(-0.5 * c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.05e-113) tmp = ((b * -2.0) / a) / 3.0; elseif (b <= 2e-89) tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0); else tmp = (-0.5 * c) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.05e-113], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 2e-89], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.05 \cdot 10^{-113}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-89}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b}\\
\end{array}
\end{array}
if b < -2.05e-113Initial program 72.5%
Applied egg-rr57.9%
div-inv57.9%
associate-/r*58.0%
frac-2neg58.0%
metadata-eval58.0%
Applied egg-rr58.0%
distribute-neg-frac58.0%
sub-neg58.0%
+-commutative58.0%
distribute-neg-in58.0%
remove-double-neg58.0%
sub-neg58.0%
Simplified58.0%
Taylor expanded in b around -inf 82.3%
*-commutative82.3%
Simplified82.3%
if -2.05e-113 < b < 2.00000000000000008e-89Initial program 70.7%
Taylor expanded in b around 0 68.8%
if 2.00000000000000008e-89 < b Initial program 14.4%
Taylor expanded in b around inf 83.5%
associate-*r/83.5%
Simplified83.5%
Final simplification79.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.35e-112)
(/ (/ (* b -2.0) a) 3.0)
(if (<= b 8.2e-93)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* -0.5 c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-112) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 8.2e-93) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (-0.5 * c) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.35d-112)) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
else if (b <= 8.2d-93) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = ((-0.5d0) * c) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-112) {
tmp = ((b * -2.0) / a) / 3.0;
} else if (b <= 8.2e-93) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (-0.5 * c) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.35e-112: tmp = ((b * -2.0) / a) / 3.0 elif b <= 8.2e-93: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (-0.5 * c) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.35e-112) tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0); elseif (b <= 8.2e-93) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(-0.5 * c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.35e-112) tmp = ((b * -2.0) / a) / 3.0; elseif (b <= 8.2e-93) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (-0.5 * c) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.35e-112], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 8.2e-93], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{-112}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{elif}\;b \leq 8.2 \cdot 10^{-93}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b}\\
\end{array}
\end{array}
if b < -1.35e-112Initial program 72.5%
Applied egg-rr57.9%
div-inv57.9%
associate-/r*58.0%
frac-2neg58.0%
metadata-eval58.0%
Applied egg-rr58.0%
distribute-neg-frac58.0%
sub-neg58.0%
+-commutative58.0%
distribute-neg-in58.0%
remove-double-neg58.0%
sub-neg58.0%
Simplified58.0%
Taylor expanded in b around -inf 82.3%
*-commutative82.3%
Simplified82.3%
if -1.35e-112 < b < 8.1999999999999998e-93Initial program 70.7%
Taylor expanded in b around 0 68.8%
associate-*r*68.8%
*-commutative68.8%
Simplified68.8%
if 8.1999999999999998e-93 < b Initial program 14.4%
Taylor expanded in b around inf 83.5%
associate-*r/83.5%
Simplified83.5%
Final simplification79.6%
(FPCore (a b c)
:precision binary64
(if (<= b -9e-113)
(/ (fma -2.0 (/ b a) (* (/ -0.5 b) (* c -3.0))) 3.0)
(if (<= b 1.9e-90)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* -0.5 c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e-113) {
tmp = fma(-2.0, (b / a), ((-0.5 / b) * (c * -3.0))) / 3.0;
} else if (b <= 1.9e-90) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (-0.5 * c) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -9e-113) tmp = Float64(fma(-2.0, Float64(b / a), Float64(Float64(-0.5 / b) * Float64(c * -3.0))) / 3.0); elseif (b <= 1.9e-90) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(-0.5 * c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -9e-113], N[(N[(-2.0 * N[(b / a), $MachinePrecision] + N[(N[(-0.5 / b), $MachinePrecision] * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 1.9e-90], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-113}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, \frac{b}{a}, \frac{-0.5}{b} \cdot \left(c \cdot -3\right)\right)}{3}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b}\\
\end{array}
\end{array}
if b < -9.0000000000000002e-113Initial program 72.5%
Applied egg-rr57.9%
div-inv57.9%
associate-/r*58.0%
frac-2neg58.0%
metadata-eval58.0%
Applied egg-rr58.0%
distribute-neg-frac58.0%
sub-neg58.0%
+-commutative58.0%
distribute-neg-in58.0%
remove-double-neg58.0%
sub-neg58.0%
Simplified58.0%
Taylor expanded in b around -inf 0.0%
fma-def0.0%
associate-*r/0.0%
*-rgt-identity0.0%
times-frac0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt82.4%
associate-*r/82.4%
/-rgt-identity82.4%
*-commutative82.4%
Simplified82.4%
if -9.0000000000000002e-113 < b < 1.9e-90Initial program 70.7%
Taylor expanded in b around 0 68.8%
associate-*r*68.8%
*-commutative68.8%
Simplified68.8%
if 1.9e-90 < b Initial program 14.4%
Taylor expanded in b around inf 83.5%
associate-*r/83.5%
Simplified83.5%
Final simplification79.7%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (+ (* 0.5 (/ c b)) (* (/ b a) -0.6666666666666666)) (/ (* -0.5 c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (0.5 * (c / b)) + ((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 <= (-2d-310)) then
tmp = (0.5d0 * (c / b)) + ((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 <= -2e-310) {
tmp = (0.5 * (c / b)) + ((b / a) * -0.6666666666666666);
} else {
tmp = (-0.5 * c) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (0.5 * (c / b)) + ((b / a) * -0.6666666666666666) else: tmp = (-0.5 * c) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(Float64(b / a) * -0.6666666666666666)); else tmp = Float64(Float64(-0.5 * c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = (0.5 * (c / b)) + ((b / a) * -0.6666666666666666); else tmp = (-0.5 * c) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + \frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 73.1%
Taylor expanded in b around -inf 67.1%
if -1.999999999999994e-310 < b Initial program 26.0%
Taylor expanded in b around inf 67.4%
associate-*r/67.4%
Simplified67.4%
Final simplification67.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (/ (* b -2.0) a) 3.0) (/ (* -0.5 c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = ((b * -2.0) / a) / 3.0;
} 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 <= (-2d-310)) then
tmp = ((b * (-2.0d0)) / a) / 3.0d0
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 <= -2e-310) {
tmp = ((b * -2.0) / a) / 3.0;
} else {
tmp = (-0.5 * c) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = ((b * -2.0) / a) / 3.0 else: tmp = (-0.5 * c) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0); else tmp = Float64(Float64(-0.5 * c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = ((b * -2.0) / a) / 3.0; else tmp = (-0.5 * c) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 73.1%
Applied egg-rr64.3%
div-inv64.3%
associate-/r*64.4%
frac-2neg64.4%
metadata-eval64.4%
Applied egg-rr64.4%
distribute-neg-frac64.4%
sub-neg64.4%
+-commutative64.4%
distribute-neg-in64.4%
remove-double-neg64.4%
sub-neg64.4%
Simplified64.4%
Taylor expanded in b around -inf 67.0%
*-commutative67.0%
Simplified67.0%
if -1.999999999999994e-310 < b Initial program 26.0%
Taylor expanded in b around inf 67.4%
associate-*r/67.4%
Simplified67.4%
Final simplification67.2%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e+34) (* b (/ -0.6666666666666666 a)) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e+34) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 3.1d+34) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = 0.5d0 * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e+34) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e+34: tmp = b * (-0.6666666666666666 / a) else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e+34) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.1e+34) tmp = b * (-0.6666666666666666 / a); else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e+34], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{+34}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.09999999999999977e34Initial program 66.6%
Applied egg-rr60.1%
Taylor expanded in b around -inf 48.2%
associate-*r/48.1%
associate-*l/48.1%
Simplified48.1%
if 3.09999999999999977e34 < b Initial program 8.5%
Taylor expanded in b around inf 71.6%
associate-/l*74.1%
Simplified74.1%
frac-2neg74.1%
distribute-lft-neg-in74.1%
metadata-eval74.1%
*-commutative74.1%
distribute-frac-neg74.1%
add-sqr-sqrt35.3%
sqrt-unprod38.7%
swap-sqr38.7%
metadata-eval38.7%
metadata-eval38.7%
swap-sqr38.7%
*-commutative38.7%
*-commutative38.7%
sqrt-unprod14.9%
add-sqr-sqrt31.6%
times-frac31.6%
metadata-eval31.6%
div-inv31.6%
clear-num31.6%
Applied egg-rr31.6%
distribute-lft-neg-in31.6%
metadata-eval31.6%
associate-*r/31.5%
associate-*l/31.8%
*-commutative31.8%
Simplified31.8%
Taylor expanded in c around 0 31.4%
Final simplification43.1%
(FPCore (a b c) :precision binary64 (if (<= b 3.9e-308) (* b (/ -0.6666666666666666 a)) (* (/ -0.5 b) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.9e-308) {
tmp = b * (-0.6666666666666666 / 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 <= 3.9d-308) then
tmp = b * ((-0.6666666666666666d0) / 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 <= 3.9e-308) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (-0.5 / b) * c;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.9e-308: tmp = b * (-0.6666666666666666 / a) else: tmp = (-0.5 / b) * c return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.9e-308) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(-0.5 / b) * c); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.9e-308) tmp = b * (-0.6666666666666666 / a); else tmp = (-0.5 / b) * c; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.9e-308], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / b), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.9 \cdot 10^{-308}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{b} \cdot c\\
\end{array}
\end{array}
if b < 3.8999999999999999e-308Initial program 73.1%
Applied egg-rr64.3%
Taylor expanded in b around -inf 67.0%
associate-*r/66.9%
associate-*l/66.9%
Simplified66.9%
if 3.8999999999999999e-308 < b Initial program 26.0%
Taylor expanded in b around inf 53.8%
associate-/l*56.2%
Simplified56.2%
add-cbrt-cube34.5%
pow1/324.3%
pow324.3%
div-inv24.3%
clear-num24.3%
Applied egg-rr24.3%
Taylor expanded in a around -inf 67.4%
associate-*r/67.4%
*-rgt-identity67.4%
times-frac67.2%
/-rgt-identity67.2%
Simplified67.2%
Final simplification67.1%
(FPCore (a b c) :precision binary64 (if (<= b 1e-309) (* (/ b a) -0.6666666666666666) (* (/ -0.5 b) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1e-309) {
tmp = (b / a) * -0.6666666666666666;
} 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 <= 1d-309) then
tmp = (b / a) * (-0.6666666666666666d0)
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 <= 1e-309) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (-0.5 / b) * c;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1e-309: tmp = (b / a) * -0.6666666666666666 else: tmp = (-0.5 / b) * c return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1e-309) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(-0.5 / b) * c); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1e-309) tmp = (b / a) * -0.6666666666666666; else tmp = (-0.5 / b) * c; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1e-309], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(-0.5 / b), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 10^{-309}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{b} \cdot c\\
\end{array}
\end{array}
if b < 1.000000000000002e-309Initial program 73.1%
Taylor expanded in b around -inf 67.0%
*-commutative67.0%
Simplified67.0%
if 1.000000000000002e-309 < b Initial program 26.0%
Taylor expanded in b around inf 53.8%
associate-/l*56.2%
Simplified56.2%
add-cbrt-cube34.5%
pow1/324.3%
pow324.3%
div-inv24.3%
clear-num24.3%
Applied egg-rr24.3%
Taylor expanded in a around -inf 67.4%
associate-*r/67.4%
*-rgt-identity67.4%
times-frac67.2%
/-rgt-identity67.2%
Simplified67.2%
Final simplification67.1%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* (/ b a) -0.6666666666666666) (/ (* -0.5 c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (-0.5 * c) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = (-0.5 * c) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(-0.5 * c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = (b / a) * -0.6666666666666666; else tmp = (-0.5 * c) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 73.1%
Taylor expanded in b around -inf 67.0%
*-commutative67.0%
Simplified67.0%
if -1.999999999999994e-310 < b Initial program 26.0%
Taylor expanded in b around inf 67.4%
associate-*r/67.4%
Simplified67.4%
Final simplification67.2%
(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.2%
Taylor expanded in b around inf 28.4%
associate-/l*29.6%
Simplified29.6%
frac-2neg29.6%
distribute-lft-neg-in29.6%
metadata-eval29.6%
*-commutative29.6%
distribute-frac-neg29.6%
add-sqr-sqrt14.7%
sqrt-unprod16.7%
swap-sqr16.7%
metadata-eval16.7%
metadata-eval16.7%
swap-sqr16.7%
*-commutative16.7%
*-commutative16.7%
sqrt-unprod5.5%
add-sqr-sqrt11.7%
times-frac11.7%
metadata-eval11.7%
div-inv11.7%
clear-num11.7%
Applied egg-rr11.7%
distribute-lft-neg-in11.7%
metadata-eval11.7%
associate-*r/11.6%
associate-*l/11.7%
*-commutative11.7%
Simplified11.7%
Taylor expanded in c around 0 11.6%
Final simplification11.6%
herbie shell --seed 2023307
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))