
(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 10 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 (<= x -180000000000.0) (/ (* x (- (cos B))) (sin B)) (if (<= x 29000000.0) (/ (- 1.0 x) (sin B)) (/ (- x) (tan B)))))
double code(double B, double x) {
double tmp;
if (x <= -180000000000.0) {
tmp = (x * -cos(B)) / sin(B);
} else if (x <= 29000000.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 <= (-180000000000.0d0)) then
tmp = (x * -cos(b)) / sin(b)
else if (x <= 29000000.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 <= -180000000000.0) {
tmp = (x * -Math.cos(B)) / Math.sin(B);
} else if (x <= 29000000.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = -x / Math.tan(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -180000000000.0: tmp = (x * -math.cos(B)) / math.sin(B) elif x <= 29000000.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 <= -180000000000.0) tmp = Float64(Float64(x * Float64(-cos(B))) / sin(B)); elseif (x <= 29000000.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 <= -180000000000.0) tmp = (x * -cos(B)) / sin(B); elseif (x <= 29000000.0) tmp = (1.0 - x) / sin(B); else tmp = -x / tan(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -180000000000.0], N[(N[(x * (-N[Cos[B], $MachinePrecision])), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 29000000.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 -180000000000:\\
\;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\
\mathbf{elif}\;x \leq 29000000:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{\tan B}\\
\end{array}
\end{array}
if x < -1.8e11Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 99.5%
associate-*r/99.5%
neg-mul-199.5%
distribute-lft-neg-in99.5%
Simplified99.5%
if -1.8e11 < x < 2.9e7Initial program 99.9%
+-commutative99.9%
unsub-neg99.9%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
sub-div99.8%
Applied egg-rr99.8%
Taylor expanded in B around 0 97.7%
if 2.9e7 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around 0 99.6%
Taylor expanded in x around inf 99.6%
associate-*r/99.6%
neg-mul-199.6%
distribute-lft-neg-in99.6%
Simplified99.6%
associate-/l*99.5%
distribute-frac-neg99.5%
add-sqr-sqrt72.3%
sqrt-unprod72.6%
sqr-neg72.6%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
associate-/l*0.5%
*-commutative0.5%
associate-/l*0.5%
add-sqr-sqrt0.2%
sqrt-unprod72.8%
sqr-neg72.8%
sqrt-unprod72.4%
add-sqr-sqrt99.7%
tan-quot99.8%
div-inv99.6%
*-commutative99.6%
neg-mul-199.6%
Applied egg-rr99.8%
Final simplification98.8%
(FPCore (B x) :precision binary64 (if (or (<= x -180000000000.0) (not (<= x 4500000.0))) (/ (- x) (tan B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -180000000000.0) || !(x <= 4500000.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 <= (-180000000000.0d0)) .or. (.not. (x <= 4500000.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 <= -180000000000.0) || !(x <= 4500000.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -180000000000.0) or not (x <= 4500000.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 <= -180000000000.0) || !(x <= 4500000.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 <= -180000000000.0) || ~((x <= 4500000.0))) tmp = -x / tan(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -180000000000.0], N[Not[LessEqual[x, 4500000.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 -180000000000 \lor \neg \left(x \leq 4500000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1.8e11 or 4.5e6 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 99.6%
associate-*r/99.6%
neg-mul-199.6%
distribute-lft-neg-in99.6%
Simplified99.6%
associate-/l*99.4%
distribute-frac-neg99.4%
add-sqr-sqrt70.4%
sqrt-unprod70.6%
sqr-neg70.6%
sqrt-unprod0.2%
add-sqr-sqrt0.4%
associate-/l*0.4%
*-commutative0.4%
associate-/l*0.4%
add-sqr-sqrt0.2%
sqrt-unprod70.9%
sqr-neg70.9%
sqrt-unprod70.6%
add-sqr-sqrt99.6%
tan-quot99.6%
div-inv99.5%
*-commutative99.5%
neg-mul-199.5%
Applied egg-rr99.6%
if -1.8e11 < x < 4.5e6Initial program 99.9%
+-commutative99.9%
unsub-neg99.9%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
sub-div99.8%
Applied egg-rr99.8%
Taylor expanded in B around 0 97.7%
Final simplification98.7%
(FPCore (B x) :precision binary64 (if (or (<= x -1.05) (not (<= x 2.7))) (/ (- x) (sin B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.05) || !(x <= 2.7)) {
tmp = -x / sin(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.05d0)) .or. (.not. (x <= 2.7d0))) then
tmp = -x / sin(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.05) || !(x <= 2.7)) {
tmp = -x / Math.sin(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.05) or not (x <= 2.7): tmp = -x / math.sin(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.05) || !(x <= 2.7)) tmp = Float64(Float64(-x) / sin(B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.05) || ~((x <= 2.7))) tmp = -x / sin(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.05], N[Not[LessEqual[x, 2.7]], $MachinePrecision]], N[((-x) / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \lor \neg \left(x \leq 2.7\right):\\
\;\;\;\;\frac{-x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.05000000000000004 or 2.7000000000000002 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
neg-mul-197.9%
distribute-lft-neg-in97.9%
Simplified97.9%
Taylor expanded in B around 0 51.2%
neg-mul-151.2%
Simplified51.2%
if -1.05000000000000004 < x < 2.7000000000000002Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in x around 0 97.4%
Final simplification71.0%
(FPCore (B x) :precision binary64 (if (or (<= x -1.85) (not (<= x 1.0))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.85) || !(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.85d0)) .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.85) || !(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.85) 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.85) || !(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.85) || ~((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.85], 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.85 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.8500000000000001 or 1 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
neg-mul-197.9%
distribute-lft-neg-in97.9%
Simplified97.9%
associate-/l*97.7%
distribute-frac-neg97.7%
add-sqr-sqrt69.8%
sqrt-unprod70.0%
sqr-neg70.0%
sqrt-unprod0.2%
add-sqr-sqrt0.4%
associate-/l*0.4%
*-commutative0.4%
associate-/l*0.4%
add-sqr-sqrt0.2%
sqrt-unprod70.2%
sqr-neg70.2%
sqrt-unprod69.9%
add-sqr-sqrt97.9%
tan-quot98.0%
div-inv97.8%
*-commutative97.8%
neg-mul-197.8%
Applied egg-rr98.0%
if -1.8500000000000001 < x < 1Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in x around 0 97.4%
Final simplification97.7%
(FPCore (B x) :precision binary64 (if (or (<= x -4.8e-6) (not (<= x 2.55e-5))) (+ (* B 0.16666666666666666) (/ (- 1.0 x) B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -4.8e-6) || !(x <= 2.55e-5)) {
tmp = (B * 0.16666666666666666) + ((1.0 - 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 ((x <= (-4.8d-6)) .or. (.not. (x <= 2.55d-5))) then
tmp = (b * 0.16666666666666666d0) + ((1.0d0 - 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 ((x <= -4.8e-6) || !(x <= 2.55e-5)) {
tmp = (B * 0.16666666666666666) + ((1.0 - x) / B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -4.8e-6) or not (x <= 2.55e-5): tmp = (B * 0.16666666666666666) + ((1.0 - x) / B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -4.8e-6) || !(x <= 2.55e-5)) tmp = Float64(Float64(B * 0.16666666666666666) + Float64(Float64(1.0 - x) / B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -4.8e-6) || ~((x <= 2.55e-5))) tmp = (B * 0.16666666666666666) + ((1.0 - x) / B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -4.8e-6], N[Not[LessEqual[x, 2.55e-5]], $MachinePrecision]], N[(N[(B * 0.16666666666666666), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{-6} \lor \neg \left(x \leq 2.55 \cdot 10^{-5}\right):\\
\;\;\;\;B \cdot 0.16666666666666666 + \frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -4.7999999999999998e-6 or 2.54999999999999998e-5 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 48.9%
+-commutative48.9%
mul-1-neg48.9%
sub-neg48.9%
associate--l+48.9%
*-commutative48.9%
*-commutative48.9%
div-sub48.9%
Simplified48.9%
Taylor expanded in x around 0 49.7%
*-commutative49.7%
Simplified49.7%
if -4.7999999999999998e-6 < x < 2.54999999999999998e-5Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in x around 0 98.7%
Final simplification70.4%
(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%
Simplified99.7%
Taylor expanded in B around 0 50.9%
+-commutative50.9%
mul-1-neg50.9%
sub-neg50.9%
associate--l+50.9%
*-commutative50.9%
*-commutative50.9%
div-sub50.9%
Simplified50.9%
Taylor expanded in x around 0 51.3%
*-commutative51.3%
Simplified51.3%
Final simplification51.3%
(FPCore (B x) :precision binary64 (if (or (<= x -750.0) (not (<= x 1.0))) (- (/ x B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -750.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 <= (-750.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 <= -750.0) || !(x <= 1.0)) {
tmp = -(x / B);
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -750.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 <= -750.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 <= -750.0) || ~((x <= 1.0))) tmp = -(x / B); else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -750.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 -750 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;-\frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -750 or 1 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 49.0%
mul-1-neg49.0%
sub-neg49.0%
Simplified49.0%
Taylor expanded in x around inf 48.3%
neg-mul-148.3%
distribute-neg-frac48.3%
Simplified48.3%
if -750 < x < 1Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in B around 0 54.1%
mul-1-neg54.1%
sub-neg54.1%
Simplified54.1%
Taylor expanded in x around 0 52.4%
Final simplification50.1%
(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 51.3%
mul-1-neg51.3%
sub-neg51.3%
Simplified51.3%
Final simplification51.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 51.3%
mul-1-neg51.3%
sub-neg51.3%
Simplified51.3%
Taylor expanded in x around 0 24.5%
Final simplification24.5%
herbie shell --seed 2023182
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))