
(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 (- (/ 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 (or (<= x -1.45e-9) (not (<= x 1.3e-9))) (* x (/ (+ (/ 1.0 x) -1.0) (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.45e-9) || !(x <= 1.3e-9)) {
tmp = x * (((1.0 / x) + -1.0) / 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.45d-9)) .or. (.not. (x <= 1.3d-9))) then
tmp = x * (((1.0d0 / x) + (-1.0d0)) / 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.45e-9) || !(x <= 1.3e-9)) {
tmp = x * (((1.0 / x) + -1.0) / Math.tan(B));
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.45e-9) or not (x <= 1.3e-9): tmp = x * (((1.0 / x) + -1.0) / math.tan(B)) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.45e-9) || !(x <= 1.3e-9)) tmp = Float64(x * Float64(Float64(Float64(1.0 / x) + -1.0) / 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.45e-9) || ~((x <= 1.3e-9))) tmp = x * (((1.0 / x) + -1.0) / tan(B)); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.45e-9], N[Not[LessEqual[x, 1.3e-9]], $MachinePrecision]], N[(x * N[(N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / 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.45 \cdot 10^{-9} \lor \neg \left(x \leq 1.3 \cdot 10^{-9}\right):\\
\;\;\;\;x \cdot \frac{\frac{1}{x} + -1}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.44999999999999996e-9 or 1.3000000000000001e-9 < x Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
div-inv99.8%
clear-num99.7%
frac-sub88.8%
*-un-lft-identity88.8%
*-commutative88.8%
*-un-lft-identity88.8%
Applied egg-rr88.8%
associate-/r*99.7%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in B around 0 97.6%
if -1.44999999999999996e-9 < x < 1.3000000000000001e-9Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 99.4%
Final simplification98.5%
(FPCore (B x) :precision binary64 (if (or (<= x -6.6e-8) (not (<= x 1.4e-9))) (/ (* x (+ (/ 1.0 x) -1.0)) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -6.6e-8) || !(x <= 1.4e-9)) {
tmp = (x * ((1.0 / x) + -1.0)) / 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 <= (-6.6d-8)) .or. (.not. (x <= 1.4d-9))) then
tmp = (x * ((1.0d0 / x) + (-1.0d0))) / 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 <= -6.6e-8) || !(x <= 1.4e-9)) {
tmp = (x * ((1.0 / x) + -1.0)) / Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -6.6e-8) or not (x <= 1.4e-9): tmp = (x * ((1.0 / x) + -1.0)) / math.tan(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -6.6e-8) || !(x <= 1.4e-9)) tmp = Float64(Float64(x * Float64(Float64(1.0 / x) + -1.0)) / tan(B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -6.6e-8) || ~((x <= 1.4e-9))) tmp = (x * ((1.0 / x) + -1.0)) / tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -6.6e-8], N[Not[LessEqual[x, 1.4e-9]], $MachinePrecision]], N[(N[(x * N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.6 \cdot 10^{-8} \lor \neg \left(x \leq 1.4 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{x \cdot \left(\frac{1}{x} + -1\right)}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -6.59999999999999954e-8 or 1.39999999999999992e-9 < x Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
div-inv99.8%
clear-num99.7%
frac-sub88.8%
*-un-lft-identity88.8%
*-commutative88.8%
*-un-lft-identity88.8%
Applied egg-rr88.8%
associate-/r*99.7%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in B around 0 97.6%
associate-*l/97.7%
sub-neg97.7%
metadata-eval97.7%
Applied egg-rr97.7%
if -6.59999999999999954e-8 < x < 1.39999999999999992e-9Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 99.4%
Final simplification98.5%
(FPCore (B x) :precision binary64 (if (or (<= x -2.0) (not (<= x 4.5))) (/ (* x (+ (/ 1.0 x) -1.0)) (tan B)) (+ (/ 1.0 (sin B)) (* x (/ -1.0 B)))))
double code(double B, double x) {
double tmp;
if ((x <= -2.0) || !(x <= 4.5)) {
tmp = (x * ((1.0 / x) + -1.0)) / tan(B);
} else {
tmp = (1.0 / sin(B)) + (x * (-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 <= (-2.0d0)) .or. (.not. (x <= 4.5d0))) then
tmp = (x * ((1.0d0 / x) + (-1.0d0))) / tan(b)
else
tmp = (1.0d0 / sin(b)) + (x * ((-1.0d0) / b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -2.0) || !(x <= 4.5)) {
tmp = (x * ((1.0 / x) + -1.0)) / Math.tan(B);
} else {
tmp = (1.0 / Math.sin(B)) + (x * (-1.0 / B));
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2.0) or not (x <= 4.5): tmp = (x * ((1.0 / x) + -1.0)) / math.tan(B) else: tmp = (1.0 / math.sin(B)) + (x * (-1.0 / B)) return tmp
function code(B, x) tmp = 0.0 if ((x <= -2.0) || !(x <= 4.5)) tmp = Float64(Float64(x * Float64(Float64(1.0 / x) + -1.0)) / tan(B)); else tmp = Float64(Float64(1.0 / sin(B)) + Float64(x * Float64(-1.0 / B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -2.0) || ~((x <= 4.5))) tmp = (x * ((1.0 / x) + -1.0)) / tan(B); else tmp = (1.0 / sin(B)) + (x * (-1.0 / B)); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2.0], N[Not[LessEqual[x, 4.5]], $MachinePrecision]], N[(N[(x * N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[(x * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \lor \neg \left(x \leq 4.5\right):\\
\;\;\;\;\frac{x \cdot \left(\frac{1}{x} + -1\right)}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} + x \cdot \frac{-1}{B}\\
\end{array}
\end{array}
if x < -2 or 4.5 < x Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
div-inv99.8%
clear-num99.7%
frac-sub89.2%
*-un-lft-identity89.2%
*-commutative89.2%
*-un-lft-identity89.2%
Applied egg-rr89.2%
associate-/r*99.7%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in B around 0 98.3%
associate-*l/98.4%
sub-neg98.4%
metadata-eval98.4%
Applied egg-rr98.4%
if -2 < x < 4.5Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 99.1%
Final simplification98.7%
(FPCore (B x) :precision binary64 (if (or (<= x -2.0) (not (<= x 1.0))) (* x (/ -1.0 (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -2.0) || !(x <= 1.0)) {
tmp = x * (-1.0 / tan(B));
} else {
tmp = 1.0 / sin(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-2.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = x * ((-1.0d0) / tan(b))
else
tmp = 1.0d0 / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -2.0) || !(x <= 1.0)) {
tmp = x * (-1.0 / Math.tan(B));
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2.0) or not (x <= 1.0): tmp = x * (-1.0 / math.tan(B)) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -2.0) || !(x <= 1.0)) tmp = Float64(x * Float64(-1.0 / tan(B))); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -2.0) || ~((x <= 1.0))) tmp = x * (-1.0 / tan(B)); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;x \cdot \frac{-1}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -2 or 1 < x Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
div-inv99.8%
clear-num99.7%
frac-sub89.2%
*-un-lft-identity89.2%
*-commutative89.2%
*-un-lft-identity89.2%
Applied egg-rr89.2%
associate-/r*99.7%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in x around inf 98.0%
associate-*r/98.0%
mul-1-neg98.0%
Simplified98.0%
distribute-frac-neg98.0%
neg-sub098.0%
clear-num98.0%
quot-tan98.0%
Applied egg-rr98.0%
neg-sub098.0%
distribute-neg-frac98.0%
metadata-eval98.0%
Simplified98.0%
if -2 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 97.7%
Final simplification97.8%
(FPCore (B x) :precision binary64 (if (<= x -1.35) (/ -1.0 (/ 1.0 (/ x (tan B)))) (if (<= x 1.0) (/ 1.0 (sin B)) (* x (/ -1.0 (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -1.35) {
tmp = -1.0 / (1.0 / (x / tan(B)));
} else if (x <= 1.0) {
tmp = 1.0 / sin(B);
} else {
tmp = x * (-1.0 / 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 <= (-1.35d0)) then
tmp = (-1.0d0) / (1.0d0 / (x / tan(b)))
else if (x <= 1.0d0) then
tmp = 1.0d0 / sin(b)
else
tmp = x * ((-1.0d0) / tan(b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.35) {
tmp = -1.0 / (1.0 / (x / Math.tan(B)));
} else if (x <= 1.0) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = x * (-1.0 / Math.tan(B));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.35: tmp = -1.0 / (1.0 / (x / math.tan(B))) elif x <= 1.0: tmp = 1.0 / math.sin(B) else: tmp = x * (-1.0 / math.tan(B)) return tmp
function code(B, x) tmp = 0.0 if (x <= -1.35) tmp = Float64(-1.0 / Float64(1.0 / Float64(x / tan(B)))); elseif (x <= 1.0) tmp = Float64(1.0 / sin(B)); else tmp = Float64(x * Float64(-1.0 / tan(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.35) tmp = -1.0 / (1.0 / (x / tan(B))); elseif (x <= 1.0) tmp = 1.0 / sin(B); else tmp = x * (-1.0 / tan(B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.35], N[(-1.0 / N[(1.0 / N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35:\\
\;\;\;\;\frac{-1}{\frac{1}{\frac{x}{\tan B}}}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B}\\
\end{array}
\end{array}
if x < -1.3500000000000001Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
div-inv99.8%
clear-num99.7%
frac-sub87.7%
*-un-lft-identity87.7%
*-commutative87.7%
*-un-lft-identity87.7%
Applied egg-rr87.7%
associate-/r*99.7%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in x around inf 96.5%
associate-*r/96.5%
mul-1-neg96.5%
Simplified96.5%
distribute-frac-neg96.5%
distribute-lft-neg-in96.5%
associate-/r/96.5%
clear-num96.4%
distribute-neg-frac96.4%
metadata-eval96.4%
clear-num96.5%
add-sqr-sqrt76.2%
sqrt-unprod76.4%
sqr-neg76.4%
sqrt-unprod0.1%
add-sqr-sqrt0.5%
associate-/l*0.5%
associate-*l/0.5%
clear-num0.5%
associate-*l/0.5%
*-un-lft-identity0.5%
add-sqr-sqrt0.1%
sqrt-unprod76.5%
sqr-neg76.5%
Applied egg-rr96.5%
if -1.3500000000000001 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 97.7%
if 1 < x Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
div-inv99.8%
clear-num99.8%
frac-sub90.8%
*-un-lft-identity90.8%
*-commutative90.8%
*-un-lft-identity90.8%
Applied egg-rr90.8%
associate-/r*99.8%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in x around inf 99.7%
associate-*r/99.7%
mul-1-neg99.7%
Simplified99.7%
distribute-frac-neg99.7%
neg-sub099.7%
clear-num99.7%
quot-tan99.7%
Applied egg-rr99.7%
neg-sub099.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification97.9%
(FPCore (B x)
:precision binary64
(if (or (<= B -3.4e+21) (not (<= B 0.00082)))
(/ 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 <= -3.4e+21) || !(B <= 0.00082)) {
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 <= (-3.4d+21)) .or. (.not. (b <= 0.00082d0))) 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 <= -3.4e+21) || !(B <= 0.00082)) {
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 <= -3.4e+21) or not (B <= 0.00082): 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 <= -3.4e+21) || !(B <= 0.00082)) 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 <= -3.4e+21) || ~((B <= 0.00082))) 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, -3.4e+21], N[Not[LessEqual[B, 0.00082]], $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 -3.4 \cdot 10^{+21} \lor \neg \left(B \leq 0.00082\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 < -3.4e21 or 8.1999999999999998e-4 < B Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in x around 0 52.7%
if -3.4e21 < B < 8.1999999999999998e-4Initial program 99.9%
+-commutative99.9%
unsub-neg99.9%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
Taylor expanded in B around 0 95.4%
Final simplification76.0%
(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.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 54.0%
Final simplification54.0%
(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 54.0%
+-commutative54.0%
mul-1-neg54.0%
sub-neg54.0%
associate--l+54.0%
*-commutative54.0%
*-commutative54.0%
div-sub54.0%
Simplified54.0%
Final simplification54.0%
(FPCore (B x) :precision binary64 (- (+ (/ 1.0 B) (* B 0.16666666666666666)) (/ x B)))
double code(double B, double x) {
return ((1.0 / B) + (B * 0.16666666666666666)) - (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 / b)
end function
public static double code(double B, double x) {
return ((1.0 / B) + (B * 0.16666666666666666)) - (x / B);
}
def code(B, x): return ((1.0 / B) + (B * 0.16666666666666666)) - (x / B)
function code(B, x) return Float64(Float64(Float64(1.0 / B) + Float64(B * 0.16666666666666666)) - Float64(x / B)) end
function tmp = code(B, x) tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / B); end
code[B_, x_] := N[(N[(N[(1.0 / B), $MachinePrecision] + N[(B * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{B} + B \cdot 0.16666666666666666\right) - \frac{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 67.5%
Taylor expanded in B around 0 53.9%
Final simplification53.9%
(FPCore (B x) :precision binary64 (if (or (<= x -0.00112) (not (<= x 5.2e+22))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -0.00112) || !(x <= 5.2e+22)) {
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.00112d0)) .or. (.not. (x <= 5.2d+22))) 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.00112) || !(x <= 5.2e+22)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.00112) or not (x <= 5.2e+22): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.00112) || !(x <= 5.2e+22)) 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.00112) || ~((x <= 5.2e+22))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.00112], N[Not[LessEqual[x, 5.2e+22]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00112 \lor \neg \left(x \leq 5.2 \cdot 10^{+22}\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -0.0011199999999999999 or 5.2e22 < x Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
div-inv99.8%
clear-num99.7%
frac-sub89.1%
*-un-lft-identity89.1%
*-commutative89.1%
*-un-lft-identity89.1%
Applied egg-rr89.1%
associate-/r*99.7%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in x around inf 97.2%
associate-*r/97.2%
mul-1-neg97.2%
Simplified97.2%
Taylor expanded in B around 0 53.4%
associate-*r/53.4%
neg-mul-153.4%
Simplified53.4%
if -0.0011199999999999999 < x < 5.2e22Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 53.7%
mul-1-neg53.7%
sub-neg53.7%
Simplified53.7%
Taylor expanded in x around 0 52.3%
Final simplification52.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%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 53.7%
mul-1-neg53.7%
sub-neg53.7%
Simplified53.7%
Final simplification53.7%
(FPCore (B x) :precision binary64 (/ 1.0 B))
double code(double B, double x) {
return 1.0 / B;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = 1.0d0 / b
end function
public static double code(double B, double x) {
return 1.0 / B;
}
def code(B, x): return 1.0 / B
function code(B, x) return Float64(1.0 / B) end
function tmp = code(B, x) tmp = 1.0 / B; end
code[B_, x_] := N[(1.0 / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 53.7%
mul-1-neg53.7%
sub-neg53.7%
Simplified53.7%
Taylor expanded in x around 0 27.3%
Final simplification27.3%
herbie shell --seed 2023193
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))