
(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 12 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%
*-commutative99.7%
remove-double-neg99.7%
distribute-frac-neg299.7%
tan-neg99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
(FPCore (B x) :precision binary64 (if (or (<= x -2e+27) (not (<= x 2000000.0))) (* (cos B) (/ x (- (sin B)))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -2e+27) || !(x <= 2000000.0)) {
tmp = cos(B) * (x / -sin(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 <= (-2d+27)) .or. (.not. (x <= 2000000.0d0))) then
tmp = cos(b) * (x / -sin(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 <= -2e+27) || !(x <= 2000000.0)) {
tmp = Math.cos(B) * (x / -Math.sin(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2e+27) or not (x <= 2000000.0): tmp = math.cos(B) * (x / -math.sin(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -2e+27) || !(x <= 2000000.0)) tmp = Float64(cos(B) * Float64(x / Float64(-sin(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 <= -2e+27) || ~((x <= 2000000.0))) tmp = cos(B) * (x / -sin(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2e+27], N[Not[LessEqual[x, 2000000.0]], $MachinePrecision]], N[(N[Cos[B], $MachinePrecision] * N[(x / (-N[Sin[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 -2 \cdot 10^{+27} \lor \neg \left(x \leq 2000000\right):\\
\;\;\;\;\cos B \cdot \frac{x}{-\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -2e27 or 2e6 < x Initial program 99.4%
div-inv99.8%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 98.6%
mul-1-neg98.6%
associate-*l/98.6%
distribute-lft-neg-in98.6%
*-commutative98.6%
distribute-neg-frac298.6%
Simplified98.6%
if -2e27 < x < 2e6Initial program 99.9%
div-inv99.9%
clear-num99.9%
Applied egg-rr99.9%
Taylor expanded in B around inf 99.9%
div-sub99.9%
Simplified99.9%
Taylor expanded in B around 0 99.6%
Final simplification99.1%
(FPCore (B x) :precision binary64 (if (or (<= x -2e+27) (not (<= x 2400000.0))) (* x (/ (cos B) (- (sin B)))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -2e+27) || !(x <= 2400000.0)) {
tmp = x * (cos(B) / -sin(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 <= (-2d+27)) .or. (.not. (x <= 2400000.0d0))) then
tmp = x * (cos(b) / -sin(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 <= -2e+27) || !(x <= 2400000.0)) {
tmp = x * (Math.cos(B) / -Math.sin(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2e+27) or not (x <= 2400000.0): tmp = x * (math.cos(B) / -math.sin(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -2e+27) || !(x <= 2400000.0)) tmp = Float64(x * Float64(cos(B) / Float64(-sin(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 <= -2e+27) || ~((x <= 2400000.0))) tmp = x * (cos(B) / -sin(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2e+27], N[Not[LessEqual[x, 2400000.0]], $MachinePrecision]], N[(x * N[(N[Cos[B], $MachinePrecision] / (-N[Sin[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 -2 \cdot 10^{+27} \lor \neg \left(x \leq 2400000\right):\\
\;\;\;\;x \cdot \frac{\cos B}{-\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -2e27 or 2.4e6 < x Initial program 99.4%
Taylor expanded in x around inf 98.6%
mul-1-neg98.6%
associate-/l*98.5%
distribute-rgt-neg-in98.5%
distribute-neg-frac98.5%
Simplified98.5%
if -2e27 < x < 2.4e6Initial program 99.9%
div-inv99.9%
clear-num99.9%
Applied egg-rr99.9%
Taylor expanded in B around inf 99.9%
div-sub99.9%
Simplified99.9%
Taylor expanded in B around 0 99.6%
Final simplification99.0%
(FPCore (B x)
:precision binary64
(let* ((t_0 (- (sin B))))
(if (<= x -2e+27)
(/ (* x (cos B)) t_0)
(if (<= x 650000.0) (/ (- 1.0 x) (sin B)) (* (cos B) (/ x t_0))))))
double code(double B, double x) {
double t_0 = -sin(B);
double tmp;
if (x <= -2e+27) {
tmp = (x * cos(B)) / t_0;
} else if (x <= 650000.0) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = cos(B) * (x / t_0);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = -sin(b)
if (x <= (-2d+27)) then
tmp = (x * cos(b)) / t_0
else if (x <= 650000.0d0) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = cos(b) * (x / t_0)
end if
code = tmp
end function
public static double code(double B, double x) {
double t_0 = -Math.sin(B);
double tmp;
if (x <= -2e+27) {
tmp = (x * Math.cos(B)) / t_0;
} else if (x <= 650000.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = Math.cos(B) * (x / t_0);
}
return tmp;
}
def code(B, x): t_0 = -math.sin(B) tmp = 0 if x <= -2e+27: tmp = (x * math.cos(B)) / t_0 elif x <= 650000.0: tmp = (1.0 - x) / math.sin(B) else: tmp = math.cos(B) * (x / t_0) return tmp
function code(B, x) t_0 = Float64(-sin(B)) tmp = 0.0 if (x <= -2e+27) tmp = Float64(Float64(x * cos(B)) / t_0); elseif (x <= 650000.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(cos(B) * Float64(x / t_0)); end return tmp end
function tmp_2 = code(B, x) t_0 = -sin(B); tmp = 0.0; if (x <= -2e+27) tmp = (x * cos(B)) / t_0; elseif (x <= 650000.0) tmp = (1.0 - x) / sin(B); else tmp = cos(B) * (x / t_0); end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = (-N[Sin[B], $MachinePrecision])}, If[LessEqual[x, -2e+27], N[(N[(x * N[Cos[B], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[x, 650000.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[Cos[B], $MachinePrecision] * N[(x / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin B\\
\mathbf{if}\;x \leq -2 \cdot 10^{+27}:\\
\;\;\;\;\frac{x \cdot \cos B}{t\_0}\\
\mathbf{elif}\;x \leq 650000:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\cos B \cdot \frac{x}{t\_0}\\
\end{array}
\end{array}
if x < -2e27Initial 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.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
distribute-frac-neg299.7%
Simplified99.7%
if -2e27 < x < 6.5e5Initial program 99.9%
div-inv99.9%
clear-num99.9%
Applied egg-rr99.9%
Taylor expanded in B around inf 99.9%
div-sub99.9%
Simplified99.9%
Taylor expanded in B around 0 99.6%
if 6.5e5 < x Initial program 99.3%
div-inv99.7%
clear-num99.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 97.4%
mul-1-neg97.4%
associate-*l/97.4%
distribute-lft-neg-in97.4%
*-commutative97.4%
distribute-neg-frac297.4%
Simplified97.4%
(FPCore (B x)
:precision binary64
(if (<= B 0.195)
(+
(* B 0.16666666666666666)
(+ (/ 1.0 B) (* x (+ (* B 0.3333333333333333) (/ -1.0 B)))))
(/ (+ 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 0.195) {
tmp = (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / 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 (b <= 0.195d0) then
tmp = (b * 0.16666666666666666d0) + ((1.0d0 / b) + (x * ((b * 0.3333333333333333d0) + ((-1.0d0) / 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 (B <= 0.195) {
tmp = (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B))));
} else {
tmp = (1.0 + x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 0.195: tmp = (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B)))) else: tmp = (1.0 + x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 0.195) tmp = Float64(Float64(B * 0.16666666666666666) + Float64(Float64(1.0 / B) + Float64(x * Float64(Float64(B * 0.3333333333333333) + Float64(-1.0 / B))))); else tmp = Float64(Float64(1.0 + x) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= 0.195) tmp = (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B)))); else tmp = (1.0 + x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 0.195], N[(N[(B * 0.16666666666666666), $MachinePrecision] + N[(N[(1.0 / B), $MachinePrecision] + N[(x * N[(N[(B * 0.3333333333333333), $MachinePrecision] + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 0.195:\\
\;\;\;\;B \cdot 0.16666666666666666 + \left(\frac{1}{B} + x \cdot \left(B \cdot 0.3333333333333333 + \frac{-1}{B}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + x}{\sin B}\\
\end{array}
\end{array}
if B < 0.19500000000000001Initial program 99.7%
Taylor expanded in B around 0 68.5%
Taylor expanded in x around 0 68.4%
if 0.19500000000000001 < B Initial program 99.6%
div-inv99.7%
clear-num99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.5%
div-sub99.5%
Simplified99.5%
Taylor expanded in B around 0 45.7%
div-sub45.7%
sub-neg45.7%
distribute-frac-neg45.7%
add-sqr-sqrt21.3%
sqrt-unprod46.2%
sqr-neg46.2%
sqrt-unprod26.3%
add-sqr-sqrt49.4%
Applied egg-rr49.4%
*-rgt-identity49.4%
*-lft-identity49.4%
associate-*l/49.4%
distribute-lft-in49.4%
associate-*l/49.4%
*-lft-identity49.4%
+-commutative49.4%
Simplified49.4%
Final simplification64.0%
(FPCore (B x)
:precision binary64
(if (<= B 3.6e+16)
(+
(* B 0.16666666666666666)
(+ (/ 1.0 B) (* x (+ (* B 0.3333333333333333) (/ -1.0 B)))))
(/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 3.6e+16) {
tmp = (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / 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 <= 3.6d+16) then
tmp = (b * 0.16666666666666666d0) + ((1.0d0 / b) + (x * ((b * 0.3333333333333333d0) + ((-1.0d0) / 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 <= 3.6e+16) {
tmp = (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B))));
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 3.6e+16: tmp = (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B)))) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 3.6e+16) tmp = Float64(Float64(B * 0.16666666666666666) + Float64(Float64(1.0 / B) + Float64(x * Float64(Float64(B * 0.3333333333333333) + Float64(-1.0 / B))))); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= 3.6e+16) tmp = (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B)))); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 3.6e+16], N[(N[(B * 0.16666666666666666), $MachinePrecision] + N[(N[(1.0 / B), $MachinePrecision] + N[(x * N[(N[(B * 0.3333333333333333), $MachinePrecision] + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 3.6 \cdot 10^{+16}:\\
\;\;\;\;B \cdot 0.16666666666666666 + \left(\frac{1}{B} + x \cdot \left(B \cdot 0.3333333333333333 + \frac{-1}{B}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 3.6e16Initial program 99.7%
Taylor expanded in B around 0 67.3%
Taylor expanded in x around 0 67.2%
if 3.6e16 < B Initial program 99.6%
Taylor expanded in x around 0 44.9%
Final simplification62.4%
(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%
div-inv99.8%
clear-num99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in B around 0 73.5%
(FPCore (B x) :precision binary64 (+ (* B 0.16666666666666666) (+ (/ 1.0 B) (* x (+ (* B 0.3333333333333333) (/ -1.0 B))))))
double code(double B, double x) {
return (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B))));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (b * 0.16666666666666666d0) + ((1.0d0 / b) + (x * ((b * 0.3333333333333333d0) + ((-1.0d0) / b))))
end function
public static double code(double B, double x) {
return (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B))));
}
def code(B, x): return (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B))))
function code(B, x) return Float64(Float64(B * 0.16666666666666666) + Float64(Float64(1.0 / B) + Float64(x * Float64(Float64(B * 0.3333333333333333) + Float64(-1.0 / B))))) end
function tmp = code(B, x) tmp = (B * 0.16666666666666666) + ((1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B)))); end
code[B_, x_] := N[(N[(B * 0.16666666666666666), $MachinePrecision] + N[(N[(1.0 / B), $MachinePrecision] + N[(x * N[(N[(B * 0.3333333333333333), $MachinePrecision] + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
B \cdot 0.16666666666666666 + \left(\frac{1}{B} + x \cdot \left(B \cdot 0.3333333333333333 + \frac{-1}{B}\right)\right)
\end{array}
Initial program 99.7%
Taylor expanded in B around 0 53.9%
Taylor expanded in x around 0 53.9%
Final simplification53.9%
(FPCore (B x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ x (- B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(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 <= (-1.0d0)) .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 <= -1.0) || !(x <= 1.0)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = x / -B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.0) || !(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 <= -1.0) || ~((x <= 1.0))) tmp = x / -B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.0], 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 -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 99.5%
Taylor expanded in B around 0 48.9%
Taylor expanded in x around inf 47.2%
neg-mul-147.2%
distribute-neg-frac247.2%
Simplified47.2%
if -1 < x < 1Initial program 99.9%
Taylor expanded in B around 0 58.6%
Taylor expanded in x around 0 58.5%
Final simplification52.2%
(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%
Taylor expanded in B around 0 53.9%
Taylor expanded in x around 0 53.9%
Taylor expanded in B around 0 53.5%
Final simplification53.5%
(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%
Taylor expanded in B around 0 53.2%
(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%
Taylor expanded in B around 0 53.2%
Taylor expanded in x around 0 27.6%
herbie shell --seed 2024090
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))