
(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%
associate-*l/99.8%
*-lft-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 -2.9e-10) (not (<= x 0.038))) (- (/ 1.0 B) (/ x (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -2.9e-10) || !(x <= 0.038)) {
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 <= (-2.9d-10)) .or. (.not. (x <= 0.038d0))) 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 <= -2.9e-10) || !(x <= 0.038)) {
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 <= -2.9e-10) or not (x <= 0.038): 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 <= -2.9e-10) || !(x <= 0.038)) 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 <= -2.9e-10) || ~((x <= 0.038))) 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, -2.9e-10], N[Not[LessEqual[x, 0.038]], $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 -2.9 \cdot 10^{-10} \lor \neg \left(x \leq 0.038\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -2.89999999999999981e-10 or 0.0379999999999999991 < x 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%
associate-*l/99.7%
*-lft-identity99.7%
tan-neg99.7%
distribute-neg-frac299.7%
distribute-neg-frac99.7%
remove-double-neg99.7%
Simplified99.7%
Taylor expanded in B around 0 99.0%
if -2.89999999999999981e-10 < x < 0.0379999999999999991Initial program 99.8%
Taylor expanded in x around 0 97.5%
Final simplification98.2%
(FPCore (B x) :precision binary64 (if (or (<= x -2.6) (not (<= x 1.0))) (/ x (- (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -2.6) || !(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 <= (-2.6d0)) .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 <= -2.6) || !(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 <= -2.6) 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 <= -2.6) || !(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 <= -2.6) || ~((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, -2.6], 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 -2.6 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -2.60000000000000009 or 1 < x Initial program 99.6%
+-commutative99.6%
div-inv99.7%
sub-neg99.7%
clear-num99.6%
frac-sub92.9%
*-un-lft-identity92.9%
*-commutative92.9%
*-un-lft-identity92.9%
Applied egg-rr92.9%
associate-/r*99.6%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in x around inf 99.3%
associate-/r/99.3%
*-commutative99.3%
Applied egg-rr99.3%
associate-*r/99.4%
associate-*l/99.4%
*-commutative99.4%
neg-mul-199.4%
distribute-neg-frac299.4%
Simplified99.4%
if -2.60000000000000009 < x < 1Initial program 99.8%
Taylor expanded in x around 0 96.1%
Final simplification97.7%
(FPCore (B x)
:precision binary64
(if (<= B 0.34)
(/
(- (+ 1.0 (* (* B B) (+ 0.16666666666666666 (* x 0.3333333333333333)))) x)
B)
(/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 0.34) {
tmp = ((1.0 + ((B * B) * (0.16666666666666666 + (x * 0.3333333333333333)))) - 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.34d0) then
tmp = ((1.0d0 + ((b * b) * (0.16666666666666666d0 + (x * 0.3333333333333333d0)))) - 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.34) {
tmp = ((1.0 + ((B * B) * (0.16666666666666666 + (x * 0.3333333333333333)))) - x) / B;
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 0.34: tmp = ((1.0 + ((B * B) * (0.16666666666666666 + (x * 0.3333333333333333)))) - x) / B else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 0.34) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(B * B) * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333)))) - 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.34) tmp = ((1.0 + ((B * B) * (0.16666666666666666 + (x * 0.3333333333333333)))) - x) / B; else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 0.34], N[(N[(N[(1.0 + N[(N[(B * B), $MachinePrecision] * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 0.34:\\
\;\;\;\;\frac{\left(1 + \left(B \cdot B\right) \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 0.340000000000000024Initial program 99.8%
Taylor expanded in B around 0 65.5%
unpow265.5%
Applied egg-rr65.5%
if 0.340000000000000024 < B Initial program 99.5%
Taylor expanded in x around 0 58.0%
Final simplification63.6%
(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 49.4%
Taylor expanded in x around 0 49.4%
Final simplification49.4%
(FPCore (B x) :precision binary64 (if (<= x -4e+31) (/ x (- B)) (if (<= x 1.0) (/ 1.0 B) (/ -1.0 (/ B x)))))
double code(double B, double x) {
double tmp;
if (x <= -4e+31) {
tmp = x / -B;
} else if (x <= 1.0) {
tmp = 1.0 / B;
} else {
tmp = -1.0 / (B / x);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-4d+31)) then
tmp = x / -b
else if (x <= 1.0d0) then
tmp = 1.0d0 / b
else
tmp = (-1.0d0) / (b / x)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -4e+31) {
tmp = x / -B;
} else if (x <= 1.0) {
tmp = 1.0 / B;
} else {
tmp = -1.0 / (B / x);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -4e+31: tmp = x / -B elif x <= 1.0: tmp = 1.0 / B else: tmp = -1.0 / (B / x) return tmp
function code(B, x) tmp = 0.0 if (x <= -4e+31) tmp = Float64(x / Float64(-B)); elseif (x <= 1.0) tmp = Float64(1.0 / B); else tmp = Float64(-1.0 / Float64(B / x)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -4e+31) tmp = x / -B; elseif (x <= 1.0) tmp = 1.0 / B; else tmp = -1.0 / (B / x); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -4e+31], N[(x / (-B)), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 / B), $MachinePrecision], N[(-1.0 / N[(B / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+31}:\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{1}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{B}{x}}\\
\end{array}
\end{array}
if x < -3.9999999999999999e31Initial program 99.6%
Taylor expanded in B around 0 38.0%
Taylor expanded in x around inf 38.0%
associate-*r/38.0%
neg-mul-138.0%
Simplified38.0%
if -3.9999999999999999e31 < x < 1Initial program 99.8%
Taylor expanded in B around 0 55.5%
Taylor expanded in x around 0 53.7%
if 1 < x Initial program 99.6%
+-commutative99.6%
div-inv99.7%
sub-neg99.7%
clear-num99.6%
frac-sub95.7%
*-un-lft-identity95.7%
*-commutative95.7%
*-un-lft-identity95.7%
Applied egg-rr95.7%
associate-/r*99.6%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in x around inf 99.0%
Taylor expanded in B around 0 43.5%
Final simplification47.6%
(FPCore (B x) :precision binary64 (/ (- (+ 1.0 (* (* B B) (+ 0.16666666666666666 (* x 0.3333333333333333)))) x) B))
double code(double B, double x) {
return ((1.0 + ((B * B) * (0.16666666666666666 + (x * 0.3333333333333333)))) - x) / B;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 + ((b * b) * (0.16666666666666666d0 + (x * 0.3333333333333333d0)))) - x) / b
end function
public static double code(double B, double x) {
return ((1.0 + ((B * B) * (0.16666666666666666 + (x * 0.3333333333333333)))) - x) / B;
}
def code(B, x): return ((1.0 + ((B * B) * (0.16666666666666666 + (x * 0.3333333333333333)))) - x) / B
function code(B, x) return Float64(Float64(Float64(1.0 + Float64(Float64(B * B) * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333)))) - x) / B) end
function tmp = code(B, x) tmp = ((1.0 + ((B * B) * (0.16666666666666666 + (x * 0.3333333333333333)))) - x) / B; end
code[B_, x_] := N[(N[(N[(1.0 + N[(N[(B * B), $MachinePrecision] * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \left(B \cdot B\right) \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - x}{B}
\end{array}
Initial program 99.7%
Taylor expanded in B around 0 49.4%
unpow249.4%
Applied egg-rr49.4%
Final simplification49.4%
(FPCore (B x) :precision binary64 (if (or (<= x -4e+31) (not (<= x 1.0))) (/ x (- B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -4e+31) || !(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 <= (-4d+31)) .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 <= -4e+31) || !(x <= 1.0)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -4e+31) or not (x <= 1.0): tmp = x / -B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -4e+31) || !(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 <= -4e+31) || ~((x <= 1.0))) tmp = x / -B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -4e+31], 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 -4 \cdot 10^{+31} \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -3.9999999999999999e31 or 1 < x Initial program 99.6%
Taylor expanded in B around 0 41.3%
Taylor expanded in x around inf 40.9%
associate-*r/40.9%
neg-mul-140.9%
Simplified40.9%
if -3.9999999999999999e31 < x < 1Initial program 99.8%
Taylor expanded in B around 0 55.5%
Taylor expanded in x around 0 53.7%
Final simplification47.6%
(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 49.4%
Taylor expanded in x around 0 49.4%
Taylor expanded in B around 0 49.0%
neg-mul-149.0%
sub-neg49.0%
Simplified49.0%
Final simplification49.0%
(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 48.7%
(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 48.7%
Taylor expanded in x around 0 29.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%
Taylor expanded in B around 0 49.4%
Taylor expanded in x around 0 49.4%
Taylor expanded in x around inf 22.3%
*-commutative22.3%
Simplified22.3%
Taylor expanded in x around 0 3.3%
*-commutative3.3%
Simplified3.3%
herbie shell --seed 2024132
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))