
(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 12 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 -4e+126)
(/ (- (- (/ (* 1.5 a) (/ b c)) b) b) (* a 3.0))
(if (<= b 2.6e-69)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+126) {
tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 2.6e-69) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - 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 <= (-4d+126)) then
tmp = ((((1.5d0 * a) / (b / c)) - b) - b) / (a * 3.0d0)
else if (b <= 2.6d-69) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - 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 <= -4e+126) {
tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 2.6e-69) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e+126: tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0) elif b <= 2.6e-69: tmp = (math.sqrt(((b * b) - (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 <= -4e+126) tmp = Float64(Float64(Float64(Float64(Float64(1.5 * a) / Float64(b / c)) - b) - b) / Float64(a * 3.0)); elseif (b <= 2.6e-69) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - 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 <= -4e+126) tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0); elseif (b <= 2.6e-69) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e+126], N[(N[(N[(N[(N[(1.5 * a), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.6e-69], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+126}:\\
\;\;\;\;\frac{\left(\frac{1.5 \cdot a}{\frac{b}{c}} - b\right) - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{-69}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 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 < -3.9999999999999997e126Initial program 53.2%
Taylor expanded in b around -inf 91.4%
+-commutative91.4%
mul-1-neg91.4%
unsub-neg91.4%
associate-/l*97.1%
associate-*r/97.1%
Simplified97.1%
if -3.9999999999999997e126 < b < 2.6000000000000002e-69Initial program 84.2%
if 2.6000000000000002e-69 < b Initial program 16.3%
Taylor expanded in b around inf 88.5%
associate-*r/88.5%
Simplified88.5%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -8.5e-177)
(/ (- (- (/ (* 1.5 a) (/ b c)) b) b) (* a 3.0))
(if (<= b 2.6e-69)
(/ (- (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 <= -8.5e-177) {
tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 2.6e-69) {
tmp = (sqrt((-3.0 * (a * 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-177)) then
tmp = ((((1.5d0 * a) / (b / c)) - b) - b) / (a * 3.0d0)
else if (b <= 2.6d-69) then
tmp = (sqrt(((-3.0d0) * (a * 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-177) {
tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 2.6e-69) {
tmp = (Math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.5e-177: tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0) elif b <= 2.6e-69: tmp = (math.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 <= -8.5e-177) tmp = Float64(Float64(Float64(Float64(Float64(1.5 * a) / Float64(b / c)) - b) - b) / Float64(a * 3.0)); elseif (b <= 2.6e-69) 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
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.5e-177) tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0); elseif (b <= 2.6e-69) tmp = (sqrt((-3.0 * (a * 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-177], N[(N[(N[(N[(N[(1.5 * a), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.6e-69], 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 -8.5 \cdot 10^{-177}:\\
\;\;\;\;\frac{\left(\frac{1.5 \cdot a}{\frac{b}{c}} - b\right) - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{-69}:\\
\;\;\;\;\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 < -8.4999999999999993e-177Initial program 69.5%
Taylor expanded in b around -inf 79.9%
+-commutative79.9%
mul-1-neg79.9%
unsub-neg79.9%
associate-/l*83.2%
associate-*r/83.2%
Simplified83.2%
if -8.4999999999999993e-177 < b < 2.6000000000000002e-69Initial program 78.3%
Taylor expanded in b around 0 77.1%
if 2.6000000000000002e-69 < b Initial program 16.3%
Taylor expanded in b around inf 88.5%
associate-*r/88.5%
Simplified88.5%
Final simplification83.4%
(FPCore (a b c)
:precision binary64
(if (<= b -8.5e-177)
(/ (- (- (/ (* 1.5 a) (/ b c)) b) b) (* a 3.0))
(if (<= b 3.9e-70)
(/ (- (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 <= -8.5e-177) {
tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 3.9e-70) {
tmp = (sqrt((c * (a * -3.0))) - 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-177)) then
tmp = ((((1.5d0 * a) / (b / c)) - b) - b) / (a * 3.0d0)
else if (b <= 3.9d-70) then
tmp = (sqrt((c * (a * (-3.0d0)))) - 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-177) {
tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 3.9e-70) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.5e-177: tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0) elif b <= 3.9e-70: tmp = (math.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 <= -8.5e-177) tmp = Float64(Float64(Float64(Float64(Float64(1.5 * a) / Float64(b / c)) - b) - b) / Float64(a * 3.0)); elseif (b <= 3.9e-70) 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
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.5e-177) tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0); elseif (b <= 3.9e-70) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.5e-177], N[(N[(N[(N[(N[(1.5 * a), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.9e-70], 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 -8.5 \cdot 10^{-177}:\\
\;\;\;\;\frac{\left(\frac{1.5 \cdot a}{\frac{b}{c}} - b\right) - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-70}:\\
\;\;\;\;\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 < -8.4999999999999993e-177Initial program 69.5%
Taylor expanded in b around -inf 79.9%
+-commutative79.9%
mul-1-neg79.9%
unsub-neg79.9%
associate-/l*83.2%
associate-*r/83.2%
Simplified83.2%
if -8.4999999999999993e-177 < b < 3.90000000000000019e-70Initial program 78.3%
Taylor expanded in b around 0 77.1%
associate-*r*77.2%
*-commutative77.2%
*-commutative77.2%
Simplified77.2%
if 3.90000000000000019e-70 < b Initial program 16.3%
Taylor expanded in b around inf 88.5%
associate-*r/88.5%
Simplified88.5%
Final simplification83.4%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* (/ -0.3333333333333333 a) (+ (* a (/ (* c -1.5) b)) (* b 2.0))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (-0.3333333333333333 / a) * ((a * ((c * -1.5) / b)) + (b * 2.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 <= (-5d-310)) then
tmp = ((-0.3333333333333333d0) / a) * ((a * ((c * (-1.5d0)) / b)) + (b * 2.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 <= -5e-310) {
tmp = (-0.3333333333333333 / a) * ((a * ((c * -1.5) / b)) + (b * 2.0));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (-0.3333333333333333 / a) * ((a * ((c * -1.5) / b)) + (b * 2.0)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(Float64(a * Float64(Float64(c * -1.5) / b)) + Float64(b * 2.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 <= -5e-310) tmp = (-0.3333333333333333 / a) * ((a * ((c * -1.5) / b)) + (b * 2.0)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(N[(a * N[(N[(c * -1.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(a \cdot \frac{c \cdot -1.5}{b} + b \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.4%
Taylor expanded in b around inf 2.0%
associate-*r/2.0%
clear-num2.0%
Applied egg-rr2.0%
associate-/r/2.0%
*-commutative2.0%
associate-*l*2.0%
Simplified2.0%
div-inv2.0%
associate-+r+2.1%
add-sqr-sqrt10.9%
sqrt-unprod21.4%
sqr-neg21.4%
sqrt-unprod0.0%
add-sqr-sqrt0.9%
associate-*l/0.9%
*-un-lft-identity0.9%
*-un-lft-identity0.9%
times-frac0.8%
/-rgt-identity0.8%
add-sqr-sqrt0.4%
sqrt-unprod24.0%
*-commutative24.0%
*-commutative24.0%
swap-sqr24.0%
metadata-eval24.0%
metadata-eval24.0%
swap-sqr24.0%
sqrt-unprod30.5%
Applied egg-rr68.8%
*-commutative68.8%
associate-*l/68.8%
metadata-eval68.8%
+-commutative68.8%
count-268.8%
*-commutative68.8%
Simplified68.8%
if -4.999999999999985e-310 < b Initial program 34.2%
Taylor expanded in b around inf 68.9%
associate-*r/68.9%
Simplified68.9%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (- (- (/ (* 1.5 a) (/ b c)) b) b) (* a 3.0)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((((1.5 * a) / (b / c)) - b) - 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 <= (-5d-310)) then
tmp = ((((1.5d0 * a) / (b / c)) - b) - 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 <= -5e-310) {
tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(Float64(Float64(1.5 * a) / Float64(b / c)) - b) - 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 <= -5e-310) tmp = ((((1.5 * a) / (b / c)) - b) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(N[(N[(1.5 * a), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(\frac{1.5 \cdot a}{\frac{b}{c}} - b\right) - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.4%
Taylor expanded in b around -inf 66.2%
+-commutative66.2%
mul-1-neg66.2%
unsub-neg66.2%
associate-/l*68.9%
associate-*r/68.9%
Simplified68.9%
if -4.999999999999985e-310 < b Initial program 34.2%
Taylor expanded in b around inf 68.9%
associate-*r/68.9%
Simplified68.9%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} 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 = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
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 = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); 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-310) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); else tmp = (c * -0.5) / 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[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.4%
Taylor expanded in b around -inf 68.8%
if -4.999999999999985e-310 < b Initial program 34.2%
Taylor expanded in b around inf 68.9%
associate-*r/68.9%
Simplified68.9%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* (* b 2.0) (/ (/ 1.0 a) -3.0)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * 2.0) * ((1.0 / 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 <= (-5d-310)) then
tmp = (b * 2.0d0) * ((1.0d0 / 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 <= -5e-310) {
tmp = (b * 2.0) * ((1.0 / a) / -3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * 2.0) * ((1.0 / a) / -3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b * 2.0) * Float64(Float64(1.0 / 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 <= -5e-310) tmp = (b * 2.0) * ((1.0 / a) / -3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b * 2.0), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] / -3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(b \cdot 2\right) \cdot \frac{\frac{1}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.4%
Applied egg-rr66.0%
associate-/r*65.9%
Simplified65.9%
Taylor expanded in b around -inf 68.7%
*-commutative68.7%
Simplified68.7%
if -4.999999999999985e-310 < b Initial program 34.2%
Taylor expanded in b around inf 68.9%
associate-*r/68.9%
Simplified68.9%
Final simplification68.8%
(FPCore (a b c) :precision binary64 (if (<= b 5.5) (* b (/ -0.6666666666666666 a)) (* c (/ 0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.5) {
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 <= 5.5d0) 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 <= 5.5) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.5: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.5) 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 <= 5.5) tmp = b * (-0.6666666666666666 / a); else tmp = c * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.5], 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.5:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if b < 5.5Initial program 70.0%
Applied egg-rr66.0%
sub-neg66.0%
distribute-rgt-out--66.0%
*-commutative66.0%
associate-*r*66.0%
*-commutative66.0%
associate-*l*66.0%
Simplified66.0%
Taylor expanded in b around -inf 54.7%
associate-*r/54.7%
associate-/l*54.7%
associate-/r/54.7%
Simplified54.7%
if 5.5 < b Initial program 11.8%
Taylor expanded in b around -inf 2.4%
Taylor expanded in b around 0 35.2%
metadata-eval35.2%
times-frac35.2%
*-commutative35.2%
times-frac35.2%
/-rgt-identity35.2%
Simplified35.2%
Final simplification49.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* b (/ -0.6666666666666666 a)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b * Float64(-0.6666666666666666 / 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-310) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.4%
Applied egg-rr65.9%
sub-neg65.9%
distribute-rgt-out--65.9%
*-commutative65.9%
associate-*r*66.0%
*-commutative66.0%
associate-*l*66.0%
Simplified66.0%
Taylor expanded in b around -inf 68.7%
associate-*r/68.7%
associate-/l*68.7%
associate-/r/68.7%
Simplified68.7%
if -4.999999999999985e-310 < b Initial program 34.2%
Taylor expanded in b around inf 68.9%
associate-*r/68.9%
associate-/l*68.5%
Simplified68.5%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* a -1.5)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -1.5);
} 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-310)) then
tmp = b / (a * (-1.5d0))
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-310) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (a * -1.5) else: tmp = -0.5 / (b / c) 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(b / c)); 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 / (b / c); 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[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.4%
Applied egg-rr65.9%
sub-neg65.9%
distribute-rgt-out--65.9%
*-commutative65.9%
associate-*r*66.0%
*-commutative66.0%
associate-*l*66.0%
Simplified66.0%
Taylor expanded in b around -inf 68.7%
associate-*r/68.7%
associate-/l*68.7%
associate-/r/68.7%
Simplified68.7%
*-commutative68.7%
clear-num68.6%
un-div-inv68.6%
div-inv68.7%
metadata-eval68.7%
Applied egg-rr68.7%
if -4.999999999999985e-310 < b Initial program 34.2%
Taylor expanded in b around inf 68.9%
associate-*r/68.9%
associate-/l*68.5%
Simplified68.5%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -1.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-310)) then
tmp = b / (a * (-1.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-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / 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(Float64(c * -0.5) / 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 = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 70.4%
Applied egg-rr65.9%
sub-neg65.9%
distribute-rgt-out--65.9%
*-commutative65.9%
associate-*r*66.0%
*-commutative66.0%
associate-*l*66.0%
Simplified66.0%
Taylor expanded in b around -inf 68.7%
associate-*r/68.7%
associate-/l*68.7%
associate-/r/68.7%
Simplified68.7%
*-commutative68.7%
clear-num68.6%
un-div-inv68.6%
div-inv68.7%
metadata-eval68.7%
Applied egg-rr68.7%
if -4.999999999999985e-310 < b Initial program 34.2%
Taylor expanded in b around inf 68.9%
associate-*r/68.9%
Simplified68.9%
Final simplification68.8%
(FPCore (a b c) :precision binary64 (* c (/ 0.5 b)))
double code(double a, double b, double c) {
return c * (0.5 / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c * (0.5d0 / b)
end function
public static double code(double a, double b, double c) {
return c * (0.5 / b);
}
def code(a, b, c): return c * (0.5 / b)
function code(a, b, c) return Float64(c * Float64(0.5 / b)) end
function tmp = code(a, b, c) tmp = c * (0.5 / b); end
code[a_, b_, c_] := N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{0.5}{b}
\end{array}
Initial program 55.7%
Taylor expanded in b around -inf 41.8%
Taylor expanded in b around 0 11.1%
metadata-eval11.1%
times-frac11.1%
*-commutative11.1%
times-frac11.1%
/-rgt-identity11.1%
Simplified11.1%
Final simplification11.1%
herbie shell --seed 2024016
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))