
(FPCore (B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x): return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B))) end
function tmp = code(B, x) tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B)); end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x): return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B))) end
function tmp = code(B, x) tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B)); end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\end{array}
(FPCore (B x) :precision binary64 (- (/ 1.0 (sin B)) (/ x (tan B))))
double code(double B, double x) {
return (1.0 / sin(B)) - (x / tan(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / sin(b)) - (x / tan(b))
end function
public static double code(double B, double x) {
return (1.0 / Math.sin(B)) - (x / Math.tan(B));
}
def code(B, x): return (1.0 / math.sin(B)) - (x / math.tan(B))
function code(B, x) return Float64(Float64(1.0 / sin(B)) - Float64(x / tan(B))) end
function tmp = code(B, x) tmp = (1.0 / sin(B)) - (x / tan(B)); end
code[B_, x_] := N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sin B} - \frac{x}{\tan B}
\end{array}
Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (or (<= x -10.8) (not (<= x 2.65))) (- (/ 1.0 B) (/ x (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -10.8) || !(x <= 2.65)) {
tmp = (1.0 / B) - (x / tan(B));
} else {
tmp = (1.0 - x) / sin(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-10.8d0)) .or. (.not. (x <= 2.65d0))) then
tmp = (1.0d0 / b) - (x / tan(b))
else
tmp = (1.0d0 - x) / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -10.8) || !(x <= 2.65)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -10.8) or not (x <= 2.65): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -10.8) || !(x <= 2.65)) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); else tmp = Float64(Float64(1.0 - x) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -10.8) || ~((x <= 2.65))) tmp = (1.0 / B) - (x / tan(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -10.8], N[Not[LessEqual[x, 2.65]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.8 \lor \neg \left(x \leq 2.65\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -10.800000000000001 or 2.64999999999999991 < x Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 98.8%
if -10.800000000000001 < x < 2.64999999999999991Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
*-commutative99.8%
div-sub99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in B around 0 98.3%
Final simplification98.6%
(FPCore (B x) :precision binary64 (if (or (<= x -10.8) (not (<= x 3.6))) (- (/ 1.0 B) (/ x (tan B))) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -10.8) || !(x <= 3.6)) {
tmp = (1.0 / B) - (x / tan(B));
} else {
tmp = (1.0 / sin(B)) - (x / B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-10.8d0)) .or. (.not. (x <= 3.6d0))) then
tmp = (1.0d0 / b) - (x / tan(b))
else
tmp = (1.0d0 / sin(b)) - (x / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -10.8) || !(x <= 3.6)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = (1.0 / Math.sin(B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -10.8) or not (x <= 3.6): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = (1.0 / math.sin(B)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -10.8) || !(x <= 3.6)) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); else tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -10.8) || ~((x <= 3.6))) tmp = (1.0 / B) - (x / tan(B)); else tmp = (1.0 / sin(B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -10.8], N[Not[LessEqual[x, 3.6]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.8 \lor \neg \left(x \leq 3.6\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -10.800000000000001 or 3.60000000000000009 < x Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.6%
if -10.800000000000001 < x < 3.60000000000000009Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 97.7%
Final simplification98.6%
(FPCore (B x) :precision binary64 (if (or (<= x -0.185) (not (<= x 3.4e-7))) (+ (* 0.3333333333333333 (* B x)) (/ (- 1.0 x) B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -0.185) || !(x <= 3.4e-7)) {
tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B);
} else {
tmp = 1.0 / sin(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-0.185d0)) .or. (.not. (x <= 3.4d-7))) then
tmp = (0.3333333333333333d0 * (b * x)) + ((1.0d0 - x) / b)
else
tmp = 1.0d0 / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -0.185) || !(x <= 3.4e-7)) {
tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.185) or not (x <= 3.4e-7): tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.185) || !(x <= 3.4e-7)) tmp = Float64(Float64(0.3333333333333333 * Float64(B * x)) + Float64(Float64(1.0 - x) / B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -0.185) || ~((x <= 3.4e-7))) tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.185], N[Not[LessEqual[x, 3.4e-7]], $MachinePrecision]], N[(N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.185 \lor \neg \left(x \leq 3.4 \cdot 10^{-7}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(B \cdot x\right) + \frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -0.185 or 3.39999999999999974e-7 < x Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 55.3%
+-commutative55.3%
mul-1-neg55.3%
sub-neg55.3%
associate--l+55.3%
*-commutative55.3%
*-commutative55.3%
div-sub55.3%
Simplified55.3%
Taylor expanded in x around inf 55.3%
if -0.185 < x < 3.39999999999999974e-7Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 98.0%
Final simplification76.7%
(FPCore (B x) :precision binary64 (/ (- 1.0 x) (sin B)))
double code(double B, double x) {
return (1.0 - x) / sin(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - x) / sin(b)
end function
public static double code(double B, double x) {
return (1.0 - x) / Math.sin(B);
}
def code(B, x): return (1.0 - x) / math.sin(B)
function code(B, x) return Float64(Float64(1.0 - x) / sin(B)) end
function tmp = code(B, x) tmp = (1.0 - x) / sin(B); end
code[B_, x_] := N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{\sin B}
\end{array}
Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.7%
*-commutative99.7%
div-sub99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in B around 0 78.5%
Final simplification78.5%
(FPCore (B x)
:precision binary64
(if (<= B -9.5)
(- 1.0 (/ x B))
(-
(+ (/ 1.0 B) (* B (+ 0.16666666666666666 (* x 0.3333333333333333))))
(/ x B))))
double code(double B, double x) {
double tmp;
if (B <= -9.5) {
tmp = 1.0 - (x / B);
} else {
tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= (-9.5d0)) then
tmp = 1.0d0 - (x / b)
else
tmp = ((1.0d0 / b) + (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0)))) - (x / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= -9.5) {
tmp = 1.0 - (x / B);
} else {
tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= -9.5: tmp = 1.0 - (x / B) else: tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B) return tmp
function code(B, x) tmp = 0.0 if (B <= -9.5) tmp = Float64(1.0 - Float64(x / B)); else tmp = Float64(Float64(Float64(1.0 / B) + Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333)))) - Float64(x / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= -9.5) tmp = 1.0 - (x / B); else tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, -9.5], N[(1.0 - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / B), $MachinePrecision] + N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -9.5:\\
\;\;\;\;1 - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}\\
\end{array}
\end{array}
if B < -9.5Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 56.1%
add-exp-log37.4%
log-rec37.3%
Applied egg-rr37.3%
exp-neg37.4%
add-exp-log56.1%
add-sqr-sqrt37.3%
associate-/r*37.2%
metadata-eval37.2%
sqrt-div37.3%
add-exp-log37.3%
exp-neg37.3%
add-sqr-sqrt37.2%
sqrt-unprod37.3%
sqr-neg37.3%
sqrt-unprod0.0%
add-sqr-sqrt9.1%
add-exp-log9.1%
Applied egg-rr9.1%
*-inverses9.9%
Simplified9.9%
if -9.5 < B Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 71.3%
Final simplification56.7%
(FPCore (B x) :precision binary64 (if (<= B -3.1) (- 1.0 (/ x B)) (+ (/ (- 1.0 x) B) (* B (+ 0.16666666666666666 (* x 0.3333333333333333))))))
double code(double B, double x) {
double tmp;
if (B <= -3.1) {
tmp = 1.0 - (x / B);
} else {
tmp = ((1.0 - x) / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)));
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= (-3.1d0)) then
tmp = 1.0d0 - (x / b)
else
tmp = ((1.0d0 - x) / b) + (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0)))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= -3.1) {
tmp = 1.0 - (x / B);
} else {
tmp = ((1.0 - x) / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)));
}
return tmp;
}
def code(B, x): tmp = 0 if B <= -3.1: tmp = 1.0 - (x / B) else: tmp = ((1.0 - x) / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333))) return tmp
function code(B, x) tmp = 0.0 if (B <= -3.1) tmp = Float64(1.0 - Float64(x / B)); else tmp = Float64(Float64(Float64(1.0 - x) / B) + Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333)))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= -3.1) tmp = 1.0 - (x / B); else tmp = ((1.0 - x) / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333))); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, -3.1], N[(1.0 - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision] + N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -3.1:\\
\;\;\;\;1 - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\\
\end{array}
\end{array}
if B < -3.10000000000000009Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 56.1%
add-exp-log37.4%
log-rec37.3%
Applied egg-rr37.3%
exp-neg37.4%
add-exp-log56.1%
add-sqr-sqrt37.3%
associate-/r*37.2%
metadata-eval37.2%
sqrt-div37.3%
add-exp-log37.3%
exp-neg37.3%
add-sqr-sqrt37.2%
sqrt-unprod37.3%
sqr-neg37.3%
sqrt-unprod0.0%
add-sqr-sqrt9.1%
add-exp-log9.1%
Applied egg-rr9.1%
*-inverses9.9%
Simplified9.9%
if -3.10000000000000009 < B Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 71.3%
+-commutative71.3%
mul-1-neg71.3%
sub-neg71.3%
associate--l+71.3%
*-commutative71.3%
*-commutative71.3%
div-sub71.3%
Simplified71.3%
Final simplification56.7%
(FPCore (B x) :precision binary64 (if (<= B -3.1) (- 1.0 (/ x B)) (- (+ (/ 1.0 B) (* B 0.16666666666666666)) (/ x B))))
double code(double B, double x) {
double tmp;
if (B <= -3.1) {
tmp = 1.0 - (x / B);
} else {
tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= (-3.1d0)) then
tmp = 1.0d0 - (x / b)
else
tmp = ((1.0d0 / b) + (b * 0.16666666666666666d0)) - (x / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= -3.1) {
tmp = 1.0 - (x / B);
} else {
tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= -3.1: tmp = 1.0 - (x / B) else: tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if (B <= -3.1) tmp = Float64(1.0 - Float64(x / B)); else tmp = Float64(Float64(Float64(1.0 / B) + Float64(B * 0.16666666666666666)) - Float64(x / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= -3.1) tmp = 1.0 - (x / B); else tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, -3.1], N[(1.0 - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / B), $MachinePrecision] + N[(B * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -3.1:\\
\;\;\;\;1 - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{B} + B \cdot 0.16666666666666666\right) - \frac{x}{B}\\
\end{array}
\end{array}
if B < -3.10000000000000009Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 56.1%
add-exp-log37.4%
log-rec37.3%
Applied egg-rr37.3%
exp-neg37.4%
add-exp-log56.1%
add-sqr-sqrt37.3%
associate-/r*37.2%
metadata-eval37.2%
sqrt-div37.3%
add-exp-log37.3%
exp-neg37.3%
add-sqr-sqrt37.2%
sqrt-unprod37.3%
sqr-neg37.3%
sqrt-unprod0.0%
add-sqr-sqrt9.1%
add-exp-log9.1%
Applied egg-rr9.1%
*-inverses9.9%
Simplified9.9%
if -3.10000000000000009 < B Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 82.9%
Taylor expanded in B around 0 71.1%
Final simplification56.5%
(FPCore (B x) :precision binary64 (if (<= B -3.1) (- 1.0 (/ x B)) (+ (/ (- 1.0 x) B) (* B 0.16666666666666666))))
double code(double B, double x) {
double tmp;
if (B <= -3.1) {
tmp = 1.0 - (x / B);
} else {
tmp = ((1.0 - x) / B) + (B * 0.16666666666666666);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= (-3.1d0)) then
tmp = 1.0d0 - (x / b)
else
tmp = ((1.0d0 - x) / b) + (b * 0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= -3.1) {
tmp = 1.0 - (x / B);
} else {
tmp = ((1.0 - x) / B) + (B * 0.16666666666666666);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= -3.1: tmp = 1.0 - (x / B) else: tmp = ((1.0 - x) / B) + (B * 0.16666666666666666) return tmp
function code(B, x) tmp = 0.0 if (B <= -3.1) tmp = Float64(1.0 - Float64(x / B)); else tmp = Float64(Float64(Float64(1.0 - x) / B) + Float64(B * 0.16666666666666666)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= -3.1) tmp = 1.0 - (x / B); else tmp = ((1.0 - x) / B) + (B * 0.16666666666666666); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, -3.1], N[(1.0 - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision] + N[(B * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -3.1:\\
\;\;\;\;1 - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B} + B \cdot 0.16666666666666666\\
\end{array}
\end{array}
if B < -3.10000000000000009Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 56.1%
add-exp-log37.4%
log-rec37.3%
Applied egg-rr37.3%
exp-neg37.4%
add-exp-log56.1%
add-sqr-sqrt37.3%
associate-/r*37.2%
metadata-eval37.2%
sqrt-div37.3%
add-exp-log37.3%
exp-neg37.3%
add-sqr-sqrt37.2%
sqrt-unprod37.3%
sqr-neg37.3%
sqrt-unprod0.0%
add-sqr-sqrt9.1%
add-exp-log9.1%
Applied egg-rr9.1%
*-inverses9.9%
Simplified9.9%
if -3.10000000000000009 < B Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 82.9%
Taylor expanded in B around 0 71.1%
associate--l+71.1%
*-commutative71.1%
div-sub71.1%
Simplified71.1%
Final simplification56.5%
(FPCore (B x) :precision binary64 (if (or (<= x -3.8e-5) (not (<= x 1.0))) (- 1.0 (/ x B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -3.8e-5) || !(x <= 1.0)) {
tmp = 1.0 - (x / B);
} else {
tmp = 1.0 / B;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-3.8d-5)) .or. (.not. (x <= 1.0d0))) then
tmp = 1.0d0 - (x / b)
else
tmp = 1.0d0 / b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -3.8e-5) || !(x <= 1.0)) {
tmp = 1.0 - (x / B);
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -3.8e-5) or not (x <= 1.0): tmp = 1.0 - (x / B) else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -3.8e-5) || !(x <= 1.0)) tmp = Float64(1.0 - Float64(x / B)); else tmp = Float64(1.0 / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -3.8e-5) || ~((x <= 1.0))) tmp = 1.0 - (x / B); else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -3.8e-5], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(1.0 - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-5} \lor \neg \left(x \leq 1\right):\\
\;\;\;\;1 - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -3.8000000000000002e-5 or 1 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 53.5%
add-exp-log28.2%
log-rec28.2%
Applied egg-rr28.2%
exp-neg28.2%
add-exp-log53.5%
add-sqr-sqrt28.2%
associate-/r*28.2%
metadata-eval28.2%
sqrt-div28.2%
add-exp-log28.2%
exp-neg28.2%
add-sqr-sqrt28.2%
sqrt-unprod28.2%
sqr-neg28.2%
sqrt-unprod0.0%
add-sqr-sqrt27.3%
add-exp-log27.3%
Applied egg-rr27.3%
*-inverses51.1%
Simplified51.1%
if -3.8000000000000002e-5 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 56.4%
mul-1-neg56.4%
sub-neg56.4%
Simplified56.4%
Taylor expanded in x around 0 55.3%
Final simplification53.2%
(FPCore (B x) :precision binary64 (if (or (<= x -0.18) (not (<= x 1.0))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -0.18) || !(x <= 1.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-0.18d0)) .or. (.not. (x <= 1.0d0))) then
tmp = -x / b
else
tmp = 1.0d0 / b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -0.18) || !(x <= 1.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.18) or not (x <= 1.0): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.18) || !(x <= 1.0)) tmp = Float64(Float64(-x) / B); else tmp = Float64(1.0 / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -0.18) || ~((x <= 1.0))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.18], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.18 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -0.17999999999999999 or 1 < x Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 53.3%
mul-1-neg53.3%
sub-neg53.3%
Simplified53.3%
Taylor expanded in x around inf 51.0%
neg-mul-151.0%
distribute-neg-frac51.0%
Simplified51.0%
if -0.17999999999999999 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 55.6%
mul-1-neg55.6%
sub-neg55.6%
Simplified55.6%
Taylor expanded in x around 0 54.6%
Final simplification52.8%
(FPCore (B x) :precision binary64 (if (<= B -3.1) (- 1.0 (/ x B)) (/ (- 1.0 x) B)))
double code(double B, double x) {
double tmp;
if (B <= -3.1) {
tmp = 1.0 - (x / B);
} else {
tmp = (1.0 - x) / B;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= (-3.1d0)) then
tmp = 1.0d0 - (x / b)
else
tmp = (1.0d0 - x) / b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= -3.1) {
tmp = 1.0 - (x / B);
} else {
tmp = (1.0 - x) / B;
}
return tmp;
}
def code(B, x): tmp = 0 if B <= -3.1: tmp = 1.0 - (x / B) else: tmp = (1.0 - x) / B return tmp
function code(B, x) tmp = 0.0 if (B <= -3.1) tmp = Float64(1.0 - Float64(x / B)); else tmp = Float64(Float64(1.0 - x) / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= -3.1) tmp = 1.0 - (x / B); else tmp = (1.0 - x) / B; end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, -3.1], N[(1.0 - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -3.1:\\
\;\;\;\;1 - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B}\\
\end{array}
\end{array}
if B < -3.10000000000000009Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 56.1%
add-exp-log37.4%
log-rec37.3%
Applied egg-rr37.3%
exp-neg37.4%
add-exp-log56.1%
add-sqr-sqrt37.3%
associate-/r*37.2%
metadata-eval37.2%
sqrt-div37.3%
add-exp-log37.3%
exp-neg37.3%
add-sqr-sqrt37.2%
sqrt-unprod37.3%
sqr-neg37.3%
sqrt-unprod0.0%
add-sqr-sqrt9.1%
add-exp-log9.1%
Applied egg-rr9.1%
*-inverses9.9%
Simplified9.9%
if -3.10000000000000009 < B Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 70.6%
mul-1-neg70.6%
sub-neg70.6%
Simplified70.6%
Final simplification56.1%
(FPCore (B x) :precision binary64 (/ 1.0 B))
double code(double B, double x) {
return 1.0 / B;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = 1.0d0 / b
end function
public static double code(double B, double x) {
return 1.0 / B;
}
def code(B, x): return 1.0 / B
function code(B, x) return Float64(1.0 / B) end
function tmp = code(B, x) tmp = 1.0 / B; end
code[B_, x_] := N[(1.0 / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 54.4%
mul-1-neg54.4%
sub-neg54.4%
Simplified54.4%
Taylor expanded in x around 0 29.1%
Final simplification29.1%
herbie shell --seed 2023217
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))