
(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 14 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 -4e+17) (not (<= x 14500000.0))) (/ (- (cos B)) (/ (sin B) x)) (+ (/ 1.0 (sin B)) (* x (/ -1.0 B)))))
double code(double B, double x) {
double tmp;
if ((x <= -4e+17) || !(x <= 14500000.0)) {
tmp = -cos(B) / (sin(B) / x);
} else {
tmp = (1.0 / sin(B)) + (x * (-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 <= (-4d+17)) .or. (.not. (x <= 14500000.0d0))) then
tmp = -cos(b) / (sin(b) / x)
else
tmp = (1.0d0 / sin(b)) + (x * ((-1.0d0) / b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -4e+17) || !(x <= 14500000.0)) {
tmp = -Math.cos(B) / (Math.sin(B) / x);
} else {
tmp = (1.0 / Math.sin(B)) + (x * (-1.0 / B));
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -4e+17) or not (x <= 14500000.0): tmp = -math.cos(B) / (math.sin(B) / x) else: tmp = (1.0 / math.sin(B)) + (x * (-1.0 / B)) return tmp
function code(B, x) tmp = 0.0 if ((x <= -4e+17) || !(x <= 14500000.0)) tmp = Float64(Float64(-cos(B)) / Float64(sin(B) / x)); else tmp = Float64(Float64(1.0 / sin(B)) + Float64(x * Float64(-1.0 / B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -4e+17) || ~((x <= 14500000.0))) tmp = -cos(B) / (sin(B) / x); else tmp = (1.0 / sin(B)) + (x * (-1.0 / B)); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -4e+17], N[Not[LessEqual[x, 14500000.0]], $MachinePrecision]], N[((-N[Cos[B], $MachinePrecision]) / N[(N[Sin[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[(x * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+17} \lor \neg \left(x \leq 14500000\right):\\
\;\;\;\;\frac{-\cos B}{\frac{\sin B}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} + x \cdot \frac{-1}{B}\\
\end{array}
\end{array}
if x < -4e17 or 1.45e7 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.7%
tan-quot99.8%
clear-num99.7%
div-inv99.7%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
associate-/l*99.6%
Simplified99.6%
if -4e17 < x < 1.45e7Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 98.0%
Final simplification98.7%
(FPCore (B x) :precision binary64 (if (or (<= x -4e+17) (not (<= x 34000.0))) (/ (* x (- (cos B))) (sin B)) (+ (/ 1.0 (sin B)) (* x (/ -1.0 B)))))
double code(double B, double x) {
double tmp;
if ((x <= -4e+17) || !(x <= 34000.0)) {
tmp = (x * -cos(B)) / sin(B);
} else {
tmp = (1.0 / sin(B)) + (x * (-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 <= (-4d+17)) .or. (.not. (x <= 34000.0d0))) then
tmp = (x * -cos(b)) / sin(b)
else
tmp = (1.0d0 / sin(b)) + (x * ((-1.0d0) / b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -4e+17) || !(x <= 34000.0)) {
tmp = (x * -Math.cos(B)) / Math.sin(B);
} else {
tmp = (1.0 / Math.sin(B)) + (x * (-1.0 / B));
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -4e+17) or not (x <= 34000.0): tmp = (x * -math.cos(B)) / math.sin(B) else: tmp = (1.0 / math.sin(B)) + (x * (-1.0 / B)) return tmp
function code(B, x) tmp = 0.0 if ((x <= -4e+17) || !(x <= 34000.0)) tmp = Float64(Float64(x * Float64(-cos(B))) / sin(B)); else tmp = Float64(Float64(1.0 / sin(B)) + Float64(x * Float64(-1.0 / B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -4e+17) || ~((x <= 34000.0))) tmp = (x * -cos(B)) / sin(B); else tmp = (1.0 / sin(B)) + (x * (-1.0 / B)); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -4e+17], N[Not[LessEqual[x, 34000.0]], $MachinePrecision]], N[(N[(x * (-N[Cos[B], $MachinePrecision])), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[(x * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+17} \lor \neg \left(x \leq 34000\right):\\
\;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} + x \cdot \frac{-1}{B}\\
\end{array}
\end{array}
if x < -4e17 or 34000 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.7%
tan-quot99.8%
clear-num99.7%
div-inv99.7%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 99.7%
associate-*r/99.7%
*-commutative99.7%
associate-*r*99.7%
neg-mul-199.7%
Simplified99.7%
if -4e17 < x < 34000Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 98.0%
Final simplification98.7%
(FPCore (B x) :precision binary64 (if (or (<= x -1.6e+18) (not (<= x 1.3e+43))) (- (+ (/ 1.0 B) (* B 0.16666666666666666)) (/ x (tan B))) (+ (/ 1.0 (sin B)) (* x (/ -1.0 B)))))
double code(double B, double x) {
double tmp;
if ((x <= -1.6e+18) || !(x <= 1.3e+43)) {
tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / tan(B));
} else {
tmp = (1.0 / sin(B)) + (x * (-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 <= (-1.6d+18)) .or. (.not. (x <= 1.3d+43))) then
tmp = ((1.0d0 / b) + (b * 0.16666666666666666d0)) - (x / tan(b))
else
tmp = (1.0d0 / sin(b)) + (x * ((-1.0d0) / b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -1.6e+18) || !(x <= 1.3e+43)) {
tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / Math.tan(B));
} else {
tmp = (1.0 / Math.sin(B)) + (x * (-1.0 / B));
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.6e+18) or not (x <= 1.3e+43): tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / math.tan(B)) else: tmp = (1.0 / math.sin(B)) + (x * (-1.0 / B)) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.6e+18) || !(x <= 1.3e+43)) tmp = Float64(Float64(Float64(1.0 / B) + Float64(B * 0.16666666666666666)) - Float64(x / tan(B))); else tmp = Float64(Float64(1.0 / sin(B)) + Float64(x * Float64(-1.0 / B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.6e+18) || ~((x <= 1.3e+43))) tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / tan(B)); else tmp = (1.0 / sin(B)) + (x * (-1.0 / B)); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.6e+18], N[Not[LessEqual[x, 1.3e+43]], $MachinePrecision]], N[(N[(N[(1.0 / B), $MachinePrecision] + N[(B * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[(x * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+18} \lor \neg \left(x \leq 1.3 \cdot 10^{+43}\right):\\
\;\;\;\;\left(\frac{1}{B} + B \cdot 0.16666666666666666\right) - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} + x \cdot \frac{-1}{B}\\
\end{array}
\end{array}
if x < -1.6e18 or 1.3000000000000001e43 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 80.8%
if -1.6e18 < x < 1.3000000000000001e43Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 95.5%
Final simplification89.2%
(FPCore (B x) :precision binary64 (if (or (<= B -0.068) (not (<= B 0.05))) (/ (+ 1.0 x) (sin B)) (+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B))))
double code(double B, double x) {
double tmp;
if ((B <= -0.068) || !(B <= 0.05)) {
tmp = (1.0 + x) / sin(B);
} else {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((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 <= (-0.068d0)) .or. (.not. (b <= 0.05d0))) then
tmp = (1.0d0 + x) / sin(b)
else
tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -0.068) || !(B <= 0.05)) {
tmp = (1.0 + x) / Math.sin(B);
} else {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -0.068) or not (B <= 0.05): tmp = (1.0 + x) / math.sin(B) else: tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B) return tmp
function code(B, x) tmp = 0.0 if ((B <= -0.068) || !(B <= 0.05)) tmp = Float64(Float64(1.0 + x) / sin(B)); else tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -0.068) || ~((B <= 0.05))) tmp = (1.0 + x) / sin(B); else tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -0.068], N[Not[LessEqual[B, 0.05]], $MachinePrecision]], N[(N[(1.0 + x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.068 \lor \neg \left(B \leq 0.05\right):\\
\;\;\;\;\frac{1 + x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}\\
\end{array}
\end{array}
if B < -0.068000000000000005 or 0.050000000000000003 < B Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in B around 0 54.0%
+-commutative54.0%
un-div-inv54.0%
frac-add54.0%
*-un-lft-identity54.0%
add-sqr-sqrt25.2%
sqrt-unprod54.4%
sqr-neg54.4%
sqrt-unprod29.2%
add-sqr-sqrt54.5%
Applied egg-rr54.5%
Taylor expanded in B around 0 56.2%
Taylor expanded in B around inf 57.7%
if -0.068000000000000005 < B < 0.050000000000000003Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in B around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
sub-neg100.0%
associate--l+100.0%
*-commutative100.0%
*-commutative100.0%
div-sub100.0%
Simplified100.0%
Final simplification78.5%
(FPCore (B x)
:precision binary64
(if (<= B -0.059)
(/ 1.0 (sin B))
(if (<= B 0.175)
(+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B))
(/ B (* B (sin B))))))
double code(double B, double x) {
double tmp;
if (B <= -0.059) {
tmp = 1.0 / sin(B);
} else if (B <= 0.175) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
} else {
tmp = B / (B * sin(B));
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= (-0.059d0)) then
tmp = 1.0d0 / sin(b)
else if (b <= 0.175d0) then
tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
else
tmp = b / (b * sin(b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= -0.059) {
tmp = 1.0 / Math.sin(B);
} else if (B <= 0.175) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
} else {
tmp = B / (B * Math.sin(B));
}
return tmp;
}
def code(B, x): tmp = 0 if B <= -0.059: tmp = 1.0 / math.sin(B) elif B <= 0.175: tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B) else: tmp = B / (B * math.sin(B)) return tmp
function code(B, x) tmp = 0.0 if (B <= -0.059) tmp = Float64(1.0 / sin(B)); elseif (B <= 0.175) tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B)); else tmp = Float64(B / Float64(B * sin(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= -0.059) tmp = 1.0 / sin(B); elseif (B <= 0.175) tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B); else tmp = B / (B * sin(B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, -0.059], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 0.175], N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[(B / N[(B * N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.059:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{elif}\;B \leq 0.175:\\
\;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{B}{B \cdot \sin B}\\
\end{array}
\end{array}
if B < -0.058999999999999997Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in x around 0 56.7%
if -0.058999999999999997 < B < 0.17499999999999999Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in B around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
sub-neg100.0%
associate--l+100.0%
*-commutative100.0%
*-commutative100.0%
div-sub100.0%
Simplified100.0%
if 0.17499999999999999 < B Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in B around 0 49.7%
+-commutative49.7%
un-div-inv49.7%
frac-add49.7%
*-un-lft-identity49.7%
add-sqr-sqrt24.0%
sqrt-unprod50.7%
sqr-neg50.7%
sqrt-unprod26.5%
add-sqr-sqrt50.4%
Applied egg-rr50.4%
Taylor expanded in B around inf 49.7%
Final simplification76.6%
(FPCore (B x) :precision binary64 (/ (+ (/ 1.0 x) -1.0) (/ (sin B) x)))
double code(double B, double x) {
return ((1.0 / x) + -1.0) / (sin(B) / x);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 / x) + (-1.0d0)) / (sin(b) / x)
end function
public static double code(double B, double x) {
return ((1.0 / x) + -1.0) / (Math.sin(B) / x);
}
def code(B, x): return ((1.0 / x) + -1.0) / (math.sin(B) / x)
function code(B, x) return Float64(Float64(Float64(1.0 / x) + -1.0) / Float64(sin(B) / x)) end
function tmp = code(B, x) tmp = ((1.0 / x) + -1.0) / (sin(B) / x); end
code[B_, x_] := N[(N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x} + -1}{\frac{\sin B}{x}}
\end{array}
Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.8%
tan-quot99.8%
clear-num99.8%
div-inv99.8%
associate-/r*99.7%
Applied egg-rr99.7%
frac-sub99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Taylor expanded in B around 0 77.6%
Final simplification77.6%
(FPCore (B x) :precision binary64 (if (or (<= B -0.034) (not (<= B 0.0255))) (/ 1.0 (sin B)) (+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B))))
double code(double B, double x) {
double tmp;
if ((B <= -0.034) || !(B <= 0.0255)) {
tmp = 1.0 / sin(B);
} else {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((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 <= (-0.034d0)) .or. (.not. (b <= 0.0255d0))) then
tmp = 1.0d0 / sin(b)
else
tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -0.034) || !(B <= 0.0255)) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -0.034) or not (B <= 0.0255): tmp = 1.0 / math.sin(B) else: tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B) return tmp
function code(B, x) tmp = 0.0 if ((B <= -0.034) || !(B <= 0.0255)) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -0.034) || ~((B <= 0.0255))) tmp = 1.0 / sin(B); else tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -0.034], N[Not[LessEqual[B, 0.0255]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.034 \lor \neg \left(B \leq 0.0255\right):\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}\\
\end{array}
\end{array}
if B < -0.034000000000000002 or 0.0254999999999999984 < B Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in x around 0 53.9%
if -0.034000000000000002 < B < 0.0254999999999999984Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in B around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
sub-neg100.0%
associate--l+100.0%
*-commutative100.0%
*-commutative100.0%
div-sub100.0%
Simplified100.0%
Final simplification76.6%
(FPCore (B x) :precision binary64 (+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B)))
double code(double B, double x) {
return (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
end function
public static double code(double B, double x) {
return (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
}
def code(B, x): return (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B)
function code(B, x) return Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B)) end
function tmp = code(B, x) tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B); end
code[B_, x_] := N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 51.3%
+-commutative51.3%
mul-1-neg51.3%
sub-neg51.3%
associate--l+51.3%
*-commutative51.3%
*-commutative51.3%
div-sub51.3%
Simplified51.3%
Final simplification51.3%
(FPCore (B x) :precision binary64 (if (or (<= x -0.5) (not (<= x 15.5))) (/ (- x) B) (/ (+ 1.0 x) B)))
double code(double B, double x) {
double tmp;
if ((x <= -0.5) || !(x <= 15.5)) {
tmp = -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 ((x <= (-0.5d0)) .or. (.not. (x <= 15.5d0))) then
tmp = -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 ((x <= -0.5) || !(x <= 15.5)) {
tmp = -x / B;
} else {
tmp = (1.0 + x) / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.5) or not (x <= 15.5): tmp = -x / B else: tmp = (1.0 + x) / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.5) || !(x <= 15.5)) tmp = Float64(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 ((x <= -0.5) || ~((x <= 15.5))) tmp = -x / B; else tmp = (1.0 + x) / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.5], N[Not[LessEqual[x, 15.5]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(N[(1.0 + x), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.5 \lor \neg \left(x \leq 15.5\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + x}{B}\\
\end{array}
\end{array}
if x < -0.5 or 15.5 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 51.1%
Taylor expanded in B around 0 51.5%
Taylor expanded in x around inf 50.2%
associate-*r/50.2%
neg-mul-150.2%
Simplified50.2%
if -0.5 < x < 15.5Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in B around 0 98.6%
+-commutative98.6%
un-div-inv98.6%
frac-add75.4%
*-un-lft-identity75.4%
add-sqr-sqrt40.2%
sqrt-unprod75.4%
sqr-neg75.4%
sqrt-unprod35.2%
add-sqr-sqrt74.4%
Applied egg-rr74.4%
Taylor expanded in B around 0 48.6%
+-commutative48.6%
Simplified48.6%
Final simplification49.3%
(FPCore (B x) :precision binary64 (+ (* B 0.16666666666666666) (/ (- 1.0 x) B)))
double code(double B, double x) {
return (B * 0.16666666666666666) + ((1.0 - x) / B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (b * 0.16666666666666666d0) + ((1.0d0 - x) / b)
end function
public static double code(double B, double x) {
return (B * 0.16666666666666666) + ((1.0 - x) / B);
}
def code(B, x): return (B * 0.16666666666666666) + ((1.0 - x) / B)
function code(B, x) return Float64(Float64(B * 0.16666666666666666) + Float64(Float64(1.0 - x) / B)) end
function tmp = code(B, x) tmp = (B * 0.16666666666666666) + ((1.0 - x) / B); end
code[B_, x_] := N[(N[(B * 0.16666666666666666), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
B \cdot 0.16666666666666666 + \frac{1 - x}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 76.3%
Taylor expanded in B around 0 51.1%
*-commutative51.1%
fma-def51.1%
+-commutative51.1%
neg-mul-151.1%
unsub-neg51.1%
Simplified51.1%
fma-udef51.1%
*-commutative51.1%
sub-neg51.1%
mul-1-neg51.1%
+-commutative51.1%
+-commutative51.1%
+-commutative51.1%
mul-1-neg51.1%
sub-neg51.1%
sub-div51.1%
*-commutative51.1%
Applied egg-rr51.1%
Final simplification51.1%
(FPCore (B x) :precision binary64 (/ (- 1.0 x) B))
double code(double B, double x) {
return (1.0 - x) / B;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - x) / b
end function
public static double code(double B, double x) {
return (1.0 - x) / B;
}
def code(B, x): return (1.0 - x) / B
function code(B, x) return Float64(Float64(1.0 - x) / B) end
function tmp = code(B, x) tmp = (1.0 - x) / B; end
code[B_, x_] := N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 50.7%
mul-1-neg50.7%
sub-neg50.7%
Simplified50.7%
Final simplification50.7%
(FPCore (B x) :precision binary64 (/ (- x) B))
double code(double B, double x) {
return -x / B;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -x / b
end function
public static double code(double B, double x) {
return -x / B;
}
def code(B, x): return -x / B
function code(B, x) return Float64(Float64(-x) / B) end
function tmp = code(B, x) tmp = -x / B; end
code[B_, x_] := N[((-x) / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{-x}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 76.3%
Taylor expanded in B around 0 51.1%
Taylor expanded in x around inf 25.4%
associate-*r/25.4%
neg-mul-125.4%
Simplified25.4%
Final simplification25.4%
(FPCore (B x) :precision binary64 (* B 0.16666666666666666))
double code(double B, double x) {
return B * 0.16666666666666666;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = b * 0.16666666666666666d0
end function
public static double code(double B, double x) {
return B * 0.16666666666666666;
}
def code(B, x): return B * 0.16666666666666666
function code(B, x) return Float64(B * 0.16666666666666666) end
function tmp = code(B, x) tmp = B * 0.16666666666666666; end
code[B_, x_] := N[(B * 0.16666666666666666), $MachinePrecision]
\begin{array}{l}
\\
B \cdot 0.16666666666666666
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 76.3%
Taylor expanded in B around 0 51.1%
Taylor expanded in B around inf 3.5%
*-commutative3.5%
Simplified3.5%
Final simplification3.5%
herbie shell --seed 2023214
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))