
(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 (/ (tan B) x)) (/ 1.0 (sin B))))
double code(double B, double x) {
return (-1.0 / (tan(B) / x)) + (1.0 / sin(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((-1.0d0) / (tan(b) / x)) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
return (-1.0 / (Math.tan(B) / x)) + (1.0 / Math.sin(B));
}
def code(B, x): return (-1.0 / (math.tan(B) / x)) + (1.0 / math.sin(B))
function code(B, x) return Float64(Float64(-1.0 / Float64(tan(B) / x)) + Float64(1.0 / sin(B))) end
function tmp = code(B, x) tmp = (-1.0 / (tan(B) / x)) + (1.0 / sin(B)); end
code[B_, x_] := N[(N[(-1.0 / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{\frac{\tan B}{x}} + \frac{1}{\sin B}
\end{array}
Initial program 99.7%
div-inv99.7%
clear-num99.8%
Applied egg-rr99.8%
Final simplification99.8%
(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%
*-commutative99.7%
remove-double-neg99.7%
distribute-frac-neg299.7%
tan-neg99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
tan-neg99.7%
distribute-neg-frac299.7%
distribute-neg-frac99.7%
remove-double-neg99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (B x) :precision binary64 (if (or (<= x -2.7) (not (<= x 7.5e-7))) (/ (- 1.0 x) (tan B)) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -2.7) || !(x <= 7.5e-7)) {
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 <= (-2.7d0)) .or. (.not. (x <= 7.5d-7))) 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 <= -2.7) || !(x <= 7.5e-7)) {
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 <= -2.7) or not (x <= 7.5e-7): 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 <= -2.7) || !(x <= 7.5e-7)) 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 <= -2.7) || ~((x <= 7.5e-7))) 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, -2.7], N[Not[LessEqual[x, 7.5e-7]], $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 -2.7 \lor \neg \left(x \leq 7.5 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -2.7000000000000002 or 7.5000000000000002e-7 < x Initial program 99.6%
+-commutative99.6%
div-inv99.7%
sub-neg99.7%
clear-num99.7%
frac-sub89.2%
*-un-lft-identity89.2%
*-commutative89.2%
*-un-lft-identity89.2%
Applied egg-rr89.2%
Simplified99.6%
Taylor expanded in B around 0 98.3%
associate-*l/98.4%
clear-num98.4%
*-commutative98.4%
Applied egg-rr98.4%
*-rgt-identity98.4%
*-commutative98.4%
times-frac98.2%
associate-/l/98.3%
remove-double-div98.4%
associate-/r/98.3%
associate-*l/98.4%
metadata-eval98.4%
sub-neg98.4%
sub-neg98.4%
metadata-eval98.4%
distribute-rgt-in98.4%
neg-mul-198.4%
unsub-neg98.4%
lft-mult-inverse98.4%
Simplified98.4%
if -2.7000000000000002 < x < 7.5000000000000002e-7Initial program 99.8%
Taylor expanded in B around 0 99.3%
Taylor expanded in x around 0 99.3%
mul-1-neg99.3%
+-commutative99.3%
sub-neg99.3%
Simplified99.3%
Final simplification98.8%
(FPCore (B x) :precision binary64 (if (or (<= x -9.5e-12) (not (<= x 4e-8))) (/ (- 1.0 x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -9.5e-12) || !(x <= 4e-8)) {
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 <= (-9.5d-12)) .or. (.not. (x <= 4d-8))) 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 <= -9.5e-12) || !(x <= 4e-8)) {
tmp = (1.0 - x) / Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -9.5e-12) or not (x <= 4e-8): 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 <= -9.5e-12) || !(x <= 4e-8)) 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 <= -9.5e-12) || ~((x <= 4e-8))) tmp = (1.0 - x) / tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -9.5e-12], N[Not[LessEqual[x, 4e-8]], $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 -9.5 \cdot 10^{-12} \lor \neg \left(x \leq 4 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -9.4999999999999995e-12 or 4.0000000000000001e-8 < x Initial program 99.6%
+-commutative99.6%
div-inv99.7%
sub-neg99.7%
clear-num99.7%
frac-sub88.2%
*-un-lft-identity88.2%
*-commutative88.2%
*-un-lft-identity88.2%
Applied egg-rr88.2%
Simplified99.0%
Taylor expanded in B around 0 96.9%
associate-*l/97.6%
clear-num97.6%
*-commutative97.6%
Applied egg-rr97.6%
*-rgt-identity97.6%
*-commutative97.6%
times-frac97.1%
associate-/l/97.2%
remove-double-div97.3%
associate-/r/97.6%
associate-*l/97.6%
metadata-eval97.6%
sub-neg97.6%
sub-neg97.6%
metadata-eval97.6%
distribute-rgt-in97.6%
neg-mul-197.6%
unsub-neg97.6%
lft-mult-inverse97.6%
Simplified97.6%
if -9.4999999999999995e-12 < x < 4.0000000000000001e-8Initial program 99.8%
Taylor expanded in x around 0 99.6%
Final simplification98.6%
(FPCore (B x) :precision binary64 (if (<= x -1.35) (/ x (- (tan B))) (if (<= x 1.0) (/ 1.0 (sin B)) (* x (/ -1.0 (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -1.35) {
tmp = x / -tan(B);
} else if (x <= 1.0) {
tmp = 1.0 / sin(B);
} else {
tmp = x * (-1.0 / tan(B));
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.35d0)) then
tmp = x / -tan(b)
else if (x <= 1.0d0) then
tmp = 1.0d0 / sin(b)
else
tmp = x * ((-1.0d0) / tan(b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.35) {
tmp = x / -Math.tan(B);
} else if (x <= 1.0) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = x * (-1.0 / Math.tan(B));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.35: tmp = x / -math.tan(B) elif x <= 1.0: tmp = 1.0 / math.sin(B) else: tmp = x * (-1.0 / math.tan(B)) return tmp
function code(B, x) tmp = 0.0 if (x <= -1.35) tmp = Float64(x / Float64(-tan(B))); elseif (x <= 1.0) tmp = Float64(1.0 / sin(B)); else tmp = Float64(x * Float64(-1.0 / tan(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.35) tmp = x / -tan(B); elseif (x <= 1.0) tmp = 1.0 / sin(B); else tmp = x * (-1.0 / tan(B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.35], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35:\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B}\\
\end{array}
\end{array}
if x < -1.3500000000000001Initial program 99.6%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
associate-/l*96.7%
distribute-rgt-neg-in96.7%
distribute-neg-frac296.7%
Simplified96.7%
*-commutative96.7%
distribute-frac-neg296.7%
clear-num96.5%
tan-quot96.6%
distribute-lft-neg-in96.6%
associate-/r/96.7%
add-sqr-sqrt42.1%
sqrt-unprod28.5%
sqr-neg28.5%
sqrt-unprod0.3%
add-sqr-sqrt0.5%
clear-num0.5%
frac-2neg0.5%
tan-quot0.5%
distribute-frac-neg0.5%
add-sqr-sqrt0.2%
sqrt-unprod47.6%
sqr-neg47.6%
sqrt-unprod48.8%
add-sqr-sqrt96.6%
Applied egg-rr96.7%
if -1.3500000000000001 < x < 1Initial program 99.8%
Taylor expanded in x around 0 98.0%
if 1 < x Initial program 99.6%
Taylor expanded in x around inf 97.0%
mul-1-neg97.0%
associate-/l*97.1%
distribute-rgt-neg-in97.1%
distribute-neg-frac297.1%
Simplified97.1%
distribute-frac-neg297.1%
clear-num97.0%
tan-quot97.1%
neg-sub097.1%
Applied egg-rr97.1%
neg-sub097.1%
distribute-neg-frac97.1%
metadata-eval97.1%
Simplified97.1%
Final simplification97.5%
(FPCore (B x) :precision binary64 (if (<= x -1.3) (/ x (- (tan B))) (if (<= x 1.1) (/ 1.0 (sin B)) (/ -1.0 (/ (tan B) x)))))
double code(double B, double x) {
double tmp;
if (x <= -1.3) {
tmp = x / -tan(B);
} else if (x <= 1.1) {
tmp = 1.0 / sin(B);
} else {
tmp = -1.0 / (tan(B) / x);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.3d0)) then
tmp = x / -tan(b)
else if (x <= 1.1d0) then
tmp = 1.0d0 / sin(b)
else
tmp = (-1.0d0) / (tan(b) / x)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.3) {
tmp = x / -Math.tan(B);
} else if (x <= 1.1) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = -1.0 / (Math.tan(B) / x);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.3: tmp = x / -math.tan(B) elif x <= 1.1: tmp = 1.0 / math.sin(B) else: tmp = -1.0 / (math.tan(B) / x) return tmp
function code(B, x) tmp = 0.0 if (x <= -1.3) tmp = Float64(x / Float64(-tan(B))); elseif (x <= 1.1) tmp = Float64(1.0 / sin(B)); else tmp = Float64(-1.0 / Float64(tan(B) / x)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.3) tmp = x / -tan(B); elseif (x <= 1.1) tmp = 1.0 / sin(B); else tmp = -1.0 / (tan(B) / x); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.3], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision], If[LessEqual[x, 1.1], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3:\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{elif}\;x \leq 1.1:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\tan B}{x}}\\
\end{array}
\end{array}
if x < -1.30000000000000004Initial program 99.6%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
associate-/l*96.7%
distribute-rgt-neg-in96.7%
distribute-neg-frac296.7%
Simplified96.7%
*-commutative96.7%
distribute-frac-neg296.7%
clear-num96.5%
tan-quot96.6%
distribute-lft-neg-in96.6%
associate-/r/96.7%
add-sqr-sqrt42.1%
sqrt-unprod28.5%
sqr-neg28.5%
sqrt-unprod0.3%
add-sqr-sqrt0.5%
clear-num0.5%
frac-2neg0.5%
tan-quot0.5%
distribute-frac-neg0.5%
add-sqr-sqrt0.2%
sqrt-unprod47.6%
sqr-neg47.6%
sqrt-unprod48.8%
add-sqr-sqrt96.6%
Applied egg-rr96.7%
if -1.30000000000000004 < x < 1.1000000000000001Initial program 99.8%
Taylor expanded in x around 0 98.0%
if 1.1000000000000001 < x Initial program 99.6%
Taylor expanded in x around inf 97.0%
mul-1-neg97.0%
associate-/l*97.1%
distribute-rgt-neg-in97.1%
distribute-neg-frac297.1%
Simplified97.1%
*-commutative97.1%
distribute-frac-neg297.1%
clear-num97.0%
tan-quot97.1%
distribute-lft-neg-in97.1%
associate-/r/97.1%
distribute-neg-frac97.1%
metadata-eval97.1%
Applied egg-rr97.1%
Final simplification97.5%
(FPCore (B x) :precision binary64 (if (or (<= x -1.36) (not (<= x 1.0))) (/ x (- (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.36) || !(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.36d0)) .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.36) || !(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.36) 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.36) || !(x <= 1.0)) tmp = Float64(x / Float64(-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.36) || ~((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.36], 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.36 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.3600000000000001 or 1 < x Initial program 99.6%
Taylor expanded in x around inf 96.8%
mul-1-neg96.8%
associate-/l*96.9%
distribute-rgt-neg-in96.9%
distribute-neg-frac296.9%
Simplified96.9%
*-commutative96.9%
distribute-frac-neg296.9%
clear-num96.8%
tan-quot96.9%
distribute-lft-neg-in96.9%
associate-/r/96.9%
add-sqr-sqrt43.7%
sqrt-unprod27.0%
sqr-neg27.0%
sqrt-unprod0.3%
add-sqr-sqrt0.5%
clear-num0.5%
frac-2neg0.5%
tan-quot0.5%
distribute-frac-neg0.5%
add-sqr-sqrt0.2%
sqrt-unprod51.1%
sqr-neg51.1%
sqrt-unprod53.1%
add-sqr-sqrt96.8%
Applied egg-rr96.9%
if -1.3600000000000001 < x < 1Initial program 99.8%
Taylor expanded in x around 0 98.0%
Final simplification97.5%
(FPCore (B x) :precision binary64 (if (<= B 8.5e-6) (- (/ 1.0 B) (/ x B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 8.5e-6) {
tmp = (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 <= 8.5d-6) then
tmp = (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 <= 8.5e-6) {
tmp = (1.0 / B) - (x / B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 8.5e-6: tmp = (1.0 / B) - (x / B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 8.5e-6) tmp = Float64(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 <= 8.5e-6) tmp = (1.0 / B) - (x / B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 8.5e-6], N[(N[(1.0 / B), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 8.5 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 8.4999999999999999e-6Initial program 99.8%
Taylor expanded in B around 0 67.1%
div-sub67.1%
Applied egg-rr67.1%
if 8.4999999999999999e-6 < B Initial program 99.5%
Taylor expanded in x around 0 46.9%
Final simplification61.7%
(FPCore (B x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1850.0))) (/ x (- B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1850.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 <= 1850.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 <= 1850.0)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.0) or not (x <= 1850.0): tmp = x / -B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1850.0)) tmp = Float64(x / Float64(-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 <= 1850.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, 1850.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 1850\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1 or 1850 < x Initial program 99.6%
Taylor expanded in B around 0 42.9%
Taylor expanded in x around inf 41.5%
associate-*r/41.5%
neg-mul-141.5%
Simplified41.5%
if -1 < x < 1850Initial program 99.8%
Taylor expanded in B around 0 57.1%
Taylor expanded in x around 0 55.8%
Final simplification48.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%
Taylor expanded in B around 0 50.2%
div-sub50.2%
Applied egg-rr50.2%
Final simplification50.2%
(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 50.2%
Final simplification50.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.7%
Taylor expanded in B around 0 50.2%
Taylor expanded in x around 0 30.4%
Final simplification30.4%
herbie shell --seed 2024075
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))