
(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 10 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.4e+153)
(* -2.0 (/ b (* 3.0 a)))
(if (<= b 2.8e-64)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.4e+153) {
tmp = -2.0 * (b / (3.0 * a));
} else if (b <= 2.8e-64) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * 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 <= (-8.4d+153)) then
tmp = (-2.0d0) * (b / (3.0d0 * a))
else if (b <= 2.8d-64) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * 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 <= -8.4e+153) {
tmp = -2.0 * (b / (3.0 * a));
} else if (b <= 2.8e-64) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.4e+153: tmp = -2.0 * (b / (3.0 * a)) elif b <= 2.8e-64: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.4e+153) tmp = Float64(-2.0 * Float64(b / Float64(3.0 * a))); elseif (b <= 2.8e-64) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * 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 <= -8.4e+153) tmp = -2.0 * (b / (3.0 * a)); elseif (b <= 2.8e-64) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.4e+153], N[(-2.0 * N[(b / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.8e-64], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.4 \cdot 10^{+153}:\\
\;\;\;\;-2 \cdot \frac{b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-64}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -8.40000000000000067e153Initial program 23.6%
Taylor expanded in b around -inf 97.5%
*-commutative97.5%
Simplified97.5%
*-commutative97.5%
associate-/l*97.5%
Applied egg-rr97.5%
if -8.40000000000000067e153 < b < 2.80000000000000004e-64Initial program 81.0%
if 2.80000000000000004e-64 < b Initial program 14.0%
Taylor expanded in b around inf 88.9%
*-commutative88.9%
Simplified88.9%
Final simplification86.1%
(FPCore (a b c)
:precision binary64
(if (<= b -3.4e-44)
(- (* (/ c b) (- -0.5)) (* 0.6666666666666666 (/ b a)))
(if (<= b 1e-64)
(* 0.3333333333333333 (/ (+ b (sqrt (* -3.0 (* a c)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.4e-44) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a));
} else if (b <= 1e-64) {
tmp = 0.3333333333333333 * ((b + sqrt((-3.0 * (a * c)))) / 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 <= (-3.4d-44)) then
tmp = ((c / b) * -(-0.5d0)) - (0.6666666666666666d0 * (b / a))
else if (b <= 1d-64) then
tmp = 0.3333333333333333d0 * ((b + sqrt(((-3.0d0) * (a * c)))) / 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 <= -3.4e-44) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a));
} else if (b <= 1e-64) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((-3.0 * (a * c)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.4e-44: tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)) elif b <= 1e-64: tmp = 0.3333333333333333 * ((b + math.sqrt((-3.0 * (a * c)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.4e-44) tmp = Float64(Float64(Float64(c / b) * Float64(-(-0.5))) - Float64(0.6666666666666666 * Float64(b / a))); elseif (b <= 1e-64) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(-3.0 * Float64(a * c)))) / 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 <= -3.4e-44) tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)); elseif (b <= 1e-64) tmp = 0.3333333333333333 * ((b + sqrt((-3.0 * (a * c)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.4e-44], N[(N[(N[(c / b), $MachinePrecision] * (--0.5)), $MachinePrecision] - N[(0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-64], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.4 \cdot 10^{-44}:\\
\;\;\;\;\frac{c}{b} \cdot \left(--0.5\right) - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 10^{-64}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{-3 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.40000000000000016e-44Initial program 62.5%
Taylor expanded in b around -inf 93.9%
Taylor expanded in c around 0 94.0%
if -3.40000000000000016e-44 < b < 9.99999999999999965e-65Initial program 73.4%
Taylor expanded in b around 0 65.6%
*-un-lft-identity65.6%
times-frac65.5%
metadata-eval65.5%
add-sqr-sqrt34.8%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-prod31.0%
add-sqr-sqrt63.2%
associate-*r*63.2%
*-commutative63.2%
Applied egg-rr63.2%
Taylor expanded in a around 0 63.2%
if 9.99999999999999965e-65 < b Initial program 14.0%
Taylor expanded in b around inf 88.9%
*-commutative88.9%
Simplified88.9%
Final simplification81.9%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-32)
(- (* (/ c b) (- -0.5)) (* 0.6666666666666666 (/ b a)))
(if (<= b 7.5e-64)
(/ (+ b (sqrt (* c (* a -3.0)))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-32) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a));
} else if (b <= 7.5e-64) {
tmp = (b + sqrt((c * (a * -3.0)))) / (3.0 * 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 <= (-6.5d-32)) then
tmp = ((c / b) * -(-0.5d0)) - (0.6666666666666666d0 * (b / a))
else if (b <= 7.5d-64) then
tmp = (b + sqrt((c * (a * (-3.0d0))))) / (3.0d0 * 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 <= -6.5e-32) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a));
} else if (b <= 7.5e-64) {
tmp = (b + Math.sqrt((c * (a * -3.0)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-32: tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)) elif b <= 7.5e-64: tmp = (b + math.sqrt((c * (a * -3.0)))) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-32) tmp = Float64(Float64(Float64(c / b) * Float64(-(-0.5))) - Float64(0.6666666666666666 * Float64(b / a))); elseif (b <= 7.5e-64) tmp = Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / Float64(3.0 * 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 <= -6.5e-32) tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)); elseif (b <= 7.5e-64) tmp = (b + sqrt((c * (a * -3.0)))) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-32], N[(N[(N[(c / b), $MachinePrecision] * (--0.5)), $MachinePrecision] - N[(0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-64], N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-32}:\\
\;\;\;\;\frac{c}{b} \cdot \left(--0.5\right) - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-64}:\\
\;\;\;\;\frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.49999999999999988e-32Initial program 62.5%
Taylor expanded in b around -inf 93.9%
Taylor expanded in c around 0 94.0%
if -6.49999999999999988e-32 < b < 7.49999999999999949e-64Initial program 73.4%
Taylor expanded in b around 0 65.6%
div-inv65.5%
add-sqr-sqrt34.9%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-prod31.0%
add-sqr-sqrt63.2%
associate-*r*63.2%
*-commutative63.2%
*-commutative63.2%
Applied egg-rr63.2%
associate-*r/63.4%
*-rgt-identity63.4%
*-commutative63.4%
Simplified63.4%
if 7.49999999999999949e-64 < b Initial program 14.0%
Taylor expanded in b around inf 88.9%
*-commutative88.9%
Simplified88.9%
Final simplification81.9%
(FPCore (a b c)
:precision binary64
(if (<= b -7.6e-42)
(- (* (/ c b) (- -0.5)) (* 0.6666666666666666 (/ b a)))
(if (<= b 3.2e-62)
(/ (- (sqrt (* -3.0 (* a c))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.6e-42) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a));
} else if (b <= 3.2e-62) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (3.0 * 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 <= (-7.6d-42)) then
tmp = ((c / b) * -(-0.5d0)) - (0.6666666666666666d0 * (b / a))
else if (b <= 3.2d-62) then
tmp = (sqrt(((-3.0d0) * (a * c))) - b) / (3.0d0 * 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 <= -7.6e-42) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a));
} else if (b <= 3.2e-62) {
tmp = (Math.sqrt((-3.0 * (a * c))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.6e-42: tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)) elif b <= 3.2e-62: tmp = (math.sqrt((-3.0 * (a * c))) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.6e-42) tmp = Float64(Float64(Float64(c / b) * Float64(-(-0.5))) - Float64(0.6666666666666666 * Float64(b / a))); elseif (b <= 3.2e-62) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / Float64(3.0 * 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 <= -7.6e-42) tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)); elseif (b <= 3.2e-62) tmp = (sqrt((-3.0 * (a * c))) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.6e-42], N[(N[(N[(c / b), $MachinePrecision] * (--0.5)), $MachinePrecision] - N[(0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.2e-62], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{-42}:\\
\;\;\;\;\frac{c}{b} \cdot \left(--0.5\right) - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.60000000000000035e-42Initial program 62.5%
Taylor expanded in b around -inf 93.9%
Taylor expanded in c around 0 94.0%
if -7.60000000000000035e-42 < b < 3.20000000000000021e-62Initial program 73.4%
Taylor expanded in b around 0 65.6%
if 3.20000000000000021e-62 < b Initial program 14.0%
Taylor expanded in b around inf 88.9%
*-commutative88.9%
Simplified88.9%
Final simplification82.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e-36)
(- (* (/ c b) (- -0.5)) (* 0.6666666666666666 (/ b a)))
(if (<= b 1.35e-63)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-36) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a));
} else if (b <= 1.35e-63) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * 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 <= (-1.15d-36)) then
tmp = ((c / b) * -(-0.5d0)) - (0.6666666666666666d0 * (b / a))
else if (b <= 1.35d-63) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * 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 <= -1.15e-36) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a));
} else if (b <= 1.35e-63) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-36: tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)) elif b <= 1.35e-63: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-36) tmp = Float64(Float64(Float64(c / b) * Float64(-(-0.5))) - Float64(0.6666666666666666 * Float64(b / a))); elseif (b <= 1.35e-63) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * 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 <= -1.15e-36) tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)); elseif (b <= 1.35e-63) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-36], N[(N[(N[(c / b), $MachinePrecision] * (--0.5)), $MachinePrecision] - N[(0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-63], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{-36}:\\
\;\;\;\;\frac{c}{b} \cdot \left(--0.5\right) - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-63}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.14999999999999998e-36Initial program 62.5%
Taylor expanded in b around -inf 93.9%
Taylor expanded in c around 0 94.0%
if -1.14999999999999998e-36 < b < 1.3500000000000001e-63Initial program 73.4%
Taylor expanded in b around 0 65.6%
*-commutative65.6%
*-commutative65.6%
associate-*r*65.7%
Simplified65.7%
if 1.3500000000000001e-63 < b Initial program 14.0%
Taylor expanded in b around inf 88.9%
*-commutative88.9%
Simplified88.9%
Final simplification82.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (- (* (/ c b) (- -0.5)) (* 0.6666666666666666 (/ b a))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / 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 <= (-5d-310)) then
tmp = ((c / b) * -(-0.5d0)) - (0.6666666666666666d0 * (b / 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 <= -5e-310) {
tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(c / b) * Float64(-(-0.5))) - Float64(0.6666666666666666 * Float64(b / 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 <= -5e-310) tmp = ((c / b) * -(-0.5)) - (0.6666666666666666 * (b / a)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(c / b), $MachinePrecision] * (--0.5)), $MachinePrecision] - N[(0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} \cdot \left(--0.5\right) - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 69.0%
Taylor expanded in b around -inf 68.1%
Taylor expanded in c around 0 69.9%
if -4.999999999999985e-310 < b Initial program 31.0%
Taylor expanded in b around inf 65.6%
*-commutative65.6%
Simplified65.6%
Final simplification67.8%
(FPCore (a b c) :precision binary64 (if (<= b 2e-311) (* -2.0 (/ b (* 3.0 a))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2e-311) {
tmp = -2.0 * (b / (3.0 * 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 <= 2d-311) then
tmp = (-2.0d0) * (b / (3.0d0 * 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 <= 2e-311) {
tmp = -2.0 * (b / (3.0 * a));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2e-311: tmp = -2.0 * (b / (3.0 * a)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2e-311) tmp = Float64(-2.0 * Float64(b / Float64(3.0 * 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 <= 2e-311) tmp = -2.0 * (b / (3.0 * a)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2e-311], N[(-2.0 * N[(b / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{-311}:\\
\;\;\;\;-2 \cdot \frac{b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.9999999999999e-311Initial program 69.0%
Taylor expanded in b around -inf 69.8%
*-commutative69.8%
Simplified69.8%
*-commutative69.8%
associate-/l*69.8%
Applied egg-rr69.8%
if 1.9999999999999e-311 < b Initial program 31.0%
Taylor expanded in b around inf 65.6%
*-commutative65.6%
Simplified65.6%
Final simplification67.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* (/ b a) -0.6666666666666666) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b / a) * -0.6666666666666666;
} 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 <= (-5d-310)) then
tmp = (b / a) * (-0.6666666666666666d0)
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 <= -5e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c / b) * -0.5); 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 / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 69.0%
Taylor expanded in b around -inf 69.6%
*-commutative69.6%
Simplified69.6%
if -4.999999999999985e-310 < b Initial program 31.0%
Taylor expanded in b around inf 65.6%
*-commutative65.6%
Simplified65.6%
Final simplification67.6%
(FPCore (a b c) :precision binary64 (* b (/ -0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (-0.6666666666666666 / 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 * ((-0.6666666666666666d0) / a)
end function
public static double code(double a, double b, double c) {
return b * (-0.6666666666666666 / a);
}
def code(a, b, c): return b * (-0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(-0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (-0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{-0.6666666666666666}{a}
\end{array}
Initial program 50.3%
frac-2neg50.3%
div-inv50.2%
Applied egg-rr50.3%
associate-*r/50.4%
*-rgt-identity50.4%
*-commutative50.4%
metadata-eval50.4%
distribute-lft-neg-in50.4%
distribute-neg-frac250.4%
distribute-neg-frac50.4%
neg-mul-150.4%
times-frac49.9%
metadata-eval49.9%
Simplified49.9%
Taylor expanded in b around -inf 36.6%
associate-*r/36.5%
*-commutative36.5%
associate-/l*36.5%
Simplified36.5%
Final simplification36.5%
(FPCore (a b c) :precision binary64 (* (/ b a) -0.6666666666666666))
double code(double a, double b, double c) {
return (b / a) * -0.6666666666666666;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (b / a) * (-0.6666666666666666d0)
end function
public static double code(double a, double b, double c) {
return (b / a) * -0.6666666666666666;
}
def code(a, b, c): return (b / a) * -0.6666666666666666
function code(a, b, c) return Float64(Float64(b / a) * -0.6666666666666666) end
function tmp = code(a, b, c) tmp = (b / a) * -0.6666666666666666; end
code[a_, b_, c_] := N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a} \cdot -0.6666666666666666
\end{array}
Initial program 50.3%
Taylor expanded in b around -inf 36.6%
*-commutative36.6%
Simplified36.6%
Final simplification36.6%
herbie shell --seed 2024082
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))