
(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 11 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%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x)
:precision binary64
(if (<= x -2100.0)
(/ (- x) (tan B))
(if (<= x 165000.0)
(- (/ 1.0 (sin B)) (/ x B))
(/ (* x (- (cos B))) (sin B)))))
double code(double B, double x) {
double tmp;
if (x <= -2100.0) {
tmp = -x / tan(B);
} else if (x <= 165000.0) {
tmp = (1.0 / sin(B)) - (x / 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 <= (-2100.0d0)) then
tmp = -x / tan(b)
else if (x <= 165000.0d0) then
tmp = (1.0d0 / sin(b)) - (x / 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 <= -2100.0) {
tmp = -x / Math.tan(B);
} else if (x <= 165000.0) {
tmp = (1.0 / Math.sin(B)) - (x / B);
} else {
tmp = (x * -Math.cos(B)) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -2100.0: tmp = -x / math.tan(B) elif x <= 165000.0: tmp = (1.0 / math.sin(B)) - (x / B) else: tmp = (x * -math.cos(B)) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -2100.0) tmp = Float64(Float64(-x) / tan(B)); elseif (x <= 165000.0) tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / 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 <= -2100.0) tmp = -x / tan(B); elseif (x <= 165000.0) tmp = (1.0 / sin(B)) - (x / B); else tmp = (x * -cos(B)) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -2100.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 165000.0], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / 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 -2100:\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{elif}\;x \leq 165000:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\
\end{array}
\end{array}
if x < -2100Initial program 99.5%
distribute-lft-neg-in99.5%
+-commutative99.5%
cancel-sign-sub-inv99.5%
*-commutative99.5%
*-commutative99.5%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
add-log-exp75.2%
Applied egg-rr75.2%
rem-log-exp99.7%
tan-quot99.6%
add-sqr-sqrt79.1%
sqrt-unprod79.4%
sqr-neg79.4%
sqrt-unprod0.1%
add-sqr-sqrt0.5%
associate-/l*0.5%
div-inv0.5%
add-sqr-sqrt0.1%
sqrt-unprod79.1%
sqr-neg79.1%
sqrt-unprod79.0%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 97.8%
associate-*r/97.8%
neg-mul-197.8%
distribute-lft-neg-in97.8%
Simplified97.8%
associate-/l*97.9%
neg-sub097.9%
div-sub97.9%
quot-tan97.9%
quot-tan98.0%
Applied egg-rr98.0%
div-sub98.0%
neg-sub098.0%
Simplified98.0%
if -2100 < x < 165000Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.2%
if 165000 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-log-exp63.1%
Applied egg-rr63.1%
rem-log-exp99.8%
tan-quot99.7%
add-sqr-sqrt74.7%
sqrt-unprod75.0%
sqr-neg75.0%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
associate-/l*0.5%
div-inv0.5%
add-sqr-sqrt0.2%
sqrt-unprod74.8%
sqr-neg74.8%
sqrt-unprod74.5%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 99.3%
associate-*r/99.3%
neg-mul-199.3%
distribute-lft-neg-in99.3%
Simplified99.3%
Final simplification98.9%
(FPCore (B x) :precision binary64 (if (or (<= x -760.0) (not (<= x 450000.0))) (/ (- x) (tan B)) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -760.0) || !(x <= 450000.0)) {
tmp = -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 <= (-760.0d0)) .or. (.not. (x <= 450000.0d0))) then
tmp = -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 <= -760.0) || !(x <= 450000.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 / Math.sin(B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -760.0) or not (x <= 450000.0): tmp = -x / math.tan(B) else: tmp = (1.0 / math.sin(B)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -760.0) || !(x <= 450000.0)) tmp = Float64(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 <= -760.0) || ~((x <= 450000.0))) tmp = -x / tan(B); else tmp = (1.0 / sin(B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -760.0], N[Not[LessEqual[x, 450000.0]], $MachinePrecision]], N[((-x) / N[Tan[B], $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 -760 \lor \neg \left(x \leq 450000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -760 or 4.5e5 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-log-exp69.3%
Applied egg-rr69.3%
rem-log-exp99.8%
tan-quot99.7%
add-sqr-sqrt77.0%
sqrt-unprod77.3%
sqr-neg77.3%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
associate-/l*0.5%
div-inv0.5%
add-sqr-sqrt0.2%
sqrt-unprod77.0%
sqr-neg77.0%
sqrt-unprod76.8%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
neg-mul-198.5%
distribute-lft-neg-in98.5%
Simplified98.5%
associate-/l*98.6%
neg-sub098.6%
div-sub98.6%
quot-tan98.6%
quot-tan98.6%
Applied egg-rr98.6%
div-sub98.6%
neg-sub098.6%
Simplified98.6%
if -760 < x < 4.5e5Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.2%
Final simplification98.9%
(FPCore (B x) :precision binary64 (if (or (<= x -2500.0) (not (<= x 9000000.0))) (/ (- x) (tan B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -2500.0) || !(x <= 9000000.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 <= (-2500.0d0)) .or. (.not. (x <= 9000000.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 <= -2500.0) || !(x <= 9000000.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2500.0) or not (x <= 9000000.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 <= -2500.0) || !(x <= 9000000.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 <= -2500.0) || ~((x <= 9000000.0))) tmp = -x / tan(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2500.0], N[Not[LessEqual[x, 9000000.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 -2500 \lor \neg \left(x \leq 9000000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -2500 or 9e6 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-log-exp69.3%
Applied egg-rr69.3%
rem-log-exp99.8%
tan-quot99.7%
add-sqr-sqrt77.0%
sqrt-unprod77.3%
sqr-neg77.3%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
associate-/l*0.5%
div-inv0.5%
add-sqr-sqrt0.2%
sqrt-unprod77.0%
sqr-neg77.0%
sqrt-unprod76.8%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
neg-mul-198.5%
distribute-lft-neg-in98.5%
Simplified98.5%
associate-/l*98.6%
neg-sub098.6%
div-sub98.6%
quot-tan98.6%
quot-tan98.6%
Applied egg-rr98.6%
div-sub98.6%
neg-sub098.6%
Simplified98.6%
if -2500 < x < 9e6Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-log-exp59.6%
Applied egg-rr59.6%
rem-log-exp99.8%
tan-quot99.8%
add-sqr-sqrt73.3%
sqrt-unprod99.4%
sqr-neg99.4%
sqrt-unprod26.1%
add-sqr-sqrt97.6%
associate-/l*97.6%
div-inv97.6%
add-sqr-sqrt26.1%
sqrt-unprod99.4%
sqr-neg99.4%
sqrt-unprod73.3%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 99.1%
Final simplification98.9%
(FPCore (B x) :precision binary64 (if (or (<= x -1.9) (not (<= x 1.1))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.9) || !(x <= 1.1)) {
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.9d0)) .or. (.not. (x <= 1.1d0))) 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.9) || !(x <= 1.1)) {
tmp = -x / Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.9) or not (x <= 1.1): tmp = -x / math.tan(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.9) || !(x <= 1.1)) 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.9) || ~((x <= 1.1))) tmp = -x / tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.9], N[Not[LessEqual[x, 1.1]], $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.9 \lor \neg \left(x \leq 1.1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.8999999999999999 or 1.1000000000000001 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-log-exp69.3%
Applied egg-rr69.3%
rem-log-exp99.8%
tan-quot99.7%
add-sqr-sqrt77.0%
sqrt-unprod77.3%
sqr-neg77.3%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
associate-/l*0.5%
div-inv0.5%
add-sqr-sqrt0.2%
sqrt-unprod77.0%
sqr-neg77.0%
sqrt-unprod76.8%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
neg-mul-198.5%
distribute-lft-neg-in98.5%
Simplified98.5%
associate-/l*98.6%
neg-sub098.6%
div-sub98.6%
quot-tan98.6%
quot-tan98.6%
Applied egg-rr98.6%
div-sub98.6%
neg-sub098.6%
Simplified98.6%
if -1.8999999999999999 < x < 1.1000000000000001Initial program 99.8%
Taylor expanded in x around 0 97.7%
Final simplification98.2%
(FPCore (B x)
:precision binary64
(if (<= B 2.1)
(-
(+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ 1.0 B))
(/ x B))
(/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 2.1) {
tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / 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 (b <= 2.1d0) then
tmp = ((b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + (1.0d0 / b)) - (x / b)
else
tmp = 1.0d0 / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= 2.1) {
tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 2.1: tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 2.1) tmp = Float64(Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(1.0 / B)) - Float64(x / B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= 2.1) tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 2.1], N[(N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / B), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 2.1:\\
\;\;\;\;\left(B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1}{B}\right) - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 2.10000000000000009Initial program 99.7%
Taylor expanded in B around 0 62.1%
if 2.10000000000000009 < B Initial program 99.4%
Taylor expanded in x around 0 43.1%
Final simplification56.7%
(FPCore (B x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (- (/ x B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -(x / B);
} else {
tmp = 1.0 / B;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = -(x / b)
else
tmp = 1.0d0 / b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -(x / B);
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -(x / B) else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-Float64(x / B)); else tmp = Float64(1.0 / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = -(x / B); else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], (-N[(x / B), $MachinePrecision]), N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;-\frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 99.6%
Taylor expanded in B around 0 45.3%
Taylor expanded in x around inf 45.3%
mul-1-neg45.3%
distribute-frac-neg45.3%
Simplified45.3%
if -1 < x < 1Initial program 99.8%
Taylor expanded in B around 0 45.6%
Taylor expanded in x around 0 44.1%
Final simplification44.7%
(FPCore (B x) :precision binary64 (+ (* B 0.16666666666666666) (/ (- 1.0 x) B)))
double code(double B, double x) {
return (B * 0.16666666666666666) + ((1.0 - x) / B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (b * 0.16666666666666666d0) + ((1.0d0 - x) / b)
end function
public static double code(double B, double x) {
return (B * 0.16666666666666666) + ((1.0 - x) / B);
}
def code(B, x): return (B * 0.16666666666666666) + ((1.0 - x) / B)
function code(B, x) return Float64(Float64(B * 0.16666666666666666) + Float64(Float64(1.0 - x) / B)) end
function tmp = code(B, x) tmp = (B * 0.16666666666666666) + ((1.0 - x) / B); end
code[B_, x_] := N[(N[(B * 0.16666666666666666), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
B \cdot 0.16666666666666666 + \frac{1 - x}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 71.6%
Taylor expanded in B around 0 45.5%
associate--l+45.5%
*-commutative45.5%
div-sub45.5%
Simplified45.5%
Final simplification45.5%
(FPCore (B x) :precision binary64 (- (/ 1.0 B) (/ x B)))
double code(double B, double x) {
return (1.0 / B) - (x / B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / b) - (x / b)
end function
public static double code(double B, double x) {
return (1.0 / B) - (x / B);
}
def code(B, x): return (1.0 / B) - (x / B)
function code(B, x) return Float64(Float64(1.0 / B) - Float64(x / B)) end
function tmp = code(B, x) tmp = (1.0 / B) - (x / B); end
code[B_, x_] := N[(N[(1.0 / B), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{B} - \frac{x}{B}
\end{array}
Initial program 99.7%
Taylor expanded in B around 0 45.5%
div-sub45.5%
Applied egg-rr45.5%
Final simplification45.5%
(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%
Taylor expanded in B around 0 45.5%
Final simplification45.5%
(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%
Taylor expanded in B around 0 45.5%
Taylor expanded in x around 0 22.8%
Final simplification22.8%
herbie shell --seed 2024021
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))