
(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.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (or (<= x -2500000000.0) (not (<= x 31.0))) (- (/ (cos B) (/ (sin B) x))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -2500000000.0) || !(x <= 31.0)) {
tmp = -(cos(B) / (sin(B) / x));
} 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 <= (-2500000000.0d0)) .or. (.not. (x <= 31.0d0))) then
tmp = -(cos(b) / (sin(b) / x))
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 <= -2500000000.0) || !(x <= 31.0)) {
tmp = -(Math.cos(B) / (Math.sin(B) / x));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2500000000.0) or not (x <= 31.0): tmp = -(math.cos(B) / (math.sin(B) / x)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -2500000000.0) || !(x <= 31.0)) tmp = Float64(-Float64(cos(B) / Float64(sin(B) / x))); else tmp = Float64(Float64(1.0 - x) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -2500000000.0) || ~((x <= 31.0))) tmp = -(cos(B) / (sin(B) / x)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2500000000.0], N[Not[LessEqual[x, 31.0]], $MachinePrecision]], (-N[(N[Cos[B], $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2500000000 \lor \neg \left(x \leq 31\right):\\
\;\;\;\;-\frac{\cos B}{\frac{\sin B}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -2.5e9 or 31 < x Initial program 99.5%
+-commutative99.5%
unsub-neg99.5%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.7%
*-commutative99.7%
div-sub99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
associate-/l*97.7%
Simplified97.7%
if -2.5e9 < x < 31Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
*-commutative99.8%
div-sub99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in B around 0 98.3%
Final simplification98.0%
(FPCore (B x) :precision binary64 (if (or (<= x -2700000000.0) (not (<= x 31.0))) (* (cos B) (/ (- x) (sin B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -2700000000.0) || !(x <= 31.0)) {
tmp = cos(B) * (-x / sin(B));
} else {
tmp = (1.0 - x) / sin(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-2700000000.0d0)) .or. (.not. (x <= 31.0d0))) then
tmp = cos(b) * (-x / sin(b))
else
tmp = (1.0d0 - x) / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -2700000000.0) || !(x <= 31.0)) {
tmp = Math.cos(B) * (-x / Math.sin(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2700000000.0) or not (x <= 31.0): tmp = math.cos(B) * (-x / math.sin(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -2700000000.0) || !(x <= 31.0)) tmp = Float64(cos(B) * Float64(Float64(-x) / sin(B))); else tmp = Float64(Float64(1.0 - x) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -2700000000.0) || ~((x <= 31.0))) tmp = cos(B) * (-x / sin(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2700000000.0], N[Not[LessEqual[x, 31.0]], $MachinePrecision]], N[(N[Cos[B], $MachinePrecision] * N[((-x) / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2700000000 \lor \neg \left(x \leq 31\right):\\
\;\;\;\;\cos B \cdot \frac{-x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -2.7e9 or 31 < x Initial program 99.5%
+-commutative99.5%
unsub-neg99.5%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 97.9%
mul-1-neg97.9%
associate-*r/97.9%
distribute-rgt-neg-in97.9%
distribute-neg-frac97.9%
Simplified97.9%
if -2.7e9 < x < 31Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
*-commutative99.8%
div-sub99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in B around 0 98.3%
Final simplification98.1%
(FPCore (B x) :precision binary64 (if (<= x -4100000000.0) (* (cos B) (/ (- x) (sin B))) (if (<= x 31.0) (/ (- 1.0 x) (sin B)) (/ (* (cos B) (- x)) (sin B)))))
double code(double B, double x) {
double tmp;
if (x <= -4100000000.0) {
tmp = cos(B) * (-x / sin(B));
} else if (x <= 31.0) {
tmp = (1.0 - x) / sin(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 <= (-4100000000.0d0)) then
tmp = cos(b) * (-x / sin(b))
else if (x <= 31.0d0) then
tmp = (1.0d0 - x) / sin(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 <= -4100000000.0) {
tmp = Math.cos(B) * (-x / Math.sin(B));
} else if (x <= 31.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = (Math.cos(B) * -x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -4100000000.0: tmp = math.cos(B) * (-x / math.sin(B)) elif x <= 31.0: tmp = (1.0 - x) / math.sin(B) else: tmp = (math.cos(B) * -x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -4100000000.0) tmp = Float64(cos(B) * Float64(Float64(-x) / sin(B))); elseif (x <= 31.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(cos(B) * Float64(-x)) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -4100000000.0) tmp = cos(B) * (-x / sin(B)); elseif (x <= 31.0) tmp = (1.0 - x) / sin(B); else tmp = (cos(B) * -x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -4100000000.0], N[(N[Cos[B], $MachinePrecision] * N[((-x) / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 31.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[B], $MachinePrecision] * (-x)), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4100000000:\\
\;\;\;\;\cos B \cdot \frac{-x}{\sin B}\\
\mathbf{elif}\;x \leq 31:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos B \cdot \left(-x\right)}{\sin B}\\
\end{array}
\end{array}
if x < -4.1e9Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 99.3%
mul-1-neg99.3%
associate-*r/99.4%
distribute-rgt-neg-in99.4%
distribute-neg-frac99.4%
Simplified99.4%
if -4.1e9 < x < 31Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
*-commutative99.8%
div-sub99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in B around 0 98.3%
if 31 < x Initial program 99.4%
+-commutative99.4%
unsub-neg99.4%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 96.4%
associate-*r/96.4%
*-commutative96.4%
neg-mul-196.4%
*-commutative96.4%
distribute-rgt-neg-in96.4%
Simplified96.4%
Final simplification98.1%
(FPCore (B x) :precision binary64 (if (or (<= x -1.35e+81) (not (<= x 3.1e+124))) (- (+ (* B 0.16666666666666666) (/ 1.0 B)) (/ x (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.35e+81) || !(x <= 3.1e+124)) {
tmp = ((B * 0.16666666666666666) + (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 <= (-1.35d+81)) .or. (.not. (x <= 3.1d+124))) then
tmp = ((b * 0.16666666666666666d0) + (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 <= -1.35e+81) || !(x <= 3.1e+124)) {
tmp = ((B * 0.16666666666666666) + (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 <= -1.35e+81) or not (x <= 3.1e+124): tmp = ((B * 0.16666666666666666) + (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 <= -1.35e+81) || !(x <= 3.1e+124)) tmp = Float64(Float64(Float64(B * 0.16666666666666666) + 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 <= -1.35e+81) || ~((x <= 3.1e+124))) tmp = ((B * 0.16666666666666666) + (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, -1.35e+81], N[Not[LessEqual[x, 3.1e+124]], $MachinePrecision]], N[(N[(N[(B * 0.16666666666666666), $MachinePrecision] + N[(1.0 / B), $MachinePrecision]), $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 -1.35 \cdot 10^{+81} \lor \neg \left(x \leq 3.1 \cdot 10^{+124}\right):\\
\;\;\;\;\left(B \cdot 0.16666666666666666 + \frac{1}{B}\right) - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1.35e81 or 3.1000000000000002e124 < 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 76.7%
if -1.35e81 < x < 3.1000000000000002e124Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
*-commutative99.8%
div-sub99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in B around 0 90.6%
Final simplification86.0%
(FPCore (B x)
:precision binary64
(let* ((t_0 (/ (- 1.0 x) B)))
(if (<= x -6.8e-7)
(+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) t_0)
(if (<= x 2.6e-7) (/ 1.0 (sin B)) (+ (* B 0.16666666666666666) t_0)))))
double code(double B, double x) {
double t_0 = (1.0 - x) / B;
double tmp;
if (x <= -6.8e-7) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0;
} else if (x <= 2.6e-7) {
tmp = 1.0 / sin(B);
} else {
tmp = (B * 0.16666666666666666) + t_0;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 - x) / b
if (x <= (-6.8d-7)) then
tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + t_0
else if (x <= 2.6d-7) then
tmp = 1.0d0 / sin(b)
else
tmp = (b * 0.16666666666666666d0) + t_0
end if
code = tmp
end function
public static double code(double B, double x) {
double t_0 = (1.0 - x) / B;
double tmp;
if (x <= -6.8e-7) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0;
} else if (x <= 2.6e-7) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (B * 0.16666666666666666) + t_0;
}
return tmp;
}
def code(B, x): t_0 = (1.0 - x) / B tmp = 0 if x <= -6.8e-7: tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0 elif x <= 2.6e-7: tmp = 1.0 / math.sin(B) else: tmp = (B * 0.16666666666666666) + t_0 return tmp
function code(B, x) t_0 = Float64(Float64(1.0 - x) / B) tmp = 0.0 if (x <= -6.8e-7) tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + t_0); elseif (x <= 2.6e-7) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(B * 0.16666666666666666) + t_0); end return tmp end
function tmp_2 = code(B, x) t_0 = (1.0 - x) / B; tmp = 0.0; if (x <= -6.8e-7) tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0; elseif (x <= 2.6e-7) tmp = 1.0 / sin(B); else tmp = (B * 0.16666666666666666) + t_0; end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]}, If[LessEqual[x, -6.8e-7], N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[x, 2.6e-7], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(B * 0.16666666666666666), $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 - x}{B}\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{-7}:\\
\;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + t_0\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;B \cdot 0.16666666666666666 + t_0\\
\end{array}
\end{array}
if x < -6.79999999999999948e-7Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in B around 0 53.5%
+-commutative53.5%
mul-1-neg53.5%
sub-neg53.5%
associate--l+53.5%
*-commutative53.5%
*-commutative53.5%
div-sub53.5%
Simplified53.5%
if -6.79999999999999948e-7 < x < 2.59999999999999999e-7Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 98.6%
if 2.59999999999999999e-7 < x Initial program 99.5%
+-commutative99.5%
unsub-neg99.5%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in B around 0 72.2%
Taylor expanded in B around 0 54.3%
associate--l+54.3%
*-commutative54.3%
sub-div54.3%
Applied egg-rr54.3%
Final simplification76.1%
(FPCore (B x) :precision binary64 (/ (- 1.0 x) (sin B)))
double code(double B, double x) {
return (1.0 - x) / sin(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - x) / sin(b)
end function
public static double code(double B, double x) {
return (1.0 - x) / Math.sin(B);
}
def code(B, x): return (1.0 - x) / math.sin(B)
function code(B, x) return Float64(Float64(1.0 - x) / sin(B)) end
function tmp = code(B, x) tmp = (1.0 - x) / sin(B); end
code[B_, x_] := N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{\sin B}
\end{array}
Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.7%
*-commutative99.7%
div-sub99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in B around 0 78.6%
Final simplification78.6%
(FPCore (B x) :precision binary64 (- (/ 1.0 B) (+ (/ x B) (* (* B x) -0.3333333333333333))))
double code(double B, double x) {
return (1.0 / B) - ((x / B) + ((B * x) * -0.3333333333333333));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / b) - ((x / b) + ((b * x) * (-0.3333333333333333d0)))
end function
public static double code(double B, double x) {
return (1.0 / B) - ((x / B) + ((B * x) * -0.3333333333333333));
}
def code(B, x): return (1.0 / B) - ((x / B) + ((B * x) * -0.3333333333333333))
function code(B, x) return Float64(Float64(1.0 / B) - Float64(Float64(x / B) + Float64(Float64(B * x) * -0.3333333333333333))) end
function tmp = code(B, x) tmp = (1.0 / B) - ((x / B) + ((B * x) * -0.3333333333333333)); end
code[B_, x_] := N[(N[(1.0 / B), $MachinePrecision] - N[(N[(x / B), $MachinePrecision] + N[(N[(B * x), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{B} - \left(\frac{x}{B} + \left(B \cdot x\right) \cdot -0.3333333333333333\right)
\end{array}
Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 62.1%
Taylor expanded in B around 0 52.6%
*-commutative52.6%
Simplified52.6%
Taylor expanded in B around 0 52.8%
Final simplification52.8%
(FPCore (B x) :precision binary64 (if (or (<= x -1.0) (not (<= x 32.0))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(x <= 32.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 <= 32.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 <= 32.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.0) or not (x <= 32.0): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.0) || !(x <= 32.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 <= 32.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, 32.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 32\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1 or 32 < x Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in B around 0 53.1%
mul-1-neg53.1%
sub-neg53.1%
Simplified53.1%
Taylor expanded in x around inf 52.6%
neg-mul-152.6%
distribute-neg-frac52.6%
Simplified52.6%
if -1 < x < 32Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 52.2%
mul-1-neg52.2%
sub-neg52.2%
Simplified52.2%
Taylor expanded in x around 0 51.0%
Final simplification51.8%
(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.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 52.6%
mul-1-neg52.6%
sub-neg52.6%
Simplified52.6%
Final simplification52.6%
(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.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 62.1%
Taylor expanded in B around inf 3.1%
*-commutative3.1%
Simplified3.1%
Final simplification3.1%
(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.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 52.6%
mul-1-neg52.6%
sub-neg52.6%
Simplified52.6%
Taylor expanded in x around 0 27.3%
Final simplification27.3%
herbie shell --seed 2023258
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))