
(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 13 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 (- (pow (sin B) -1.0) (/ x (tan B))))
double code(double B, double x) {
return pow(sin(B), -1.0) - (x / tan(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (sin(b) ** (-1.0d0)) - (x / tan(b))
end function
public static double code(double B, double x) {
return Math.pow(Math.sin(B), -1.0) - (x / Math.tan(B));
}
def code(B, x): return math.pow(math.sin(B), -1.0) - (x / math.tan(B))
function code(B, x) return Float64((sin(B) ^ -1.0) - Float64(x / tan(B))) end
function tmp = code(B, x) tmp = (sin(B) ^ -1.0) - (x / tan(B)); end
code[B_, x_] := N[(N[Power[N[Sin[B], $MachinePrecision], -1.0], $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\sin B}^{-1} - \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.8%
*-rgt-identity99.8%
Simplified99.8%
inv-pow99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (or (<= x -0.00021) (not (<= x 1.12))) (- (/ 1.0 B) (/ x (tan B))) (pow (/ (sin B) (- 1.0 x)) -1.0)))
double code(double B, double x) {
double tmp;
if ((x <= -0.00021) || !(x <= 1.12)) {
tmp = (1.0 / B) - (x / tan(B));
} else {
tmp = pow((sin(B) / (1.0 - x)), -1.0);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-0.00021d0)) .or. (.not. (x <= 1.12d0))) then
tmp = (1.0d0 / b) - (x / tan(b))
else
tmp = (sin(b) / (1.0d0 - x)) ** (-1.0d0)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -0.00021) || !(x <= 1.12)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = Math.pow((Math.sin(B) / (1.0 - x)), -1.0);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.00021) or not (x <= 1.12): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = math.pow((math.sin(B) / (1.0 - x)), -1.0) return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.00021) || !(x <= 1.12)) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); else tmp = Float64(sin(B) / Float64(1.0 - x)) ^ -1.0; end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -0.00021) || ~((x <= 1.12))) tmp = (1.0 / B) - (x / tan(B)); else tmp = (sin(B) / (1.0 - x)) ^ -1.0; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.00021], N[Not[LessEqual[x, 1.12]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sin[B], $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00021 \lor \neg \left(x \leq 1.12\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sin B}{1 - x}\right)}^{-1}\\
\end{array}
\end{array}
if x < -2.1000000000000001e-4 or 1.1200000000000001 < 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 99.4%
if -2.1000000000000001e-4 < x < 1.1200000000000001Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
inv-pow99.8%
Applied egg-rr99.8%
inv-pow99.8%
frac-sub84.0%
*-un-lft-identity84.0%
*-commutative84.0%
*-commutative84.0%
div-sub82.9%
sub-neg82.9%
*-commutative82.9%
*-commutative82.9%
times-frac84.0%
Applied egg-rr84.0%
sub-neg84.0%
times-frac82.9%
*-commutative82.9%
div-sub84.0%
associate-/l/99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
Taylor expanded in B around 0 98.6%
clear-num98.6%
inv-pow98.6%
Applied egg-rr98.6%
Final simplification99.1%
(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.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (or (<= x -0.00021) (not (<= x 1.0))) (- (/ 1.0 B) (/ x (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -0.00021) || !(x <= 1.0)) {
tmp = (1.0 / B) - (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 <= (-0.00021d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (1.0d0 / b) - (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 <= -0.00021) || !(x <= 1.0)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.00021) or not (x <= 1.0): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.00021) || !(x <= 1.0)) tmp = Float64(Float64(1.0 / B) - Float64(x / 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 <= -0.00021) || ~((x <= 1.0))) tmp = (1.0 / B) - (x / tan(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.00021], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[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 -0.00021 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -2.1000000000000001e-4 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 B around 0 99.4%
if -2.1000000000000001e-4 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
inv-pow99.8%
Applied egg-rr99.8%
inv-pow99.8%
frac-sub84.0%
*-un-lft-identity84.0%
*-commutative84.0%
*-commutative84.0%
div-sub82.9%
sub-neg82.9%
*-commutative82.9%
*-commutative82.9%
times-frac84.0%
Applied egg-rr84.0%
sub-neg84.0%
times-frac82.9%
*-commutative82.9%
div-sub84.0%
associate-/l/99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
Taylor expanded in B around 0 98.6%
Final simplification99.0%
(FPCore (B x) :precision binary64 (if (or (<= x -1150000.0) (not (<= x 4.1e+14))) (/ (- x) (tan B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1150000.0) || !(x <= 4.1e+14)) {
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 <= (-1150000.0d0)) .or. (.not. (x <= 4.1d+14))) 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 <= -1150000.0) || !(x <= 4.1e+14)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1150000.0) or not (x <= 4.1e+14): tmp = -x / math.tan(B) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1150000.0) || !(x <= 4.1e+14)) tmp = Float64(Float64(-x) / 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 <= -1150000.0) || ~((x <= 4.1e+14))) tmp = -x / tan(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1150000.0], N[Not[LessEqual[x, 4.1e+14]], $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 -1150000 \lor \neg \left(x \leq 4.1 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1.15e6 or 4.1e14 < 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%
inv-pow99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 98.9%
mul-1-neg98.9%
distribute-frac-neg98.9%
distribute-rgt-neg-out98.9%
*-commutative98.9%
associate-/l*98.8%
Simplified98.8%
distribute-frac-neg98.8%
neg-sub098.8%
add-sqr-sqrt78.8%
sqrt-unprod79.0%
sqr-neg79.0%
sqrt-unprod0.2%
add-sqr-sqrt0.4%
associate-/r/0.4%
clear-num0.4%
add-sqr-sqrt0.2%
sqrt-unprod79.0%
sqr-neg79.0%
sqrt-unprod78.8%
add-sqr-sqrt98.7%
tan-quot98.8%
Applied egg-rr98.8%
neg-sub098.8%
associate-*l/99.0%
*-lft-identity99.0%
distribute-neg-frac99.0%
Simplified99.0%
if -1.15e6 < x < 4.1e14Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
inv-pow99.8%
Applied egg-rr99.8%
inv-pow99.8%
frac-sub82.9%
*-un-lft-identity82.9%
*-commutative82.9%
*-commutative82.9%
div-sub81.8%
sub-neg81.8%
*-commutative81.8%
*-commutative81.8%
times-frac82.9%
Applied egg-rr82.9%
sub-neg82.9%
times-frac81.8%
*-commutative81.8%
div-sub82.9%
associate-/l/99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
Taylor expanded in B around 0 98.6%
Final simplification98.8%
(FPCore (B x) :precision binary64 (if (or (<= x -1.3) (not (<= x 1.0))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.3) || !(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.3d0)) .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.3) || !(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.3) 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.3) || !(x <= 1.0)) 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.3) || ~((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.3], 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.3 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.30000000000000004 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%
inv-pow99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 98.0%
mul-1-neg98.0%
distribute-frac-neg98.0%
distribute-rgt-neg-out98.0%
*-commutative98.0%
associate-/l*97.9%
Simplified97.9%
distribute-frac-neg97.9%
neg-sub097.9%
add-sqr-sqrt78.3%
sqrt-unprod78.6%
sqr-neg78.6%
sqrt-unprod0.2%
add-sqr-sqrt0.4%
associate-/r/0.4%
clear-num0.4%
add-sqr-sqrt0.2%
sqrt-unprod78.5%
sqr-neg78.5%
sqrt-unprod78.4%
add-sqr-sqrt97.9%
tan-quot98.0%
Applied egg-rr98.0%
neg-sub098.0%
associate-*l/98.1%
*-lft-identity98.1%
distribute-neg-frac98.1%
Simplified98.1%
if -1.30000000000000004 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 97.6%
Final simplification97.9%
(FPCore (B x) :precision binary64 (if (or (<= B -220000000000.0) (not (<= B 1.5e+32))) (/ 1.0 (sin B)) (+ (/ 1.0 B) (- (* 0.3333333333333333 (* B x)) (/ x B)))))
double code(double B, double x) {
double tmp;
if ((B <= -220000000000.0) || !(B <= 1.5e+32)) {
tmp = 1.0 / sin(B);
} else {
tmp = (1.0 / B) + ((0.3333333333333333 * (B * x)) - (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 <= (-220000000000.0d0)) .or. (.not. (b <= 1.5d+32))) then
tmp = 1.0d0 / sin(b)
else
tmp = (1.0d0 / b) + ((0.3333333333333333d0 * (b * x)) - (x / b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -220000000000.0) || !(B <= 1.5e+32)) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (1.0 / B) + ((0.3333333333333333 * (B * x)) - (x / B));
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -220000000000.0) or not (B <= 1.5e+32): tmp = 1.0 / math.sin(B) else: tmp = (1.0 / B) + ((0.3333333333333333 * (B * x)) - (x / B)) return tmp
function code(B, x) tmp = 0.0 if ((B <= -220000000000.0) || !(B <= 1.5e+32)) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(1.0 / B) + Float64(Float64(0.3333333333333333 * Float64(B * x)) - Float64(x / B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -220000000000.0) || ~((B <= 1.5e+32))) tmp = 1.0 / sin(B); else tmp = (1.0 / B) + ((0.3333333333333333 * (B * x)) - (x / B)); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -220000000000.0], N[Not[LessEqual[B, 1.5e+32]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / B), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -220000000000 \lor \neg \left(B \leq 1.5 \cdot 10^{+32}\right):\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B} + \left(0.3333333333333333 \cdot \left(B \cdot x\right) - \frac{x}{B}\right)\\
\end{array}
\end{array}
if B < -2.2e11 or 1.5e32 < B Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in x around 0 53.1%
if -2.2e11 < B < 1.5e32Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 99.8%
Taylor expanded in B around 0 94.8%
Final simplification74.3%
(FPCore (B x) :precision binary64 (+ (/ 1.0 B) (- (* 0.3333333333333333 (* B x)) (/ x B))))
double code(double B, double x) {
return (1.0 / B) + ((0.3333333333333333 * (B * x)) - (x / B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / b) + ((0.3333333333333333d0 * (b * x)) - (x / b))
end function
public static double code(double B, double x) {
return (1.0 / B) + ((0.3333333333333333 * (B * x)) - (x / B));
}
def code(B, x): return (1.0 / B) + ((0.3333333333333333 * (B * x)) - (x / B))
function code(B, x) return Float64(Float64(1.0 / B) + Float64(Float64(0.3333333333333333 * Float64(B * x)) - Float64(x / B))) end
function tmp = code(B, x) tmp = (1.0 / B) + ((0.3333333333333333 * (B * x)) - (x / B)); end
code[B_, x_] := N[(N[(1.0 / B), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{B} + \left(0.3333333333333333 \cdot \left(B \cdot x\right) - \frac{x}{B}\right)
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 74.4%
Taylor expanded in B around 0 49.8%
Final simplification49.8%
(FPCore (B x) :precision binary64 (+ (/ (- 1.0 x) B) (* x (* B 0.3333333333333333))))
double code(double B, double x) {
return ((1.0 - x) / B) + (x * (B * 0.3333333333333333));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 - x) / b) + (x * (b * 0.3333333333333333d0))
end function
public static double code(double B, double x) {
return ((1.0 - x) / B) + (x * (B * 0.3333333333333333));
}
def code(B, x): return ((1.0 - x) / B) + (x * (B * 0.3333333333333333))
function code(B, x) return Float64(Float64(Float64(1.0 - x) / B) + Float64(x * Float64(B * 0.3333333333333333))) end
function tmp = code(B, x) tmp = ((1.0 - x) / B) + (x * (B * 0.3333333333333333)); end
code[B_, x_] := N[(N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision] + N[(x * N[(B * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{B} + x \cdot \left(B \cdot 0.3333333333333333\right)
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 74.4%
Taylor expanded in B around 0 49.8%
neg-mul-149.8%
+-commutative49.8%
associate-+r+49.8%
+-commutative49.8%
sub-neg49.8%
div-sub49.8%
associate-*r*49.8%
Simplified49.8%
Final simplification49.8%
(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(Float64(-x) / 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.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 53.6%
neg-mul-153.6%
sub-neg53.6%
Simplified53.6%
Taylor expanded in x around inf 52.5%
neg-mul-152.5%
distribute-neg-frac52.5%
Simplified52.5%
if -1 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 44.5%
Taylor expanded in B around 0 44.6%
Taylor expanded in x around 0 43.5%
Final simplification48.4%
(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%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 49.4%
neg-mul-149.4%
sub-neg49.4%
Simplified49.4%
div-sub49.4%
Applied egg-rr49.4%
Final simplification49.4%
(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%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 49.4%
neg-mul-149.4%
sub-neg49.4%
Simplified49.4%
Final simplification49.4%
(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%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 74.4%
Taylor expanded in B around 0 49.8%
Taylor expanded in x around 0 21.3%
Final simplification21.3%
herbie shell --seed 2023313
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))