
(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 15 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 (/ (- (/ (tan B) (sin B)) x) (tan B)))
double code(double B, double x) {
return ((tan(B) / sin(B)) - x) / tan(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((tan(b) / sin(b)) - x) / tan(b)
end function
public static double code(double B, double x) {
return ((Math.tan(B) / Math.sin(B)) - x) / Math.tan(B);
}
def code(B, x): return ((math.tan(B) / math.sin(B)) - x) / math.tan(B)
function code(B, x) return Float64(Float64(Float64(tan(B) / sin(B)) - x) / tan(B)) end
function tmp = code(B, x) tmp = ((tan(B) / sin(B)) - x) / tan(B); end
code[B_, x_] := N[(N[(N[(N[Tan[B], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\tan B}{\sin B} - x}{\tan B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
div-inv99.7%
frac-sub89.8%
associate-/r*99.7%
*-un-lft-identity99.7%
*-commutative99.7%
Applied egg-rr99.7%
div-sub99.7%
sub-neg99.7%
associate-/l*99.7%
Applied egg-rr99.7%
sub-neg99.7%
*-inverses99.7%
/-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (B x) :precision binary64 (if (<= x -10.2) (- (sin B) (/ x (tan B))) (if (<= x 31000000.0) (- (/ 1.0 (sin B)) (/ x B)) (/ (- x) (tan B)))))
double code(double B, double x) {
double tmp;
if (x <= -10.2) {
tmp = sin(B) - (x / tan(B));
} else if (x <= 31000000.0) {
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 <= (-10.2d0)) then
tmp = sin(b) - (x / tan(b))
else if (x <= 31000000.0d0) 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 <= -10.2) {
tmp = Math.sin(B) - (x / Math.tan(B));
} else if (x <= 31000000.0) {
tmp = (1.0 / Math.sin(B)) - (x / B);
} else {
tmp = -x / Math.tan(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -10.2: tmp = math.sin(B) - (x / math.tan(B)) elif x <= 31000000.0: 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 <= -10.2) tmp = Float64(sin(B) - Float64(x / tan(B))); elseif (x <= 31000000.0) tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); else tmp = Float64(Float64(-x) / tan(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -10.2) tmp = sin(B) - (x / tan(B)); elseif (x <= 31000000.0) tmp = (1.0 / sin(B)) - (x / B); else tmp = -x / tan(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -10.2], N[(N[Sin[B], $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 31000000.0], 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 -10.2:\\
\;\;\;\;\sin B - \frac{x}{\tan B}\\
\mathbf{elif}\;x \leq 31000000:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{\tan B}\\
\end{array}
\end{array}
if x < -10.199999999999999Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
add-exp-log47.0%
log-rec47.0%
Applied egg-rr47.0%
add-sqr-sqrt1.9%
sqrt-unprod1.9%
sqr-neg1.9%
sqrt-unprod0.0%
add-sqr-sqrt1.2%
add-exp-log2.9%
expm1-log1p-u2.9%
expm1-udef2.6%
Applied egg-rr98.0%
expm1-def2.9%
expm1-log1p2.9%
Simplified98.0%
if -10.199999999999999 < x < 3.1e7Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 96.2%
if 3.1e7 < x Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
+-commutative99.5%
cancel-sign-sub-inv99.5%
div-inv99.6%
frac-sub96.5%
associate-/r*99.5%
*-un-lft-identity99.5%
*-commutative99.5%
Applied egg-rr99.5%
Taylor expanded in x around inf 99.6%
neg-mul-199.6%
Simplified99.6%
Final simplification97.5%
(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.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (B x) :precision binary64 (if (or (<= x -10.2) (not (<= x 5500000.0))) (/ (- x) (tan B)) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -10.2) || !(x <= 5500000.0)) {
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 <= (-10.2d0)) .or. (.not. (x <= 5500000.0d0))) 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 <= -10.2) || !(x <= 5500000.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 / Math.sin(B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -10.2) or not (x <= 5500000.0): 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 <= -10.2) || !(x <= 5500000.0)) tmp = Float64(Float64(-x) / 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 <= -10.2) || ~((x <= 5500000.0))) tmp = -x / tan(B); else tmp = (1.0 / sin(B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -10.2], N[Not[LessEqual[x, 5500000.0]], $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 -10.2 \lor \neg \left(x \leq 5500000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -10.199999999999999 or 5.5e6 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
div-inv99.7%
frac-sub97.3%
associate-/r*99.6%
*-un-lft-identity99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 98.6%
neg-mul-198.6%
Simplified98.6%
if -10.199999999999999 < x < 5.5e6Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 96.2%
Final simplification97.4%
(FPCore (B x) :precision binary64 (if (or (<= x -1.2) (not (<= x 1.05))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.2) || !(x <= 1.05)) {
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.2d0)) .or. (.not. (x <= 1.05d0))) 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.2) || !(x <= 1.05)) {
tmp = -x / Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.2) or not (x <= 1.05): tmp = -x / math.tan(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.2) || !(x <= 1.05)) tmp = Float64(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 <= -1.2) || ~((x <= 1.05))) tmp = -x / tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.2], N[Not[LessEqual[x, 1.05]], $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.2 \lor \neg \left(x \leq 1.05\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.19999999999999996 or 1.05000000000000004 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
div-inv99.7%
frac-sub97.4%
associate-/r*99.6%
*-un-lft-identity99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 97.2%
neg-mul-197.2%
Simplified97.2%
if -1.19999999999999996 < x < 1.05000000000000004Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 95.8%
Final simplification96.5%
(FPCore (B x)
:precision binary64
(if (or (<= B -0.00042) (not (<= B 1.3e+14)))
(/ 1.0 (sin B))
(-
(+ (/ 1.0 B) (* B (+ 0.16666666666666666 (* x 0.3333333333333333))))
(/ x B))))
double code(double B, double x) {
double tmp;
if ((B <= -0.00042) || !(B <= 1.3e+14)) {
tmp = 1.0 / sin(B);
} else {
tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (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.00042d0)) .or. (.not. (b <= 1.3d+14))) then
tmp = 1.0d0 / sin(b)
else
tmp = ((1.0d0 / b) + (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0)))) - (x / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -0.00042) || !(B <= 1.3e+14)) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -0.00042) or not (B <= 1.3e+14): tmp = 1.0 / math.sin(B) else: tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((B <= -0.00042) || !(B <= 1.3e+14)) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(Float64(1.0 / B) + Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333)))) - Float64(x / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -0.00042) || ~((B <= 1.3e+14))) tmp = 1.0 / sin(B); else tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -0.00042], N[Not[LessEqual[B, 1.3e+14]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / B), $MachinePrecision] + N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.00042 \lor \neg \left(B \leq 1.3 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}\\
\end{array}
\end{array}
if B < -4.2000000000000002e-4 or 1.3e14 < B Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in x around 0 47.8%
if -4.2000000000000002e-4 < B < 1.3e14Initial program 99.9%
+-commutative99.9%
unsub-neg99.9%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
Taylor expanded in B around 0 97.1%
Final simplification71.1%
(FPCore (B x)
:precision binary64
(if (<= B -1.25e+30)
(sin B)
(if (<= B 1.4e+15)
(-
(+ (/ 1.0 B) (* B (+ 0.16666666666666666 (* x 0.3333333333333333))))
(/ x B))
(sin B))))
double code(double B, double x) {
double tmp;
if (B <= -1.25e+30) {
tmp = sin(B);
} else if (B <= 1.4e+15) {
tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B);
} else {
tmp = 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 <= (-1.25d+30)) then
tmp = sin(b)
else if (b <= 1.4d+15) then
tmp = ((1.0d0 / b) + (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0)))) - (x / b)
else
tmp = sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= -1.25e+30) {
tmp = Math.sin(B);
} else if (B <= 1.4e+15) {
tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B);
} else {
tmp = Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= -1.25e+30: tmp = math.sin(B) elif B <= 1.4e+15: tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B) else: tmp = math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= -1.25e+30) tmp = sin(B); elseif (B <= 1.4e+15) tmp = Float64(Float64(Float64(1.0 / B) + Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333)))) - Float64(x / B)); else tmp = sin(B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= -1.25e+30) tmp = sin(B); elseif (B <= 1.4e+15) tmp = ((1.0 / B) + (B * (0.16666666666666666 + (x * 0.3333333333333333)))) - (x / B); else tmp = sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, -1.25e+30], N[Sin[B], $MachinePrecision], If[LessEqual[B, 1.4e+15], N[(N[(N[(1.0 / B), $MachinePrecision] + N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[Sin[B], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -1.25 \cdot 10^{+30}:\\
\;\;\;\;\sin B\\
\mathbf{elif}\;B \leq 1.4 \cdot 10^{+15}:\\
\;\;\;\;\left(\frac{1}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\sin B\\
\end{array}
\end{array}
if B < -1.25e30 or 1.4e15 < B Initial program 99.5%
+-commutative99.5%
unsub-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
add-exp-log47.8%
log-rec47.8%
Applied egg-rr47.8%
Taylor expanded in x around 0 23.0%
add-sqr-sqrt23.0%
sqrt-unprod23.0%
sqr-neg23.0%
sqrt-unprod0.0%
add-sqr-sqrt5.3%
add-exp-log11.4%
expm1-log1p-u11.4%
expm1-udef11.4%
Applied egg-rr11.4%
expm1-def11.4%
expm1-log1p11.4%
Simplified11.4%
if -1.25e30 < B < 1.4e15Initial program 99.9%
+-commutative99.9%
unsub-neg99.9%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
Taylor expanded in B around 0 94.1%
Final simplification52.4%
(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 / B) + Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333)))) - Float64(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 / B), $MachinePrecision] + N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}
\end{array}
Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 48.1%
Final simplification48.1%
(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 48.1%
+-commutative48.1%
mul-1-neg48.1%
sub-neg48.1%
associate--l+48.1%
*-commutative48.1%
*-commutative48.1%
div-sub48.1%
Simplified48.1%
Final simplification48.1%
(FPCore (B x) :precision binary64 (+ (/ (- 1.0 x) B) (* 0.3333333333333333 (* B x))))
double code(double B, double x) {
return ((1.0 - x) / B) + (0.3333333333333333 * (B * x));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 - x) / b) + (0.3333333333333333d0 * (b * x))
end function
public static double code(double B, double x) {
return ((1.0 - x) / B) + (0.3333333333333333 * (B * x));
}
def code(B, x): return ((1.0 - x) / B) + (0.3333333333333333 * (B * x))
function code(B, x) return Float64(Float64(Float64(1.0 - x) / B) + Float64(0.3333333333333333 * Float64(B * x))) end
function tmp = code(B, x) tmp = ((1.0 - x) / B) + (0.3333333333333333 * (B * x)); end
code[B_, x_] := N[(N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision] + N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{B} + 0.3333333333333333 \cdot \left(B \cdot x\right)
\end{array}
Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
add-exp-log48.4%
log-rec48.4%
Applied egg-rr48.4%
Taylor expanded in B around 0 22.9%
neg-mul-122.9%
+-commutative22.9%
associate-+r+22.9%
+-commutative22.9%
unsub-neg22.9%
exp-neg22.9%
rem-exp-log47.9%
div-sub47.9%
*-commutative47.9%
*-commutative47.9%
Simplified47.9%
Final simplification47.9%
(FPCore (B x) :precision binary64 (+ (* B 0.16666666666666666) (- (/ 1.0 B) (/ x B))))
double code(double B, double x) {
return (B * 0.16666666666666666) + ((1.0 / B) - (x / 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))
end function
public static double code(double B, double x) {
return (B * 0.16666666666666666) + ((1.0 / B) - (x / B));
}
def code(B, x): return (B * 0.16666666666666666) + ((1.0 / B) - (x / B))
function code(B, x) return Float64(Float64(B * 0.16666666666666666) + Float64(Float64(1.0 / B) - Float64(x / B))) end
function tmp = code(B, x) tmp = (B * 0.16666666666666666) + ((1.0 / B) - (x / B)); end
code[B_, x_] := N[(N[(B * 0.16666666666666666), $MachinePrecision] + N[(N[(1.0 / B), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
B \cdot 0.16666666666666666 + \left(\frac{1}{B} - \frac{x}{B}\right)
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 70.9%
Taylor expanded in B around 0 48.1%
Final simplification48.1%
(FPCore (B x) :precision binary64 (if (or (<= x -0.3) (not (<= x 1.4e-13))) (- (/ x B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -0.3) || !(x <= 1.4e-13)) {
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.3d0)) .or. (.not. (x <= 1.4d-13))) 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.3) || !(x <= 1.4e-13)) {
tmp = -(x / B);
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.3) or not (x <= 1.4e-13): tmp = -(x / B) else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.3) || !(x <= 1.4e-13)) 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 <= -0.3) || ~((x <= 1.4e-13))) tmp = -(x / B); else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.3], N[Not[LessEqual[x, 1.4e-13]], $MachinePrecision]], (-N[(x / B), $MachinePrecision]), N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.3 \lor \neg \left(x \leq 1.4 \cdot 10^{-13}\right):\\
\;\;\;\;-\frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -0.299999999999999989 or 1.4000000000000001e-13 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 44.5%
mul-1-neg44.5%
sub-neg44.5%
Simplified44.5%
Taylor expanded in x around inf 44.2%
neg-mul-144.2%
distribute-neg-frac44.2%
Simplified44.2%
if -0.299999999999999989 < x < 1.4000000000000001e-13Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 51.4%
mul-1-neg51.4%
sub-neg51.4%
Simplified51.4%
Taylor expanded in x around 0 49.8%
Final simplification46.8%
(FPCore (B x) :precision binary64 (- (/ 1.0 B) (/ x B)))
double code(double B, double x) {
return (1.0 / B) - (x / B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / b) - (x / b)
end function
public static double code(double B, double x) {
return (1.0 / B) - (x / B);
}
def code(B, x): return (1.0 / B) - (x / B)
function code(B, x) return Float64(Float64(1.0 / B) - Float64(x / B)) end
function tmp = code(B, x) tmp = (1.0 / B) - (x / B); end
code[B_, x_] := N[(N[(1.0 / B), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{B} - \frac{x}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 47.6%
mul-1-neg47.6%
sub-neg47.6%
Simplified47.6%
div-sub47.6%
Applied egg-rr47.6%
Final simplification47.6%
(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 47.6%
mul-1-neg47.6%
sub-neg47.6%
Simplified47.6%
Final simplification47.6%
(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%
Simplified99.7%
Taylor expanded in B around 0 47.6%
mul-1-neg47.6%
sub-neg47.6%
Simplified47.6%
Taylor expanded in x around 0 24.2%
Final simplification24.2%
herbie shell --seed 2023178
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))