
(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 (* x (cos B))) (sin B)))
double code(double B, double x) {
return (1.0 - (x * cos(B))) / sin(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - (x * cos(b))) / sin(b)
end function
public static double code(double B, double x) {
return (1.0 - (x * Math.cos(B))) / Math.sin(B);
}
def code(B, x): return (1.0 - (x * math.cos(B))) / math.sin(B)
function code(B, x) return Float64(Float64(1.0 - Float64(x * cos(B))) / sin(B)) end
function tmp = code(B, x) tmp = (1.0 - (x * cos(B))) / sin(B); end
code[B_, x_] := N[(N[(1.0 - N[(x * N[Cos[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x \cdot \cos B}{\sin B}
\end{array}
Initial program 99.6%
Taylor expanded in x around inf 87.6%
Taylor expanded in x around 0 99.7%
mul-1-neg99.7%
associate-/l*99.7%
distribute-rgt-neg-in99.7%
mul-1-neg99.7%
rgt-mult-inverse99.6%
associate-*r/87.5%
associate-/r*87.6%
distribute-lft-in87.6%
associate-/r*87.5%
+-commutative87.5%
mul-1-neg87.5%
sub-neg87.5%
div-sub87.5%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
neg-mul-199.7%
sub-neg99.7%
Simplified99.7%
(FPCore (B x) :precision binary64 (if (<= x -750.0) (/ (* x (cos B)) (- (sin B))) (if (<= x 5e+14) (- (/ 1.0 (sin B)) (/ x B)) (/ x (- (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -750.0) {
tmp = (x * cos(B)) / -sin(B);
} else if (x <= 5e+14) {
tmp = (1.0 / sin(B)) - (x / B);
} else {
tmp = x / -tan(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-750.0d0)) then
tmp = (x * cos(b)) / -sin(b)
else if (x <= 5d+14) then
tmp = (1.0d0 / sin(b)) - (x / b)
else
tmp = x / -tan(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -750.0) {
tmp = (x * Math.cos(B)) / -Math.sin(B);
} else if (x <= 5e+14) {
tmp = (1.0 / Math.sin(B)) - (x / B);
} else {
tmp = x / -Math.tan(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -750.0: tmp = (x * math.cos(B)) / -math.sin(B) elif x <= 5e+14: tmp = (1.0 / math.sin(B)) - (x / B) else: tmp = x / -math.tan(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -750.0) tmp = Float64(Float64(x * cos(B)) / Float64(-sin(B))); elseif (x <= 5e+14) tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); else tmp = Float64(x / Float64(-tan(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -750.0) tmp = (x * cos(B)) / -sin(B); elseif (x <= 5e+14) tmp = (1.0 / sin(B)) - (x / B); else tmp = x / -tan(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -750.0], N[(N[(x * N[Cos[B], $MachinePrecision]), $MachinePrecision] / (-N[Sin[B], $MachinePrecision])), $MachinePrecision], If[LessEqual[x, 5e+14], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -750:\\
\;\;\;\;\frac{x \cdot \cos B}{-\sin B}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+14}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{-\tan B}\\
\end{array}
\end{array}
if x < -750Initial program 99.4%
Taylor expanded in x around inf 97.2%
mul-1-neg97.2%
associate-/l*97.2%
distribute-lft-neg-in97.2%
Simplified97.2%
associate-*r/97.2%
frac-2neg97.2%
add-sqr-sqrt96.9%
sqrt-unprod65.8%
sqr-neg65.8%
sqrt-unprod0.0%
add-sqr-sqrt0.5%
distribute-lft-neg-out0.5%
add-sqr-sqrt0.5%
sqrt-unprod0.4%
sqr-neg0.4%
sqrt-unprod0.0%
add-sqr-sqrt97.2%
Applied egg-rr97.2%
if -750 < x < 5e14Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in B around 0 98.3%
if 5e14 < x Initial program 99.6%
Taylor expanded in x around inf 99.6%
mul-1-neg99.6%
associate-/l*99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
*-un-lft-identity99.6%
clear-num99.5%
tan-quot99.6%
Applied egg-rr99.6%
*-lft-identity99.6%
Simplified99.6%
un-div-inv99.7%
distribute-frac-neg99.7%
neg-sub099.7%
Applied egg-rr99.7%
neg-sub099.7%
distribute-frac-neg299.7%
Simplified99.7%
(FPCore (B x) :precision binary64 (if (<= x -800.0) (* x (/ (cos B) (- (sin B)))) (if (<= x 5e+14) (- (/ 1.0 (sin B)) (/ x B)) (/ x (- (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -800.0) {
tmp = x * (cos(B) / -sin(B));
} else if (x <= 5e+14) {
tmp = (1.0 / sin(B)) - (x / B);
} else {
tmp = x / -tan(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-800.0d0)) then
tmp = x * (cos(b) / -sin(b))
else if (x <= 5d+14) then
tmp = (1.0d0 / sin(b)) - (x / b)
else
tmp = x / -tan(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -800.0) {
tmp = x * (Math.cos(B) / -Math.sin(B));
} else if (x <= 5e+14) {
tmp = (1.0 / Math.sin(B)) - (x / B);
} else {
tmp = x / -Math.tan(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -800.0: tmp = x * (math.cos(B) / -math.sin(B)) elif x <= 5e+14: tmp = (1.0 / math.sin(B)) - (x / B) else: tmp = x / -math.tan(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -800.0) tmp = Float64(x * Float64(cos(B) / Float64(-sin(B)))); elseif (x <= 5e+14) tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); else tmp = Float64(x / Float64(-tan(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -800.0) tmp = x * (cos(B) / -sin(B)); elseif (x <= 5e+14) tmp = (1.0 / sin(B)) - (x / B); else tmp = x / -tan(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -800.0], N[(x * N[(N[Cos[B], $MachinePrecision] / (-N[Sin[B], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e+14], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -800:\\
\;\;\;\;x \cdot \frac{\cos B}{-\sin B}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+14}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{-\tan B}\\
\end{array}
\end{array}
if x < -800Initial program 99.4%
Taylor expanded in x around inf 97.2%
mul-1-neg97.2%
associate-/l*97.2%
distribute-lft-neg-in97.2%
Simplified97.2%
if -800 < x < 5e14Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in B around 0 98.3%
if 5e14 < x Initial program 99.6%
Taylor expanded in x around inf 99.6%
mul-1-neg99.6%
associate-/l*99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
*-un-lft-identity99.6%
clear-num99.5%
tan-quot99.6%
Applied egg-rr99.6%
*-lft-identity99.6%
Simplified99.6%
un-div-inv99.7%
distribute-frac-neg99.7%
neg-sub099.7%
Applied egg-rr99.7%
neg-sub099.7%
distribute-frac-neg299.7%
Simplified99.7%
Final simplification98.3%
(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.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
*-commutative99.6%
remove-double-neg99.6%
distribute-frac-neg299.6%
tan-neg99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
tan-neg99.7%
distribute-neg-frac299.7%
distribute-neg-frac99.7%
remove-double-neg99.7%
Simplified99.7%
(FPCore (B x) :precision binary64 (if (or (<= x -460.0) (not (<= x 5e+14))) (/ x (- (tan B))) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -460.0) || !(x <= 5e+14)) {
tmp = 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 <= (-460.0d0)) .or. (.not. (x <= 5d+14))) then
tmp = 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 <= -460.0) || !(x <= 5e+14)) {
tmp = x / -Math.tan(B);
} else {
tmp = (1.0 / Math.sin(B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -460.0) or not (x <= 5e+14): tmp = x / -math.tan(B) else: tmp = (1.0 / math.sin(B)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -460.0) || !(x <= 5e+14)) tmp = Float64(x / Float64(-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 <= -460.0) || ~((x <= 5e+14))) tmp = x / -tan(B); else tmp = (1.0 / sin(B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -460.0], N[Not[LessEqual[x, 5e+14]], $MachinePrecision]], N[(x / (-N[Tan[B], $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 -460 \lor \neg \left(x \leq 5 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -460 or 5e14 < x Initial program 99.5%
Taylor expanded in x around inf 98.2%
mul-1-neg98.2%
associate-/l*98.2%
distribute-lft-neg-in98.2%
Simplified98.2%
*-un-lft-identity98.2%
clear-num98.1%
tan-quot98.1%
Applied egg-rr98.1%
*-lft-identity98.1%
Simplified98.1%
un-div-inv98.2%
distribute-frac-neg98.2%
neg-sub098.2%
Applied egg-rr98.2%
neg-sub098.2%
distribute-frac-neg298.2%
Simplified98.2%
if -460 < x < 5e14Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in B around 0 98.3%
Final simplification98.3%
(FPCore (B x) :precision binary64 (if (or (<= x -1.46) (not (<= x 1.0))) (/ x (- (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.46) || !(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.46d0)) .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.46) || !(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.46) 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.46) || !(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.46) || ~((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.46], 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.46 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.46 or 1 < x Initial program 99.5%
Taylor expanded in x around inf 98.0%
mul-1-neg98.0%
associate-/l*98.0%
distribute-lft-neg-in98.0%
Simplified98.0%
*-un-lft-identity98.0%
clear-num97.9%
tan-quot97.9%
Applied egg-rr97.9%
*-lft-identity97.9%
Simplified97.9%
un-div-inv98.0%
distribute-frac-neg98.0%
neg-sub098.0%
Applied egg-rr98.0%
neg-sub098.0%
distribute-frac-neg298.0%
Simplified98.0%
if -1.46 < x < 1Initial program 99.8%
Taylor expanded in x around 0 97.9%
Final simplification97.9%
(FPCore (B x) :precision binary64 (if (<= B 0.000105) (/ (- 1.0 x) B) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 0.000105) {
tmp = (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 (b <= 0.000105d0) then
tmp = (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 (B <= 0.000105) {
tmp = (1.0 - x) / B;
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 0.000105: tmp = (1.0 - x) / B else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 0.000105) tmp = 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 (B <= 0.000105) tmp = (1.0 - x) / B; else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 0.000105], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 0.000105:\\
\;\;\;\;\frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 1.05e-4Initial program 99.7%
Taylor expanded in B around 0 60.1%
if 1.05e-4 < B Initial program 99.5%
Taylor expanded in x around 0 52.5%
(FPCore (B x) :precision binary64 (if (or (<= x -0.0017) (not (<= x 1.0))) (/ x (- B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -0.0017) || !(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.0017d0)) .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.0017) || !(x <= 1.0)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.0017) 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.0017) || !(x <= 1.0)) tmp = Float64(x / Float64(-B)); else tmp = Float64(1.0 / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -0.0017) || ~((x <= 1.0))) tmp = x / -B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.0017], 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.0017 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -0.00169999999999999991 or 1 < x Initial program 99.5%
Taylor expanded in B around 0 48.9%
Taylor expanded in x around inf 48.4%
mul-1-neg48.4%
Simplified48.4%
if -0.00169999999999999991 < x < 1Initial program 99.8%
Taylor expanded in B around 0 47.4%
Taylor expanded in x around 0 46.9%
Final simplification47.7%
(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.6%
Taylor expanded in B around 0 48.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.6%
Taylor expanded in B around 0 48.1%
Taylor expanded in x around 0 25.0%
herbie shell --seed 2024116
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))