
(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 10 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%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (B x) :precision binary64 (if (or (<= x -0.03) (not (<= x 5.8e-6))) (- (/ 1.0 B) (/ x (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -0.03) || !(x <= 5.8e-6)) {
tmp = (1.0 / B) - (x / tan(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.03d0)) .or. (.not. (x <= 5.8d-6))) then
tmp = (1.0d0 / b) - (x / tan(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.03) || !(x <= 5.8e-6)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.03) or not (x <= 5.8e-6): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.03) || !(x <= 5.8e-6)) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -0.03) || ~((x <= 5.8e-6))) tmp = (1.0 / B) - (x / tan(B)); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.03], N[Not[LessEqual[x, 5.8e-6]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.03 \lor \neg \left(x \leq 5.8 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -0.029999999999999999 or 5.8000000000000004e-6 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 98.0%
if -0.029999999999999999 < x < 5.8000000000000004e-6Initial program 99.9%
distribute-lft-neg-in99.9%
+-commutative99.9%
cancel-sign-sub-inv99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around 0 98.8%
Final simplification98.4%
(FPCore (B x) :precision binary64 (if (or (<= x -540000000.0) (not (<= x 9.0))) (/ x (- (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -540000000.0) || !(x <= 9.0)) {
tmp = 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 <= (-540000000.0d0)) .or. (.not. (x <= 9.0d0))) then
tmp = 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 <= -540000000.0) || !(x <= 9.0)) {
tmp = x / -Math.tan(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -540000000.0) or not (x <= 9.0): tmp = x / -math.tan(B) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -540000000.0) || !(x <= 9.0)) tmp = Float64(x / Float64(-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 <= -540000000.0) || ~((x <= 9.0))) tmp = x / -tan(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -540000000.0], N[Not[LessEqual[x, 9.0]], $MachinePrecision]], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -540000000 \lor \neg \left(x \leq 9\right):\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -5.4e8 or 9 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around inf 97.6%
mul-1-neg97.6%
associate-*l/97.7%
*-commutative97.7%
distribute-rgt-neg-in97.7%
distribute-neg-frac97.7%
Simplified97.7%
*-commutative97.7%
distribute-frac-neg97.7%
distribute-lft-neg-out97.7%
associate-/r/97.6%
tan-quot97.8%
frac-2neg97.8%
distribute-neg-frac97.8%
remove-double-neg97.8%
Applied egg-rr97.8%
if -5.4e8 < x < 9Initial program 99.9%
distribute-lft-neg-in99.9%
+-commutative99.9%
cancel-sign-sub-inv99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
Taylor expanded in x around 0 99.9%
+-commutative99.9%
mul-1-neg99.9%
sub-neg99.9%
*-inverses99.9%
*-rgt-identity99.9%
/-rgt-identity99.9%
*-inverses99.9%
times-frac99.9%
*-commutative99.9%
*-lft-identity99.9%
div-sub99.9%
Simplified99.9%
Taylor expanded in B around 0 98.8%
Final simplification98.3%
(FPCore (B x) :precision binary64 (if (or (<= x -1.25) (not (<= x 1.0))) (/ x (- (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.25) || !(x <= 1.0)) {
tmp = x / -tan(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 <= (-1.25d0)) .or. (.not. (x <= 1.0d0))) then
tmp = x / -tan(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 <= -1.25) || !(x <= 1.0)) {
tmp = x / -Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.25) or not (x <= 1.0): tmp = x / -math.tan(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.25) || !(x <= 1.0)) tmp = Float64(x / Float64(-tan(B))); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.25) || ~((x <= 1.0))) tmp = x / -tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.25], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.25 or 1 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around inf 96.4%
mul-1-neg96.4%
associate-*l/96.4%
*-commutative96.4%
distribute-rgt-neg-in96.4%
distribute-neg-frac96.4%
Simplified96.4%
*-commutative96.4%
distribute-frac-neg96.4%
distribute-lft-neg-out96.4%
associate-/r/96.3%
tan-quot96.5%
frac-2neg96.5%
distribute-neg-frac96.5%
remove-double-neg96.5%
Applied egg-rr96.5%
if -1.25 < x < 1Initial program 99.9%
distribute-lft-neg-in99.9%
+-commutative99.9%
cancel-sign-sub-inv99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around 0 98.8%
Final simplification97.6%
(FPCore (B x) :precision binary64 (if (or (<= B -0.038) (not (<= B 240000.0))) (/ 1.0 (sin B)) (+ (* B 0.16666666666666666) (/ (- 1.0 x) B))))
double code(double B, double x) {
double tmp;
if ((B <= -0.038) || !(B <= 240000.0)) {
tmp = 1.0 / sin(B);
} else {
tmp = (B * 0.16666666666666666) + ((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.038d0)) .or. (.not. (b <= 240000.0d0))) then
tmp = 1.0d0 / sin(b)
else
tmp = (b * 0.16666666666666666d0) + ((1.0d0 - x) / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -0.038) || !(B <= 240000.0)) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (B * 0.16666666666666666) + ((1.0 - x) / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -0.038) or not (B <= 240000.0): tmp = 1.0 / math.sin(B) else: tmp = (B * 0.16666666666666666) + ((1.0 - x) / B) return tmp
function code(B, x) tmp = 0.0 if ((B <= -0.038) || !(B <= 240000.0)) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(B * 0.16666666666666666) + Float64(Float64(1.0 - x) / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -0.038) || ~((B <= 240000.0))) tmp = 1.0 / sin(B); else tmp = (B * 0.16666666666666666) + ((1.0 - x) / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -0.038], N[Not[LessEqual[B, 240000.0]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(B * 0.16666666666666666), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.038 \lor \neg \left(B \leq 240000\right):\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;B \cdot 0.16666666666666666 + \frac{1 - x}{B}\\
\end{array}
\end{array}
if B < -0.0379999999999999991 or 2.4e5 < B Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 46.0%
if -0.0379999999999999991 < B < 2.4e5Initial program 99.9%
distribute-lft-neg-in99.9%
+-commutative99.9%
cancel-sign-sub-inv99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
add-cbrt-cube46.3%
pow346.3%
inv-pow46.3%
pow-pow46.3%
metadata-eval46.3%
Applied egg-rr46.3%
Taylor expanded in B around 0 44.4%
Taylor expanded in B around 0 98.1%
associate--l+98.1%
*-commutative98.1%
div-sub98.1%
Simplified98.1%
Final simplification72.9%
(FPCore (B x) :precision binary64 (if (or (<= x -9.4e-11) (not (<= x 9.2))) (/ (- x) B) (/ (+ 1.0 x) B)))
double code(double B, double x) {
double tmp;
if ((x <= -9.4e-11) || !(x <= 9.2)) {
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 <= (-9.4d-11)) .or. (.not. (x <= 9.2d0))) 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 <= -9.4e-11) || !(x <= 9.2)) {
tmp = -x / B;
} else {
tmp = (1.0 + x) / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -9.4e-11) or not (x <= 9.2): tmp = -x / B else: tmp = (1.0 + x) / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -9.4e-11) || !(x <= 9.2)) 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 <= -9.4e-11) || ~((x <= 9.2))) tmp = -x / B; else tmp = (1.0 + x) / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -9.4e-11], N[Not[LessEqual[x, 9.2]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(N[(1.0 + x), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.4 \cdot 10^{-11} \lor \neg \left(x \leq 9.2\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + x}{B}\\
\end{array}
\end{array}
if x < -9.39999999999999985e-11 or 9.1999999999999993 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 49.9%
Taylor expanded in x around inf 48.3%
neg-mul-148.3%
distribute-neg-frac48.3%
Simplified48.3%
if -9.39999999999999985e-11 < x < 9.1999999999999993Initial program 99.9%
distribute-lft-neg-in99.9%
+-commutative99.9%
cancel-sign-sub-inv99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in B around 0 54.8%
expm1-log1p-u24.0%
expm1-udef23.8%
sub-neg23.8%
+-commutative23.8%
add-sqr-sqrt11.2%
sqrt-unprod23.8%
sqr-neg23.8%
sqrt-unprod12.6%
add-sqr-sqrt23.8%
Applied egg-rr23.8%
expm1-def24.0%
expm1-log1p54.8%
Simplified54.8%
Final simplification51.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%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
add-cbrt-cube72.1%
pow372.1%
inv-pow72.1%
pow-pow72.1%
metadata-eval72.1%
Applied egg-rr72.1%
Taylor expanded in B around 0 45.2%
Taylor expanded in B around 0 52.2%
associate--l+52.2%
*-commutative52.2%
div-sub52.2%
Simplified52.2%
Final simplification52.2%
(FPCore (B x) :precision binary64 (if (or (<= x -9.4e-11) (not (<= x 9.2))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -9.4e-11) || !(x <= 9.2)) {
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 <= (-9.4d-11)) .or. (.not. (x <= 9.2d0))) 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 <= -9.4e-11) || !(x <= 9.2)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -9.4e-11) or not (x <= 9.2): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -9.4e-11) || !(x <= 9.2)) 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 <= -9.4e-11) || ~((x <= 9.2))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -9.4e-11], N[Not[LessEqual[x, 9.2]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.4 \cdot 10^{-11} \lor \neg \left(x \leq 9.2\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -9.39999999999999985e-11 or 9.1999999999999993 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 49.9%
Taylor expanded in x around inf 48.3%
neg-mul-148.3%
distribute-neg-frac48.3%
Simplified48.3%
if -9.39999999999999985e-11 < x < 9.1999999999999993Initial program 99.9%
distribute-lft-neg-in99.9%
+-commutative99.9%
cancel-sign-sub-inv99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in B around 0 54.8%
Taylor expanded in x around 0 54.8%
Final simplification51.3%
(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%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in B around 0 52.1%
Final simplification52.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%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in B around 0 52.1%
Taylor expanded in x around 0 27.0%
Final simplification27.0%
herbie shell --seed 2023271
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))