
(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.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (B x)
:precision binary64
(if (<= x -1.45)
(/ (+ (/ 1.0 x) -1.0) (/ (tan B) x))
(if (<= x 1800000000.0)
(- (/ 1.0 (sin B)) (/ x (sin B)))
(/ (* x (- (cos B))) (sin B)))))
double code(double B, double x) {
double tmp;
if (x <= -1.45) {
tmp = ((1.0 / x) + -1.0) / (tan(B) / x);
} else if (x <= 1800000000.0) {
tmp = (1.0 / sin(B)) - (x / sin(B));
} else {
tmp = (x * -cos(B)) / 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.45d0)) then
tmp = ((1.0d0 / x) + (-1.0d0)) / (tan(b) / x)
else if (x <= 1800000000.0d0) then
tmp = (1.0d0 / sin(b)) - (x / sin(b))
else
tmp = (x * -cos(b)) / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.45) {
tmp = ((1.0 / x) + -1.0) / (Math.tan(B) / x);
} else if (x <= 1800000000.0) {
tmp = (1.0 / Math.sin(B)) - (x / Math.sin(B));
} else {
tmp = (x * -Math.cos(B)) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.45: tmp = ((1.0 / x) + -1.0) / (math.tan(B) / x) elif x <= 1800000000.0: tmp = (1.0 / math.sin(B)) - (x / math.sin(B)) else: tmp = (x * -math.cos(B)) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -1.45) tmp = Float64(Float64(Float64(1.0 / x) + -1.0) / Float64(tan(B) / x)); elseif (x <= 1800000000.0) tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / sin(B))); else tmp = Float64(Float64(x * Float64(-cos(B))) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.45) tmp = ((1.0 / x) + -1.0) / (tan(B) / x); elseif (x <= 1800000000.0) tmp = (1.0 / sin(B)) - (x / sin(B)); else tmp = (x * -cos(B)) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.45], N[(N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1800000000.0], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * (-N[Cos[B], $MachinePrecision])), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45:\\
\;\;\;\;\frac{\frac{1}{x} + -1}{\frac{\tan B}{x}}\\
\mathbf{elif}\;x \leq 1800000000:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\
\end{array}
\end{array}
if x < -1.44999999999999996Initial program 99.5%
distribute-lft-neg-in99.5%
+-commutative99.5%
distribute-lft-neg-in99.5%
distribute-rgt-neg-in99.5%
Simplified99.5%
distribute-rgt-neg-out99.5%
div-inv99.8%
sub-neg99.8%
clear-num99.5%
frac-sub87.5%
*-un-lft-identity87.5%
*-commutative87.5%
*-un-lft-identity87.5%
Applied egg-rr87.5%
associate-/r*99.5%
div-sub99.5%
*-inverses99.5%
Simplified99.5%
Taylor expanded in B around 0 95.5%
if -1.44999999999999996 < x < 1.8e9Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in B around 0 98.6%
if 1.8e9 < x Initial program 99.3%
distribute-lft-neg-in99.3%
+-commutative99.3%
cancel-sign-sub-inv99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
associate-*r/99.3%
Simplified99.3%
Taylor expanded in x around 0 99.7%
Final simplification98.0%
(FPCore (B x) :precision binary64 (if (<= x -1.4) (/ (+ (/ 1.0 x) -1.0) (/ (tan B) x)) (if (<= x 23000.0) (/ (- 1.0 x) (sin B)) (/ (* x (- (cos B))) (sin B)))))
double code(double B, double x) {
double tmp;
if (x <= -1.4) {
tmp = ((1.0 / x) + -1.0) / (tan(B) / x);
} else if (x <= 23000.0) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (x * -cos(B)) / 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.4d0)) then
tmp = ((1.0d0 / x) + (-1.0d0)) / (tan(b) / x)
else if (x <= 23000.0d0) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = (x * -cos(b)) / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.4) {
tmp = ((1.0 / x) + -1.0) / (Math.tan(B) / x);
} else if (x <= 23000.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = (x * -Math.cos(B)) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.4: tmp = ((1.0 / x) + -1.0) / (math.tan(B) / x) elif x <= 23000.0: tmp = (1.0 - x) / math.sin(B) else: tmp = (x * -math.cos(B)) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -1.4) tmp = Float64(Float64(Float64(1.0 / x) + -1.0) / Float64(tan(B) / x)); elseif (x <= 23000.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(x * Float64(-cos(B))) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.4) tmp = ((1.0 / x) + -1.0) / (tan(B) / x); elseif (x <= 23000.0) tmp = (1.0 - x) / sin(B); else tmp = (x * -cos(B)) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.4], N[(N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 23000.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(x * (-N[Cos[B], $MachinePrecision])), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4:\\
\;\;\;\;\frac{\frac{1}{x} + -1}{\frac{\tan B}{x}}\\
\mathbf{elif}\;x \leq 23000:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\
\end{array}
\end{array}
if x < -1.3999999999999999Initial program 99.5%
distribute-lft-neg-in99.5%
+-commutative99.5%
distribute-lft-neg-in99.5%
distribute-rgt-neg-in99.5%
Simplified99.5%
distribute-rgt-neg-out99.5%
div-inv99.8%
sub-neg99.8%
clear-num99.5%
frac-sub87.5%
*-un-lft-identity87.5%
*-commutative87.5%
*-un-lft-identity87.5%
Applied egg-rr87.5%
associate-/r*99.5%
div-sub99.5%
*-inverses99.5%
Simplified99.5%
Taylor expanded in B around 0 95.5%
if -1.3999999999999999 < x < 23000Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around 0 99.7%
+-commutative99.7%
mul-1-neg99.7%
sub-neg99.7%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 98.6%
if 23000 < x Initial program 99.3%
distribute-lft-neg-in99.3%
+-commutative99.3%
cancel-sign-sub-inv99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
associate-*r/99.3%
Simplified99.3%
Taylor expanded in x around 0 99.7%
Final simplification98.0%
(FPCore (B x) :precision binary64 (if (or (<= x -500000000.0) (not (<= x 65000000.0))) (/ (- x) (tan B)) (* (/ 1.0 (sin B)) (- 1.0 x))))
double code(double B, double x) {
double tmp;
if ((x <= -500000000.0) || !(x <= 65000000.0)) {
tmp = -x / tan(B);
} else {
tmp = (1.0 / sin(B)) * (1.0 - x);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-500000000.0d0)) .or. (.not. (x <= 65000000.0d0))) then
tmp = -x / tan(b)
else
tmp = (1.0d0 / sin(b)) * (1.0d0 - x)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -500000000.0) || !(x <= 65000000.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 / Math.sin(B)) * (1.0 - x);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -500000000.0) or not (x <= 65000000.0): tmp = -x / math.tan(B) else: tmp = (1.0 / math.sin(B)) * (1.0 - x) return tmp
function code(B, x) tmp = 0.0 if ((x <= -500000000.0) || !(x <= 65000000.0)) tmp = Float64(Float64(-x) / tan(B)); else tmp = Float64(Float64(1.0 / sin(B)) * Float64(1.0 - x)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -500000000.0) || ~((x <= 65000000.0))) tmp = -x / tan(B); else tmp = (1.0 / sin(B)) * (1.0 - x); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -500000000.0], N[Not[LessEqual[x, 65000000.0]], $MachinePrecision]], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -500000000 \lor \neg \left(x \leq 65000000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -5e8 or 6.5e7 < x Initial program 99.4%
distribute-lft-neg-in99.4%
+-commutative99.4%
cancel-sign-sub-inv99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.6%
Taylor expanded in x around inf 99.6%
mul-1-neg99.6%
associate-*r/99.4%
Simplified99.4%
expm1-log1p-u50.1%
expm1-udef50.1%
clear-num50.1%
tan-quot50.1%
Applied egg-rr50.1%
expm1-def50.1%
expm1-log1p99.4%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
if -5e8 < x < 6.5e7Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.8%
Taylor expanded in B around 0 96.0%
*-un-lft-identity96.0%
div-inv96.0%
distribute-rgt-out--96.0%
Applied egg-rr96.0%
Final simplification97.8%
(FPCore (B x) :precision binary64 (if (<= x -1.45) (/ (+ (/ 1.0 x) -1.0) (/ (tan B) x)) (if (<= x 7400000.0) (/ (- 1.0 x) (sin B)) (/ (- x) (tan B)))))
double code(double B, double x) {
double tmp;
if (x <= -1.45) {
tmp = ((1.0 / x) + -1.0) / (tan(B) / x);
} else if (x <= 7400000.0) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = -x / tan(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.45d0)) then
tmp = ((1.0d0 / x) + (-1.0d0)) / (tan(b) / x)
else if (x <= 7400000.0d0) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = -x / tan(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.45) {
tmp = ((1.0 / x) + -1.0) / (Math.tan(B) / x);
} else if (x <= 7400000.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = -x / Math.tan(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.45: tmp = ((1.0 / x) + -1.0) / (math.tan(B) / x) elif x <= 7400000.0: tmp = (1.0 - x) / math.sin(B) else: tmp = -x / math.tan(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -1.45) tmp = Float64(Float64(Float64(1.0 / x) + -1.0) / Float64(tan(B) / x)); elseif (x <= 7400000.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(-x) / tan(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.45) tmp = ((1.0 / x) + -1.0) / (tan(B) / x); elseif (x <= 7400000.0) tmp = (1.0 - x) / sin(B); else tmp = -x / tan(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.45], N[(N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7400000.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45:\\
\;\;\;\;\frac{\frac{1}{x} + -1}{\frac{\tan B}{x}}\\
\mathbf{elif}\;x \leq 7400000:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{\tan B}\\
\end{array}
\end{array}
if x < -1.44999999999999996Initial program 99.5%
distribute-lft-neg-in99.5%
+-commutative99.5%
distribute-lft-neg-in99.5%
distribute-rgt-neg-in99.5%
Simplified99.5%
distribute-rgt-neg-out99.5%
div-inv99.8%
sub-neg99.8%
clear-num99.5%
frac-sub87.5%
*-un-lft-identity87.5%
*-commutative87.5%
*-un-lft-identity87.5%
Applied egg-rr87.5%
associate-/r*99.5%
div-sub99.5%
*-inverses99.5%
Simplified99.5%
Taylor expanded in B around 0 95.5%
if -1.44999999999999996 < x < 7.4e6Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around 0 99.7%
+-commutative99.7%
mul-1-neg99.7%
sub-neg99.7%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 98.6%
if 7.4e6 < x Initial program 99.3%
distribute-lft-neg-in99.3%
+-commutative99.3%
cancel-sign-sub-inv99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
associate-*r/99.3%
Simplified99.3%
expm1-log1p-u51.2%
expm1-udef51.2%
clear-num51.2%
tan-quot51.2%
Applied egg-rr51.2%
expm1-def51.2%
expm1-log1p99.3%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification98.0%
(FPCore (B x) :precision binary64 (if (or (<= x -100000000.0) (not (<= x 240000.0))) (/ (- x) (tan B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -100000000.0) || !(x <= 240000.0)) {
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 <= (-100000000.0d0)) .or. (.not. (x <= 240000.0d0))) 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 <= -100000000.0) || !(x <= 240000.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -100000000.0) or not (x <= 240000.0): tmp = -x / math.tan(B) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -100000000.0) || !(x <= 240000.0)) 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 <= -100000000.0) || ~((x <= 240000.0))) tmp = -x / tan(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -100000000.0], N[Not[LessEqual[x, 240000.0]], $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 -100000000 \lor \neg \left(x \leq 240000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1e8 or 2.4e5 < x Initial program 99.4%
distribute-lft-neg-in99.4%
+-commutative99.4%
cancel-sign-sub-inv99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.6%
Taylor expanded in x around inf 99.6%
mul-1-neg99.6%
associate-*r/99.4%
Simplified99.4%
expm1-log1p-u50.1%
expm1-udef50.1%
clear-num50.1%
tan-quot50.1%
Applied egg-rr50.1%
expm1-def50.1%
expm1-log1p99.4%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
if -1e8 < x < 2.4e5Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.8%
Taylor expanded in x around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
sub-neg99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 96.0%
Final simplification97.8%
(FPCore (B x) :precision binary64 (if (or (<= x -1.5) (not (<= x 1.0))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.5) || !(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.5d0)) .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.5) || !(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.5) 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.5) || !(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.5) || ~((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.5], 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.5 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.5 or 1 < x Initial program 99.4%
distribute-lft-neg-in99.4%
+-commutative99.4%
cancel-sign-sub-inv99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 96.5%
mul-1-neg96.5%
associate-*r/96.2%
Simplified96.2%
expm1-log1p-u48.2%
expm1-udef48.2%
clear-num48.2%
tan-quot48.2%
Applied egg-rr48.2%
expm1-def48.2%
expm1-log1p96.2%
associate-*r/96.5%
*-rgt-identity96.5%
Simplified96.5%
if -1.5 < x < 1Initial 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 x around 0 98.1%
Final simplification97.3%
(FPCore (B x) :precision binary64 (if (or (<= B -2.65e+20) (not (<= B 0.054))) (/ 1.0 (sin B)) (+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B))))
double code(double B, double x) {
double tmp;
if ((B <= -2.65e+20) || !(B <= 0.054)) {
tmp = 1.0 / sin(B);
} else {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - 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 <= (-2.65d+20)) .or. (.not. (b <= 0.054d0))) then
tmp = 1.0d0 / sin(b)
else
tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -2.65e+20) || !(B <= 0.054)) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -2.65e+20) or not (B <= 0.054): tmp = 1.0 / math.sin(B) else: tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B) return tmp
function code(B, x) tmp = 0.0 if ((B <= -2.65e+20) || !(B <= 0.054)) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -2.65e+20) || ~((B <= 0.054))) tmp = 1.0 / sin(B); else tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -2.65e+20], N[Not[LessEqual[B, 0.054]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -2.65 \cdot 10^{+20} \lor \neg \left(B \leq 0.054\right):\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}\\
\end{array}
\end{array}
if B < -2.65e20 or 0.0539999999999999994 < B Initial program 99.3%
distribute-lft-neg-in99.3%
+-commutative99.3%
distribute-lft-neg-in99.3%
distribute-rgt-neg-in99.3%
Simplified99.3%
Taylor expanded in x around 0 49.0%
if -2.65e20 < B < 0.0539999999999999994Initial 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 96.4%
+-commutative96.4%
mul-1-neg96.4%
sub-neg96.4%
associate--l+96.4%
*-commutative96.4%
div-sub96.4%
Simplified96.4%
Final simplification72.1%
(FPCore (B x) :precision binary64 (+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B)))
double code(double B, double x) {
return (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
end function
public static double code(double B, double x) {
return (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
}
def code(B, x): return (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B)
function code(B, x) return Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B)) end
function tmp = code(B, x) tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B); end
code[B_, x_] := N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}
\end{array}
Initial program 99.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 48.7%
+-commutative48.7%
mul-1-neg48.7%
sub-neg48.7%
associate--l+48.7%
*-commutative48.7%
div-sub48.7%
Simplified48.7%
Final simplification48.7%
(FPCore (B x) :precision binary64 (if (or (<= x -5.5) (not (<= x 1.0))) (- (/ x B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -5.5) || !(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 <= (-5.5d0)) .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 <= -5.5) || !(x <= 1.0)) {
tmp = -(x / B);
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -5.5) or not (x <= 1.0): tmp = -(x / B) else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -5.5) || !(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 <= -5.5) || ~((x <= 1.0))) tmp = -(x / B); else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -5.5], 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 -5.5 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;-\frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -5.5 or 1 < x Initial program 99.4%
distribute-lft-neg-in99.4%
+-commutative99.4%
distribute-lft-neg-in99.4%
distribute-rgt-neg-in99.4%
Simplified99.4%
Taylor expanded in B around 0 47.6%
neg-mul-147.6%
sub-neg47.6%
Simplified47.6%
Taylor expanded in x around inf 46.6%
neg-mul-146.6%
distribute-neg-frac46.6%
Simplified46.6%
if -5.5 < x < 1Initial 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.2%
neg-mul-149.2%
sub-neg49.2%
Simplified49.2%
Taylor expanded in x around 0 48.9%
Final simplification47.7%
(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%
+-commutative99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 48.4%
neg-mul-148.4%
sub-neg48.4%
Simplified48.4%
Final simplification48.4%
(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%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 62.5%
Taylor expanded in B around inf 3.2%
*-commutative3.2%
Simplified3.2%
Final simplification3.2%
(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%
+-commutative99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 48.4%
neg-mul-148.4%
sub-neg48.4%
Simplified48.4%
Taylor expanded in x around 0 25.6%
Final simplification25.6%
herbie shell --seed 2023279
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))