
(FPCore (B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x): return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B))) end
function tmp = code(B, x) tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B)); end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x): return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B))) end
function tmp = code(B, x) tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B)); end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\end{array}
(FPCore (B x) :precision binary64 (- (/ 1.0 (sin B)) (/ x (tan B))))
double code(double B, double x) {
return (1.0 / sin(B)) - (x / tan(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / sin(b)) - (x / tan(b))
end function
public static double code(double B, double x) {
return (1.0 / Math.sin(B)) - (x / Math.tan(B));
}
def code(B, x): return (1.0 / math.sin(B)) - (x / math.tan(B))
function code(B, x) return Float64(Float64(1.0 / sin(B)) - Float64(x / tan(B))) end
function tmp = code(B, x) tmp = (1.0 / sin(B)) - (x / tan(B)); end
code[B_, x_] := N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sin B} - \frac{x}{\tan B}
\end{array}
Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (or (<= x -0.72) (not (<= x 1.5))) (/ (- 1.0 x) (tan B)) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -0.72) || !(x <= 1.5)) {
tmp = (1.0 - 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 <= (-0.72d0)) .or. (.not. (x <= 1.5d0))) then
tmp = (1.0d0 - 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 <= -0.72) || !(x <= 1.5)) {
tmp = (1.0 - x) / Math.tan(B);
} else {
tmp = (1.0 / Math.sin(B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.72) or not (x <= 1.5): tmp = (1.0 - x) / math.tan(B) else: tmp = (1.0 / math.sin(B)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.72) || !(x <= 1.5)) tmp = Float64(Float64(1.0 - 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 <= -0.72) || ~((x <= 1.5))) tmp = (1.0 - x) / tan(B); else tmp = (1.0 / sin(B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.72], N[Not[LessEqual[x, 1.5]], $MachinePrecision]], N[(N[(1.0 - x), $MachinePrecision] / 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 -0.72 \lor \neg \left(x \leq 1.5\right):\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -0.71999999999999997 or 1.5 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
div-inv99.7%
frac-sub94.3%
associate-/r*99.7%
*-un-lft-identity99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in B around 0 98.6%
if -0.71999999999999997 < x < 1.5Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.2%
Final simplification98.9%
(FPCore (B x) :precision binary64 (if (or (<= x -2e-7) (not (<= x 4.3e-13))) (/ (- 1.0 x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -2e-7) || !(x <= 4.3e-13)) {
tmp = (1.0 - 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 <= (-2d-7)) .or. (.not. (x <= 4.3d-13))) then
tmp = (1.0d0 - 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 <= -2e-7) || !(x <= 4.3e-13)) {
tmp = (1.0 - x) / Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2e-7) or not (x <= 4.3e-13): tmp = (1.0 - x) / math.tan(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -2e-7) || !(x <= 4.3e-13)) tmp = Float64(Float64(1.0 - 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 <= -2e-7) || ~((x <= 4.3e-13))) tmp = (1.0 - x) / tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2e-7], N[Not[LessEqual[x, 4.3e-13]], $MachinePrecision]], N[(N[(1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-7} \lor \neg \left(x \leq 4.3 \cdot 10^{-13}\right):\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.9999999999999999e-7 or 4.2999999999999999e-13 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
div-inv99.8%
frac-sub93.0%
associate-/r*99.7%
*-un-lft-identity99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in B around 0 98.0%
if -1.9999999999999999e-7 < x < 4.2999999999999999e-13Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 99.4%
Final simplification98.7%
(FPCore (B x) :precision binary64 (if (or (<= x -1.45) (not (<= x 1.0))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.45) || !(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.45d0)) .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.45) || !(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.45) 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.45) || !(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.45) || ~((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.45], 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.45 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.44999999999999996 or 1 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
div-inv99.7%
frac-sub94.3%
associate-/r*99.7%
*-un-lft-identity99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 96.9%
neg-mul-196.9%
Simplified96.9%
if -1.44999999999999996 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 97.9%
Final simplification97.5%
(FPCore (B x)
:precision binary64
(if (or (<= B -0.15) (not (<= B 0.106)))
(/ 1.0 (sin B))
(-
(+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ 1.0 B))
(/ x B))))
double code(double B, double x) {
double tmp;
if ((B <= -0.15) || !(B <= 0.106)) {
tmp = 1.0 / sin(B);
} else {
tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / 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 ((b <= (-0.15d0)) .or. (.not. (b <= 0.106d0))) then
tmp = 1.0d0 / sin(b)
else
tmp = ((b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + (1.0d0 / b)) - (x / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -0.15) || !(B <= 0.106)) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -0.15) or not (B <= 0.106): tmp = 1.0 / math.sin(B) else: tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((B <= -0.15) || !(B <= 0.106)) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(1.0 / B)) - Float64(x / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -0.15) || ~((B <= 0.106))) tmp = 1.0 / sin(B); else tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -0.15], N[Not[LessEqual[B, 0.106]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.15 \lor \neg \left(B \leq 0.106\right):\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\left(B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1}{B}\right) - \frac{x}{B}\\
\end{array}
\end{array}
if B < -0.149999999999999994 or 0.105999999999999997 < B Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in x around 0 51.5%
if -0.149999999999999994 < B < 0.105999999999999997Initial program 99.9%
+-commutative99.9%
unsub-neg99.9%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
Taylor expanded in B around 0 99.5%
Final simplification73.7%
(FPCore (B x)
:precision binary64
(if (<= B -850.0)
(sin B)
(if (<= B 3.15)
(-
(+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ 1.0 B))
(/ x B))
(sin B))))
double code(double B, double x) {
double tmp;
if (B <= -850.0) {
tmp = sin(B);
} else if (B <= 3.15) {
tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B);
} else {
tmp = 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 <= (-850.0d0)) then
tmp = sin(b)
else if (b <= 3.15d0) then
tmp = ((b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + (1.0d0 / b)) - (x / b)
else
tmp = sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= -850.0) {
tmp = Math.sin(B);
} else if (B <= 3.15) {
tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B);
} else {
tmp = Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= -850.0: tmp = math.sin(B) elif B <= 3.15: tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B) else: tmp = math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= -850.0) tmp = sin(B); elseif (B <= 3.15) tmp = Float64(Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(1.0 / B)) - Float64(x / B)); else tmp = sin(B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= -850.0) tmp = sin(B); elseif (B <= 3.15) tmp = ((B * (0.16666666666666666 + (x * 0.3333333333333333))) + (1.0 / B)) - (x / B); else tmp = sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, -850.0], N[Sin[B], $MachinePrecision], If[LessEqual[B, 3.15], 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[Sin[B], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -850:\\
\;\;\;\;\sin B\\
\mathbf{elif}\;B \leq 3.15:\\
\;\;\;\;\left(B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1}{B}\right) - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\sin B\\
\end{array}
\end{array}
if B < -850 or 3.14999999999999991 < B Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in B around 0 51.8%
add-exp-log24.6%
log-rec24.7%
Applied egg-rr24.7%
Taylor expanded in x around 0 24.7%
add-sqr-sqrt24.6%
sqrt-unprod24.7%
sqr-neg24.7%
sqrt-unprod0.0%
add-sqr-sqrt5.5%
add-exp-log11.2%
expm1-log1p-u11.2%
expm1-udef11.2%
Applied egg-rr11.2%
expm1-def11.2%
expm1-log1p11.2%
Simplified11.2%
if -850 < B < 3.14999999999999991Initial program 99.9%
+-commutative99.9%
unsub-neg99.9%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
Taylor expanded in B around 0 99.5%
Final simplification51.9%
(FPCore (B x) :precision binary64 (+ (* 0.3333333333333333 (* B x)) (/ (- 1.0 x) B)))
double code(double B, double x) {
return (0.3333333333333333 * (B * x)) + ((1.0 - x) / B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (0.3333333333333333d0 * (b * x)) + ((1.0d0 - x) / b)
end function
public static double code(double B, double x) {
return (0.3333333333333333 * (B * x)) + ((1.0 - x) / B);
}
def code(B, x): return (0.3333333333333333 * (B * x)) + ((1.0 - x) / B)
function code(B, x) return Float64(Float64(0.3333333333333333 * Float64(B * x)) + Float64(Float64(1.0 - x) / B)) end
function tmp = code(B, x) tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B); end
code[B_, x_] := N[(N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.3333333333333333 \cdot \left(B \cdot x\right) + \frac{1 - x}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 47.6%
+-commutative47.6%
mul-1-neg47.6%
sub-neg47.6%
associate--l+47.6%
*-commutative47.6%
*-commutative47.6%
div-sub47.6%
Simplified47.6%
Taylor expanded in x around inf 47.8%
Final simplification47.8%
(FPCore (B x) :precision binary64 (+ (/ (- 1.0 x) B) (* B 0.16666666666666666)))
double code(double B, double x) {
return ((1.0 - x) / B) + (B * 0.16666666666666666);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 - x) / b) + (b * 0.16666666666666666d0)
end function
public static double code(double B, double x) {
return ((1.0 - x) / B) + (B * 0.16666666666666666);
}
def code(B, x): return ((1.0 - x) / B) + (B * 0.16666666666666666)
function code(B, x) return Float64(Float64(Float64(1.0 - x) / B) + Float64(B * 0.16666666666666666)) end
function tmp = code(B, x) tmp = ((1.0 - x) / B) + (B * 0.16666666666666666); end
code[B_, x_] := N[(N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision] + N[(B * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{B} + B \cdot 0.16666666666666666
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 47.6%
+-commutative47.6%
mul-1-neg47.6%
sub-neg47.6%
associate--l+47.6%
*-commutative47.6%
*-commutative47.6%
div-sub47.6%
Simplified47.6%
Taylor expanded in x around 0 47.5%
*-commutative47.5%
Simplified47.5%
Final simplification47.5%
(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%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 45.4%
mul-1-neg45.4%
sub-neg45.4%
Simplified45.4%
Taylor expanded in x around inf 43.8%
neg-mul-143.8%
distribute-neg-frac43.8%
Simplified43.8%
if -1 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 49.0%
mul-1-neg49.0%
sub-neg49.0%
Simplified49.0%
Taylor expanded in x around 0 47.9%
Final simplification45.9%
(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%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 47.3%
mul-1-neg47.3%
sub-neg47.3%
Simplified47.3%
div-sub47.3%
Applied egg-rr47.3%
Final simplification47.3%
(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 47.3%
mul-1-neg47.3%
sub-neg47.3%
Simplified47.3%
Final simplification47.3%
(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 47.3%
mul-1-neg47.3%
sub-neg47.3%
Simplified47.3%
Taylor expanded in x around 0 26.4%
Final simplification26.4%
herbie shell --seed 2023238
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))