
(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%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x)
:precision binary64
(if (<= x -3.2)
(- (/ 1.0 B) (/ x (tan B)))
(if (<= x 105000.0)
(/ (- x (/ B (sin B))) (- B))
(* (cos B) (/ x (- (sin B)))))))
double code(double B, double x) {
double tmp;
if (x <= -3.2) {
tmp = (1.0 / B) - (x / tan(B));
} else if (x <= 105000.0) {
tmp = (x - (B / sin(B))) / -B;
} else {
tmp = cos(B) * (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 <= (-3.2d0)) then
tmp = (1.0d0 / b) - (x / tan(b))
else if (x <= 105000.0d0) then
tmp = (x - (b / sin(b))) / -b
else
tmp = cos(b) * (x / -sin(b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -3.2) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else if (x <= 105000.0) {
tmp = (x - (B / Math.sin(B))) / -B;
} else {
tmp = Math.cos(B) * (x / -Math.sin(B));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -3.2: tmp = (1.0 / B) - (x / math.tan(B)) elif x <= 105000.0: tmp = (x - (B / math.sin(B))) / -B else: tmp = math.cos(B) * (x / -math.sin(B)) return tmp
function code(B, x) tmp = 0.0 if (x <= -3.2) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); elseif (x <= 105000.0) tmp = Float64(Float64(x - Float64(B / sin(B))) / Float64(-B)); else tmp = Float64(cos(B) * Float64(x / Float64(-sin(B)))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -3.2) tmp = (1.0 / B) - (x / tan(B)); elseif (x <= 105000.0) tmp = (x - (B / sin(B))) / -B; else tmp = cos(B) * (x / -sin(B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -3.2], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 105000.0], N[(N[(x - N[(B / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-B)), $MachinePrecision], N[(N[Cos[B], $MachinePrecision] * N[(x / (-N[Sin[B], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{elif}\;x \leq 105000:\\
\;\;\;\;\frac{x - \frac{B}{\sin B}}{-B}\\
\mathbf{else}:\\
\;\;\;\;\cos B \cdot \frac{x}{-\sin B}\\
\end{array}
\end{array}
if x < -3.2000000000000002Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-cbrt-cube92.6%
pow392.6%
inv-pow92.6%
pow-pow92.6%
metadata-eval92.6%
Applied egg-rr92.6%
Taylor expanded in B around 0 98.1%
if -3.2000000000000002 < x < 105000Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.0%
frac-sub73.2%
*-un-lft-identity73.2%
Applied egg-rr73.2%
frac-2neg73.2%
div-inv72.8%
*-commutative72.8%
distribute-rgt-neg-in72.8%
Applied egg-rr72.8%
associate-*r/73.2%
*-rgt-identity73.2%
distribute-neg-frac73.2%
associate-/r*99.0%
distribute-neg-frac99.0%
div-sub99.0%
associate-/l*99.0%
*-inverses99.0%
Simplified99.0%
if 105000 < x Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in B around 0 69.3%
Taylor expanded in x around inf 99.6%
mul-1-neg99.6%
associate-*r/99.7%
distribute-rgt-neg-in99.7%
neg-mul-199.7%
associate-*r/99.7%
*-commutative99.7%
remove-double-neg99.7%
neg-mul-199.7%
times-frac99.3%
neg-mul-199.3%
associate-/r*99.3%
metadata-eval99.3%
times-frac99.7%
*-rgt-identity99.7%
neg-mul-199.7%
Simplified99.7%
Final simplification98.9%
(FPCore (B x) :precision binary64 (if (or (<= x -1.7) (not (<= x 0.00065))) (- (/ 1.0 B) (/ x (tan B))) (/ (- x (/ B (sin B))) (- B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.7) || !(x <= 0.00065)) {
tmp = (1.0 / B) - (x / tan(B));
} else {
tmp = (x - (B / sin(B))) / -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.7d0)) .or. (.not. (x <= 0.00065d0))) then
tmp = (1.0d0 / b) - (x / tan(b))
else
tmp = (x - (b / sin(b))) / -b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -1.7) || !(x <= 0.00065)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = (x - (B / Math.sin(B))) / -B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.7) or not (x <= 0.00065): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = (x - (B / math.sin(B))) / -B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.7) || !(x <= 0.00065)) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); else tmp = Float64(Float64(x - Float64(B / sin(B))) / Float64(-B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.7) || ~((x <= 0.00065))) tmp = (1.0 / B) - (x / tan(B)); else tmp = (x - (B / sin(B))) / -B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.7], N[Not[LessEqual[x, 0.00065]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - N[(B / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-B)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \lor \neg \left(x \leq 0.00065\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \frac{B}{\sin B}}{-B}\\
\end{array}
\end{array}
if x < -1.69999999999999996 or 6.4999999999999997e-4 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-cbrt-cube79.5%
pow379.5%
inv-pow79.5%
pow-pow79.5%
metadata-eval79.5%
Applied egg-rr79.5%
Taylor expanded in B around 0 98.8%
if -1.69999999999999996 < x < 6.4999999999999997e-4Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.0%
frac-sub73.7%
*-un-lft-identity73.7%
Applied egg-rr73.7%
frac-2neg73.7%
div-inv73.3%
*-commutative73.3%
distribute-rgt-neg-in73.3%
Applied egg-rr73.3%
associate-*r/73.7%
*-rgt-identity73.7%
distribute-neg-frac73.7%
associate-/r*99.0%
distribute-neg-frac99.0%
div-sub99.0%
associate-/l*99.0%
*-inverses99.0%
Simplified99.0%
Final simplification98.9%
(FPCore (B x) :precision binary64 (if (or (<= x -1.1e-5) (not (<= x 1.15e-5))) (- (/ 1.0 B) (/ x (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.1e-5) || !(x <= 1.15e-5)) {
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 <= (-1.1d-5)) .or. (.not. (x <= 1.15d-5))) 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 <= -1.1e-5) || !(x <= 1.15e-5)) {
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 <= -1.1e-5) or not (x <= 1.15e-5): 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 <= -1.1e-5) || !(x <= 1.15e-5)) 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 <= -1.1e-5) || ~((x <= 1.15e-5))) 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, -1.1e-5], N[Not[LessEqual[x, 1.15e-5]], $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 -1.1 \cdot 10^{-5} \lor \neg \left(x \leq 1.15 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.1e-5 or 1.15e-5 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-cbrt-cube79.5%
pow379.5%
inv-pow79.5%
pow-pow79.5%
metadata-eval79.5%
Applied egg-rr79.5%
Taylor expanded in B around 0 98.8%
if -1.1e-5 < x < 1.15e-5Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.0%
Taylor expanded in B around inf 98.9%
Final simplification98.8%
(FPCore (B x) :precision binary64 (if (or (<= x -2.2) (not (<= x 0.00065))) (- (/ 1.0 B) (/ x (tan B))) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -2.2) || !(x <= 0.00065)) {
tmp = (1.0 / B) - (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 <= (-2.2d0)) .or. (.not. (x <= 0.00065d0))) then
tmp = (1.0d0 / b) - (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 <= -2.2) || !(x <= 0.00065)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = (1.0 / Math.sin(B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2.2) or not (x <= 0.00065): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = (1.0 / math.sin(B)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -2.2) || !(x <= 0.00065)) tmp = Float64(Float64(1.0 / B) - 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 <= -2.2) || ~((x <= 0.00065))) tmp = (1.0 / B) - (x / tan(B)); else tmp = (1.0 / sin(B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2.2], N[Not[LessEqual[x, 0.00065]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $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 -2.2 \lor \neg \left(x \leq 0.00065\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -2.2000000000000002 or 6.4999999999999997e-4 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-cbrt-cube79.5%
pow379.5%
inv-pow79.5%
pow-pow79.5%
metadata-eval79.5%
Applied egg-rr79.5%
Taylor expanded in B around 0 98.8%
if -2.2000000000000002 < x < 6.4999999999999997e-4Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.0%
Final simplification98.9%
(FPCore (B x)
:precision binary64
(if (<= x -400000000.0)
(- (/ (- x) B) (* B (* x -0.3333333333333333)))
(if (<= x 1.3e-7)
(/ 1.0 (sin B))
(+ (* x (/ -1.0 B)) (- (* B 0.16666666666666666) (/ -1.0 B))))))
double code(double B, double x) {
double tmp;
if (x <= -400000000.0) {
tmp = (-x / B) - (B * (x * -0.3333333333333333));
} else if (x <= 1.3e-7) {
tmp = 1.0 / sin(B);
} else {
tmp = (x * (-1.0 / B)) + ((B * 0.16666666666666666) - (-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 <= (-400000000.0d0)) then
tmp = (-x / b) - (b * (x * (-0.3333333333333333d0)))
else if (x <= 1.3d-7) then
tmp = 1.0d0 / sin(b)
else
tmp = (x * ((-1.0d0) / b)) + ((b * 0.16666666666666666d0) - ((-1.0d0) / b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -400000000.0) {
tmp = (-x / B) - (B * (x * -0.3333333333333333));
} else if (x <= 1.3e-7) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (x * (-1.0 / B)) + ((B * 0.16666666666666666) - (-1.0 / B));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -400000000.0: tmp = (-x / B) - (B * (x * -0.3333333333333333)) elif x <= 1.3e-7: tmp = 1.0 / math.sin(B) else: tmp = (x * (-1.0 / B)) + ((B * 0.16666666666666666) - (-1.0 / B)) return tmp
function code(B, x) tmp = 0.0 if (x <= -400000000.0) tmp = Float64(Float64(Float64(-x) / B) - Float64(B * Float64(x * -0.3333333333333333))); elseif (x <= 1.3e-7) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(x * Float64(-1.0 / B)) + Float64(Float64(B * 0.16666666666666666) - Float64(-1.0 / B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -400000000.0) tmp = (-x / B) - (B * (x * -0.3333333333333333)); elseif (x <= 1.3e-7) tmp = 1.0 / sin(B); else tmp = (x * (-1.0 / B)) + ((B * 0.16666666666666666) - (-1.0 / B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -400000000.0], N[(N[((-x) / B), $MachinePrecision] - N[(B * N[(x * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.3e-7], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision] + N[(N[(B * 0.16666666666666666), $MachinePrecision] - N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -400000000:\\
\;\;\;\;\frac{-x}{B} - B \cdot \left(x \cdot -0.3333333333333333\right)\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1}{B} + \left(B \cdot 0.16666666666666666 - \frac{-1}{B}\right)\\
\end{array}
\end{array}
if x < -4e8Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 71.9%
Taylor expanded in x around inf 99.6%
mul-1-neg99.6%
associate-*r/99.6%
distribute-rgt-neg-in99.6%
neg-mul-199.6%
associate-*r/99.6%
*-commutative99.6%
remove-double-neg99.6%
neg-mul-199.6%
times-frac99.4%
neg-mul-199.4%
associate-/r*99.4%
metadata-eval99.4%
times-frac99.6%
*-rgt-identity99.6%
neg-mul-199.6%
Simplified99.6%
Taylor expanded in B around 0 48.2%
distribute-lft-out48.2%
*-commutative48.2%
distribute-rgt-out--48.2%
metadata-eval48.2%
Simplified48.2%
if -4e8 < x < 1.29999999999999999e-7Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 96.8%
Taylor expanded in B around inf 96.7%
if 1.29999999999999999e-7 < x Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in B around 0 69.9%
Taylor expanded in B around 0 56.4%
Final simplification73.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 / 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%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 57.4%
Taylor expanded in B around 0 47.5%
Final simplification47.5%
(FPCore (B x) :precision binary64 (+ (* x (/ -1.0 B)) (- (* B 0.16666666666666666) (/ -1.0 B))))
double code(double B, double x) {
return (x * (-1.0 / B)) + ((B * 0.16666666666666666) - (-1.0 / B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (x * ((-1.0d0) / b)) + ((b * 0.16666666666666666d0) - ((-1.0d0) / b))
end function
public static double code(double B, double x) {
return (x * (-1.0 / B)) + ((B * 0.16666666666666666) - (-1.0 / B));
}
def code(B, x): return (x * (-1.0 / B)) + ((B * 0.16666666666666666) - (-1.0 / B))
function code(B, x) return Float64(Float64(x * Float64(-1.0 / B)) + Float64(Float64(B * 0.16666666666666666) - Float64(-1.0 / B))) end
function tmp = code(B, x) tmp = (x * (-1.0 / B)) + ((B * 0.16666666666666666) - (-1.0 / B)); end
code[B_, x_] := N[(N[(x * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision] + N[(N[(B * 0.16666666666666666), $MachinePrecision] - N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{-1}{B} + \left(B \cdot 0.16666666666666666 - \frac{-1}{B}\right)
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 57.4%
Taylor expanded in B around 0 47.3%
Final simplification47.3%
(FPCore (B x) :precision binary64 (if (or (<= x -10000000.0) (not (<= x 1.55e+14))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -10000000.0) || !(x <= 1.55e+14)) {
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 <= (-10000000.0d0)) .or. (.not. (x <= 1.55d+14))) 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 <= -10000000.0) || !(x <= 1.55e+14)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -10000000.0) or not (x <= 1.55e+14): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -10000000.0) || !(x <= 1.55e+14)) 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 <= -10000000.0) || ~((x <= 1.55e+14))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -10000000.0], N[Not[LessEqual[x, 1.55e+14]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10000000 \lor \neg \left(x \leq 1.55 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1e7 or 1.55e14 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 51.1%
Taylor expanded in x around inf 50.8%
associate-*r/50.8%
mul-1-neg50.8%
Simplified50.8%
if -1e7 < x < 1.55e14Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-cbrt-cube70.3%
pow370.3%
inv-pow70.3%
pow-pow70.2%
metadata-eval70.2%
Applied egg-rr70.2%
Taylor expanded in B around 0 45.0%
Taylor expanded in x around 0 42.9%
Final simplification46.9%
(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%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 73.4%
Taylor expanded in B around 0 47.2%
Final simplification47.2%
(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%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 57.4%
Taylor expanded in B around inf 3.0%
*-commutative3.0%
Simplified3.0%
Final simplification3.0%
(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%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-cbrt-cube75.0%
pow375.0%
inv-pow75.0%
pow-pow75.0%
metadata-eval75.0%
Applied egg-rr75.0%
Taylor expanded in B around 0 72.9%
Taylor expanded in x around 0 22.3%
Final simplification22.3%
herbie shell --seed 2023222
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))