
(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 -1.6e+128)
(/ 1.0 (* (/ 1.0 b) (* a -1.5)))
(if (<= b 8e-95)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e+128) {
tmp = 1.0 / ((1.0 / b) * (a * -1.5));
} else if (b <= 8e-95) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.6d+128)) then
tmp = 1.0d0 / ((1.0d0 / b) * (a * (-1.5d0)))
else if (b <= 8d-95) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e+128) {
tmp = 1.0 / ((1.0 / b) * (a * -1.5));
} else if (b <= 8e-95) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.6e+128: tmp = 1.0 / ((1.0 / b) * (a * -1.5)) elif b <= 8e-95: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.6e+128) tmp = Float64(1.0 / Float64(Float64(1.0 / b) * Float64(a * -1.5))); elseif (b <= 8e-95) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.6e+128) tmp = 1.0 / ((1.0 / b) * (a * -1.5)); elseif (b <= 8e-95) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+128], N[(1.0 / N[(N[(1.0 / b), $MachinePrecision] * N[(a * -1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-95], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{1}{\frac{1}{b} \cdot \left(a \cdot -1.5\right)}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-95}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.59999999999999993e128Initial program 42.1%
Taylor expanded in b around -inf 94.8%
*-commutative94.8%
Simplified94.8%
associate-*l/94.5%
clear-num94.5%
Applied egg-rr94.5%
*-un-lft-identity94.5%
times-frac94.6%
div-inv94.8%
metadata-eval94.8%
Applied egg-rr94.8%
if -1.59999999999999993e128 < b < 7.99999999999999992e-95Initial program 82.1%
if 7.99999999999999992e-95 < b Initial program 14.7%
Taylor expanded in b around inf 89.8%
associate-*r/89.8%
Simplified89.8%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.6e-84)
(/ b (* a -1.5))
(if (<= b 1.46e-95)
(* (/ -0.3333333333333333 a) (- b (sqrt (* c (* a -3.0)))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e-84) {
tmp = b / (a * -1.5);
} else if (b <= 1.46e-95) {
tmp = (-0.3333333333333333 / a) * (b - sqrt((c * (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 <= (-2.6d-84)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.46d-95) then
tmp = ((-0.3333333333333333d0) / a) * (b - sqrt((c * (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 <= -2.6e-84) {
tmp = b / (a * -1.5);
} else if (b <= 1.46e-95) {
tmp = (-0.3333333333333333 / a) * (b - Math.sqrt((c * (a * -3.0))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.6e-84: tmp = b / (a * -1.5) elif b <= 1.46e-95: tmp = (-0.3333333333333333 / a) * (b - math.sqrt((c * (a * -3.0)))) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.6e-84) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.46e-95) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(c * 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 <= -2.6e-84) tmp = b / (a * -1.5); elseif (b <= 1.46e-95) tmp = (-0.3333333333333333 / a) * (b - sqrt((c * (a * -3.0)))); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.6e-84], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.46e-95], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.6 \cdot 10^{-84}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.46 \cdot 10^{-95}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.6e-84Initial program 67.9%
Taylor expanded in b around -inf 86.8%
*-commutative86.8%
Simplified86.8%
*-commutative86.8%
add-exp-log36.2%
*-commutative36.2%
associate-*l/36.2%
associate-/l*36.2%
Applied egg-rr36.2%
rem-exp-log86.8%
div-inv86.9%
metadata-eval86.9%
Applied egg-rr86.9%
if -2.6e-84 < b < 1.45999999999999999e-95Initial program 77.2%
Taylor expanded in b around 0 75.4%
associate-*r*75.7%
*-commutative75.7%
*-commutative75.7%
Simplified75.7%
+-commutative75.7%
unsub-neg75.7%
Applied egg-rr75.7%
associate-*r*75.4%
*-commutative75.4%
rem-square-sqrt0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt75.6%
Simplified75.6%
frac-2neg75.6%
div-inv75.3%
Applied egg-rr75.3%
*-commutative75.3%
*-commutative75.3%
associate-/r*75.3%
metadata-eval75.3%
associate-*r*75.3%
*-commutative75.3%
associate-*r*75.3%
Simplified75.3%
if 1.45999999999999999e-95 < b Initial program 14.7%
Taylor expanded in b around inf 89.8%
associate-*r/89.8%
Simplified89.8%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -4.2e-84)
(/ b (* a -1.5))
(if (<= b 4.5e-98)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.2e-84) {
tmp = b / (a * -1.5);
} else if (b <= 4.5e-98) {
tmp = (sqrt((a * (c * -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 <= (-4.2d-84)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4.5d-98) then
tmp = (sqrt((a * (c * (-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 <= -4.2e-84) {
tmp = b / (a * -1.5);
} else if (b <= 4.5e-98) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.2e-84: tmp = b / (a * -1.5) elif b <= 4.5e-98: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.2e-84) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4.5e-98) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -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 <= -4.2e-84) tmp = b / (a * -1.5); elseif (b <= 4.5e-98) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.2e-84], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-98], N[(N[(N[Sqrt[N[(a * N[(c * -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 -4.2 \cdot 10^{-84}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-98}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.19999999999999996e-84Initial program 67.9%
Taylor expanded in b around -inf 86.8%
*-commutative86.8%
Simplified86.8%
*-commutative86.8%
add-exp-log36.2%
*-commutative36.2%
associate-*l/36.2%
associate-/l*36.2%
Applied egg-rr36.2%
rem-exp-log86.8%
div-inv86.9%
metadata-eval86.9%
Applied egg-rr86.9%
if -4.19999999999999996e-84 < b < 4.49999999999999997e-98Initial program 77.2%
Taylor expanded in b around 0 75.4%
associate-*r*75.7%
*-commutative75.7%
*-commutative75.7%
Simplified75.7%
+-commutative75.7%
unsub-neg75.7%
Applied egg-rr75.7%
associate-*r*75.4%
*-commutative75.4%
rem-square-sqrt0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt75.6%
Simplified75.6%
if 4.49999999999999997e-98 < b Initial program 14.7%
Taylor expanded in b around inf 89.8%
associate-*r/89.8%
Simplified89.8%
Final simplification84.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e-84)
(/ b (* a -1.5))
(if (<= b 2.25e-100)
(/ (- (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 <= -4.8e-84) {
tmp = b / (a * -1.5);
} else if (b <= 2.25e-100) {
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 <= (-4.8d-84)) then
tmp = b / (a * (-1.5d0))
else if (b <= 2.25d-100) 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 <= -4.8e-84) {
tmp = b / (a * -1.5);
} else if (b <= 2.25e-100) {
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 <= -4.8e-84: tmp = b / (a * -1.5) elif b <= 2.25e-100: 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 <= -4.8e-84) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 2.25e-100) 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 <= -4.8e-84) tmp = b / (a * -1.5); elseif (b <= 2.25e-100) 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, -4.8e-84], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.25e-100], 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 -4.8 \cdot 10^{-84}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.25 \cdot 10^{-100}:\\
\;\;\;\;\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 < -4.80000000000000035e-84Initial program 67.9%
Taylor expanded in b around -inf 86.8%
*-commutative86.8%
Simplified86.8%
*-commutative86.8%
add-exp-log36.2%
*-commutative36.2%
associate-*l/36.2%
associate-/l*36.2%
Applied egg-rr36.2%
rem-exp-log86.8%
div-inv86.9%
metadata-eval86.9%
Applied egg-rr86.9%
if -4.80000000000000035e-84 < b < 2.25e-100Initial program 77.2%
Taylor expanded in b around 0 75.4%
associate-*r*75.7%
*-commutative75.7%
*-commutative75.7%
Simplified75.7%
+-commutative75.7%
unsub-neg75.7%
Applied egg-rr75.7%
if 2.25e-100 < b Initial program 14.7%
Taylor expanded in b around inf 89.8%
associate-*r/89.8%
Simplified89.8%
Final simplification84.8%
(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 72.7%
Taylor expanded in b around -inf 63.0%
if -4.999999999999985e-310 < b Initial program 27.8%
Taylor expanded in b around inf 71.2%
associate-*r/71.2%
Simplified71.2%
Final simplification67.3%
(FPCore (a b c) :precision binary64 (if (<= b 3.6e-52) (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.6e-52) {
tmp = -0.6666666666666666 * (b / 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.6d-52) then
tmp = (-0.6666666666666666d0) * (b / 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.6e-52) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.6e-52: tmp = -0.6666666666666666 * (b / a) else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.6e-52) tmp = Float64(-0.6666666666666666 * Float64(b / 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.6e-52) tmp = -0.6666666666666666 * (b / a); else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.6e-52], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.6 \cdot 10^{-52}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.59999999999999988e-52Initial program 70.7%
Taylor expanded in b around -inf 48.5%
*-commutative48.5%
Simplified48.5%
if 3.59999999999999988e-52 < b Initial program 12.5%
Taylor expanded in b around inf 93.0%
associate-*r/93.0%
associate-/l*91.9%
Simplified91.9%
frac-2neg91.9%
metadata-eval91.9%
div-inv91.9%
distribute-neg-frac91.9%
add-sqr-sqrt0.0%
sqrt-unprod22.3%
sqr-neg22.3%
sqrt-unprod21.9%
add-sqr-sqrt21.9%
clear-num21.8%
Applied egg-rr21.8%
Final simplification38.8%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / 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 = (-0.6666666666666666d0) * (b / 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 = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-0.6666666666666666 * Float64(b / 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 = -0.6666666666666666 * (b / a); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 * N[(b / 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}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.7%
Taylor expanded in b around -inf 62.8%
*-commutative62.8%
Simplified62.8%
if -4.999999999999985e-310 < b Initial program 27.8%
Taylor expanded in b around inf 71.2%
associate-*r/71.2%
associate-/l*70.4%
Simplified70.4%
Final simplification66.7%
(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 72.7%
Taylor expanded in b around -inf 62.8%
*-commutative62.8%
Simplified62.8%
*-commutative62.8%
add-exp-log26.5%
*-commutative26.5%
associate-*l/26.5%
associate-/l*26.5%
Applied egg-rr26.5%
rem-exp-log62.8%
div-inv62.9%
metadata-eval62.9%
Applied egg-rr62.9%
if -4.999999999999985e-310 < b Initial program 27.8%
Taylor expanded in b around inf 71.2%
associate-*r/71.2%
associate-/l*70.4%
Simplified70.4%
Final simplification66.8%
(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 72.7%
Taylor expanded in b around -inf 62.8%
*-commutative62.8%
Simplified62.8%
*-commutative62.8%
add-exp-log26.5%
*-commutative26.5%
associate-*l/26.5%
associate-/l*26.5%
Applied egg-rr26.5%
rem-exp-log62.8%
div-inv62.9%
metadata-eval62.9%
Applied egg-rr62.9%
if -4.999999999999985e-310 < b Initial program 27.8%
Taylor expanded in b around inf 71.2%
associate-*r/71.2%
Simplified71.2%
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.6%
Taylor expanded in b around inf 37.9%
associate-*r/37.9%
associate-/l*37.4%
Simplified37.4%
frac-2neg37.4%
metadata-eval37.4%
div-inv37.4%
distribute-neg-frac37.4%
add-sqr-sqrt1.1%
sqrt-unprod9.3%
sqr-neg9.3%
sqrt-unprod8.1%
add-sqr-sqrt10.0%
clear-num10.0%
Applied egg-rr10.0%
Final simplification10.0%
herbie shell --seed 2024014
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))