
(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 (+ (/ (- x) (tan B)) (pow (sin B) -1.0)))
double code(double B, double x) {
return (-x / tan(B)) + pow(sin(B), -1.0);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (-x / tan(b)) + (sin(b) ** (-1.0d0))
end function
public static double code(double B, double x) {
return (-x / Math.tan(B)) + Math.pow(Math.sin(B), -1.0);
}
def code(B, x): return (-x / math.tan(B)) + math.pow(math.sin(B), -1.0)
function code(B, x) return Float64(Float64(Float64(-x) / tan(B)) + (sin(B) ^ -1.0)) end
function tmp = code(B, x) tmp = (-x / tan(B)) + (sin(B) ^ -1.0); end
code[B_, x_] := N[(N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[B], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-x}{\tan B} + {\sin B}^{-1}
\end{array}
Initial program 99.7%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (B x)
:precision binary64
(let* ((t_0 (pow (sin B) -1.0)) (t_1 (+ (* x (/ -1.0 (tan B))) t_0)))
(if (or (<= t_1 -10000000.0) (not (<= t_1 1000.0)))
(- (pow B -1.0) (/ x (tan B)))
(+ (- (/ x B)) t_0))))
double code(double B, double x) {
double t_0 = pow(sin(B), -1.0);
double t_1 = (x * (-1.0 / tan(B))) + t_0;
double tmp;
if ((t_1 <= -10000000.0) || !(t_1 <= 1000.0)) {
tmp = pow(B, -1.0) - (x / tan(B));
} else {
tmp = -(x / B) + t_0;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(b) ** (-1.0d0)
t_1 = (x * ((-1.0d0) / tan(b))) + t_0
if ((t_1 <= (-10000000.0d0)) .or. (.not. (t_1 <= 1000.0d0))) then
tmp = (b ** (-1.0d0)) - (x / tan(b))
else
tmp = -(x / b) + t_0
end if
code = tmp
end function
public static double code(double B, double x) {
double t_0 = Math.pow(Math.sin(B), -1.0);
double t_1 = (x * (-1.0 / Math.tan(B))) + t_0;
double tmp;
if ((t_1 <= -10000000.0) || !(t_1 <= 1000.0)) {
tmp = Math.pow(B, -1.0) - (x / Math.tan(B));
} else {
tmp = -(x / B) + t_0;
}
return tmp;
}
def code(B, x): t_0 = math.pow(math.sin(B), -1.0) t_1 = (x * (-1.0 / math.tan(B))) + t_0 tmp = 0 if (t_1 <= -10000000.0) or not (t_1 <= 1000.0): tmp = math.pow(B, -1.0) - (x / math.tan(B)) else: tmp = -(x / B) + t_0 return tmp
function code(B, x) t_0 = sin(B) ^ -1.0 t_1 = Float64(Float64(x * Float64(-1.0 / tan(B))) + t_0) tmp = 0.0 if ((t_1 <= -10000000.0) || !(t_1 <= 1000.0)) tmp = Float64((B ^ -1.0) - Float64(x / tan(B))); else tmp = Float64(Float64(-Float64(x / B)) + t_0); end return tmp end
function tmp_2 = code(B, x) t_0 = sin(B) ^ -1.0; t_1 = (x * (-1.0 / tan(B))) + t_0; tmp = 0.0; if ((t_1 <= -10000000.0) || ~((t_1 <= 1000.0))) tmp = (B ^ -1.0) - (x / tan(B)); else tmp = -(x / B) + t_0; end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = N[Power[N[Sin[B], $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -10000000.0], N[Not[LessEqual[t$95$1, 1000.0]], $MachinePrecision]], N[(N[Power[B, -1.0], $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[(x / B), $MachinePrecision]) + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin B}^{-1}\\
t_1 := x \cdot \frac{-1}{\tan B} + t\_0\\
\mathbf{if}\;t\_1 \leq -10000000 \lor \neg \left(t\_1 \leq 1000\right):\\
\;\;\;\;{B}^{-1} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + t\_0\\
\end{array}
\end{array}
if (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (/.f64 #s(literal 1 binary64) (sin.f64 B))) < -1e7 or 1e3 < (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (/.f64 #s(literal 1 binary64) (sin.f64 B))) Initial program 99.7%
lift-/.f64N/A
inv-powN/A
sqr-powN/A
pow-prod-downN/A
lower-pow.f64N/A
pow2N/A
lower-pow.f64N/A
metadata-eval67.9
Applied rewrites67.9%
Taylor expanded in B around 0
unpow2N/A
lower-*.f6467.7
Applied rewrites67.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6467.7
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6467.7
Applied rewrites67.7%
Taylor expanded in B around 0
lower-/.f6499.3
Applied rewrites99.3%
if -1e7 < (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (/.f64 #s(literal 1 binary64) (sin.f64 B))) < 1e3Initial program 99.8%
Taylor expanded in B around 0
lower-/.f6496.0
Applied rewrites96.0%
Final simplification98.4%
(FPCore (B x) :precision binary64 (if (or (<= x -1.5) (not (<= x 1.2))) (- (pow B -1.0) (/ x (tan B))) (pow (/ (sin B) (- 1.0 x)) -1.0)))
double code(double B, double x) {
double tmp;
if ((x <= -1.5) || !(x <= 1.2)) {
tmp = pow(B, -1.0) - (x / tan(B));
} else {
tmp = pow((sin(B) / (1.0 - x)), -1.0);
}
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.2d0))) then
tmp = (b ** (-1.0d0)) - (x / tan(b))
else
tmp = (sin(b) / (1.0d0 - x)) ** (-1.0d0)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -1.5) || !(x <= 1.2)) {
tmp = Math.pow(B, -1.0) - (x / Math.tan(B));
} else {
tmp = Math.pow((Math.sin(B) / (1.0 - x)), -1.0);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.5) or not (x <= 1.2): tmp = math.pow(B, -1.0) - (x / math.tan(B)) else: tmp = math.pow((math.sin(B) / (1.0 - x)), -1.0) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.5) || !(x <= 1.2)) tmp = Float64((B ^ -1.0) - Float64(x / tan(B))); else tmp = Float64(sin(B) / Float64(1.0 - x)) ^ -1.0; end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.5) || ~((x <= 1.2))) tmp = (B ^ -1.0) - (x / tan(B)); else tmp = (sin(B) / (1.0 - x)) ^ -1.0; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.5], N[Not[LessEqual[x, 1.2]], $MachinePrecision]], N[(N[Power[B, -1.0], $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sin[B], $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1.2\right):\\
\;\;\;\;{B}^{-1} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sin B}{1 - x}\right)}^{-1}\\
\end{array}
\end{array}
if x < -1.5 or 1.19999999999999996 < x Initial program 99.6%
lift-/.f64N/A
inv-powN/A
sqr-powN/A
pow-prod-downN/A
lower-pow.f64N/A
pow2N/A
lower-pow.f64N/A
metadata-eval86.9
Applied rewrites86.9%
Taylor expanded in B around 0
unpow2N/A
lower-*.f6486.6
Applied rewrites86.6%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6486.6
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6486.6
Applied rewrites86.6%
Taylor expanded in B around 0
lower-/.f6499.0
Applied rewrites99.0%
if -1.5 < x < 1.19999999999999996Initial program 99.9%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
clear-numN/A
associate-/l*N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.9%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in B around 0
lower--.f6497.7
Applied rewrites97.7%
Final simplification98.3%
(FPCore (B x) :precision binary64 (if (or (<= x -1.5) (not (<= x 1.2))) (- (pow B -1.0) (/ x (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.5) || !(x <= 1.2)) {
tmp = pow(B, -1.0) - (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 <= (-1.5d0)) .or. (.not. (x <= 1.2d0))) then
tmp = (b ** (-1.0d0)) - (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 <= -1.5) || !(x <= 1.2)) {
tmp = Math.pow(B, -1.0) - (x / Math.tan(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.5) or not (x <= 1.2): tmp = math.pow(B, -1.0) - (x / math.tan(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.5) || !(x <= 1.2)) tmp = Float64((B ^ -1.0) - 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 <= -1.5) || ~((x <= 1.2))) tmp = (B ^ -1.0) - (x / tan(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.5], N[Not[LessEqual[x, 1.2]], $MachinePrecision]], N[(N[Power[B, -1.0], $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1.2\right):\\
\;\;\;\;{B}^{-1} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1.5 or 1.19999999999999996 < x Initial program 99.6%
lift-/.f64N/A
inv-powN/A
sqr-powN/A
pow-prod-downN/A
lower-pow.f64N/A
pow2N/A
lower-pow.f64N/A
metadata-eval86.9
Applied rewrites86.9%
Taylor expanded in B around 0
unpow2N/A
lower-*.f6486.6
Applied rewrites86.6%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6486.6
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6486.6
Applied rewrites86.6%
Taylor expanded in B around 0
lower-/.f6499.0
Applied rewrites99.0%
if -1.5 < x < 1.19999999999999996Initial program 99.9%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
clear-numN/A
associate-/l*N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in B around 0
lower--.f6497.7
Applied rewrites97.7%
Final simplification98.3%
(FPCore (B x) :precision binary64 (/ (- 1.0 (* (cos B) x)) (sin B)))
double code(double B, double x) {
return (1.0 - (cos(B) * x)) / sin(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - (cos(b) * x)) / sin(b)
end function
public static double code(double B, double x) {
return (1.0 - (Math.cos(B) * x)) / Math.sin(B);
}
def code(B, x): return (1.0 - (math.cos(B) * x)) / math.sin(B)
function code(B, x) return Float64(Float64(1.0 - Float64(cos(B) * x)) / sin(B)) end
function tmp = code(B, x) tmp = (1.0 - (cos(B) * x)) / sin(B); end
code[B_, x_] := N[(N[(1.0 - N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \cos B \cdot x}{\sin B}
\end{array}
Initial program 99.7%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
clear-numN/A
associate-/l*N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.8%
(FPCore (B x) :precision binary64 (/ (- 1.0 x) (sin B)))
double code(double B, double x) {
return (1.0 - x) / sin(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - x) / sin(b)
end function
public static double code(double B, double x) {
return (1.0 - x) / Math.sin(B);
}
def code(B, x): return (1.0 - x) / math.sin(B)
function code(B, x) return Float64(Float64(1.0 - x) / sin(B)) end
function tmp = code(B, x) tmp = (1.0 - x) / sin(B); end
code[B_, x_] := N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{\sin B}
\end{array}
Initial program 99.7%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
clear-numN/A
associate-/l*N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in B around 0
lower--.f6476.4
Applied rewrites76.4%
Final simplification76.4%
(FPCore (B x) :precision binary64 (/ (- (fma (* 0.3333333333333333 x) (* B B) 1.0) x) B))
double code(double B, double x) {
return (fma((0.3333333333333333 * x), (B * B), 1.0) - x) / B;
}
function code(B, x) return Float64(Float64(fma(Float64(0.3333333333333333 * x), Float64(B * B), 1.0) - x) / B) end
code[B_, x_] := N[(N[(N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(B * B), $MachinePrecision] + 1.0), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(0.3333333333333333 \cdot x, B \cdot B, 1\right) - x}{B}
\end{array}
Initial program 99.7%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
clear-numN/A
associate-/l*N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6448.2
Applied rewrites48.2%
Taylor expanded in x around inf
Applied rewrites48.3%
(FPCore (B x) :precision binary64 (if (or (<= x -17500000.0) (not (<= x 1.0))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -17500000.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 <= (-17500000.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 <= -17500000.0) || !(x <= 1.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -17500000.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 <= -17500000.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 <= -17500000.0) || ~((x <= 1.0))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -17500000.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 -17500000 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1.75e7 or 1 < x Initial program 99.6%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6448.9
Applied rewrites48.9%
Taylor expanded in x around inf
Applied rewrites48.0%
if -1.75e7 < x < 1Initial program 99.9%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6447.9
Applied rewrites47.9%
Taylor expanded in x around 0
Applied rewrites46.5%
Final simplification47.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
lower-/.f64N/A
lower--.f6448.3
Applied rewrites48.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%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6448.3
Applied rewrites48.3%
Taylor expanded in x around 0
Applied rewrites26.5%
herbie shell --seed 2024321
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))