
(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%
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.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x)
:precision binary64
(if (<= x -145000000.0)
(/ (- x) (tan B))
(if (<= x 0.95)
(+ (/ 1.0 (sin B)) (* x (/ -1.0 B)))
(/ (- 1.0 x) (tan B)))))
double code(double B, double x) {
double tmp;
if (x <= -145000000.0) {
tmp = -x / tan(B);
} else if (x <= 0.95) {
tmp = (1.0 / sin(B)) + (x * (-1.0 / B));
} else {
tmp = (1.0 - 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 <= (-145000000.0d0)) then
tmp = -x / tan(b)
else if (x <= 0.95d0) then
tmp = (1.0d0 / sin(b)) + (x * ((-1.0d0) / b))
else
tmp = (1.0d0 - x) / tan(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -145000000.0) {
tmp = -x / Math.tan(B);
} else if (x <= 0.95) {
tmp = (1.0 / Math.sin(B)) + (x * (-1.0 / B));
} else {
tmp = (1.0 - x) / Math.tan(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -145000000.0: tmp = -x / math.tan(B) elif x <= 0.95: tmp = (1.0 / math.sin(B)) + (x * (-1.0 / B)) else: tmp = (1.0 - x) / math.tan(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -145000000.0) tmp = Float64(Float64(-x) / tan(B)); elseif (x <= 0.95) tmp = Float64(Float64(1.0 / sin(B)) + Float64(x * Float64(-1.0 / B))); else tmp = Float64(Float64(1.0 - x) / tan(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -145000000.0) tmp = -x / tan(B); elseif (x <= 0.95) tmp = (1.0 / sin(B)) + (x * (-1.0 / B)); else tmp = (1.0 - x) / tan(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -145000000.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.95], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[(x * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -145000000:\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;\frac{1}{\sin B} + x \cdot \frac{-1}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\end{array}
\end{array}
if x < -1.45e8Initial program 99.5%
distribute-lft-neg-in99.5%
+-commutative99.5%
*-commutative99.5%
remove-double-neg99.5%
distribute-frac-neg299.5%
tan-neg99.5%
cancel-sign-sub-inv99.5%
*-commutative99.5%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
div-inv99.5%
*-commutative99.5%
Applied egg-rr99.5%
associate-*l/99.8%
*-un-lft-identity99.8%
frac-sub91.7%
*-un-lft-identity91.7%
Applied egg-rr91.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in x around inf 99.8%
mul-1-neg99.8%
Simplified99.8%
if -1.45e8 < x < 0.94999999999999996Initial program 99.8%
Taylor expanded in B around 0 97.9%
if 0.94999999999999996 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
*-commutative99.6%
remove-double-neg99.6%
distribute-frac-neg299.6%
tan-neg99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
tan-neg99.7%
distribute-neg-frac299.7%
distribute-neg-frac99.7%
remove-double-neg99.7%
Simplified99.7%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
associate-*l/99.7%
*-un-lft-identity99.7%
frac-sub95.8%
*-un-lft-identity95.8%
Applied egg-rr95.8%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in B around 0 98.5%
Final simplification98.6%
(FPCore (B x) :precision binary64 (if (or (<= x -1.25) (not (<= x 0.58))) (/ (- 1.0 x) (tan B)) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.25) || !(x <= 0.58)) {
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 <= (-1.25d0)) .or. (.not. (x <= 0.58d0))) 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 <= -1.25) || !(x <= 0.58)) {
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 <= -1.25) or not (x <= 0.58): 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 <= -1.25) || !(x <= 0.58)) 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 <= -1.25) || ~((x <= 0.58))) 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, -1.25], N[Not[LessEqual[x, 0.58]], $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 -1.25 \lor \neg \left(x \leq 0.58\right):\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -1.25 or 0.57999999999999996 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
*-commutative99.6%
remove-double-neg99.6%
distribute-frac-neg299.6%
tan-neg99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
associate-*l/99.8%
*-un-lft-identity99.8%
frac-sub94.0%
*-un-lft-identity94.0%
Applied egg-rr94.0%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in B around 0 99.1%
if -1.25 < x < 0.57999999999999996Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around 0 97.9%
Final simplification98.6%
(FPCore (B x) :precision binary64 (if (or (<= x -1250000000.0) (not (<= x 56000.0))) (/ (- x) (tan B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1250000000.0) || !(x <= 56000.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 <= (-1250000000.0d0)) .or. (.not. (x <= 56000.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 <= -1250000000.0) || !(x <= 56000.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1250000000.0) or not (x <= 56000.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 <= -1250000000.0) || !(x <= 56000.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 <= -1250000000.0) || ~((x <= 56000.0))) tmp = -x / tan(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1250000000.0], N[Not[LessEqual[x, 56000.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 -1250000000 \lor \neg \left(x \leq 56000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1.25e9 or 56000 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
*-commutative99.6%
remove-double-neg99.6%
distribute-frac-neg299.6%
tan-neg99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
associate-*l/99.8%
*-un-lft-identity99.8%
frac-sub94.6%
*-un-lft-identity94.6%
Applied egg-rr94.6%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in x around inf 98.9%
mul-1-neg98.9%
Simplified98.9%
if -1.25e9 < x < 56000Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 97.8%
Final simplification98.4%
(FPCore (B x) :precision binary64 (if (<= x -1450000000.0) (/ (- x) (tan B)) (if (<= x 1.0) (/ (- 1.0 x) (sin B)) (/ (- 1.0 x) (tan B)))))
double code(double B, double x) {
double tmp;
if (x <= -1450000000.0) {
tmp = -x / tan(B);
} else if (x <= 1.0) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (1.0 - 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 <= (-1450000000.0d0)) then
tmp = -x / tan(b)
else if (x <= 1.0d0) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = (1.0d0 - x) / tan(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1450000000.0) {
tmp = -x / Math.tan(B);
} else if (x <= 1.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = (1.0 - x) / Math.tan(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1450000000.0: tmp = -x / math.tan(B) elif x <= 1.0: tmp = (1.0 - x) / math.sin(B) else: tmp = (1.0 - x) / math.tan(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -1450000000.0) tmp = Float64(Float64(-x) / tan(B)); elseif (x <= 1.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(1.0 - x) / tan(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1450000000.0) tmp = -x / tan(B); elseif (x <= 1.0) tmp = (1.0 - x) / sin(B); else tmp = (1.0 - x) / tan(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1450000000.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1450000000:\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\end{array}
\end{array}
if x < -1.45e9Initial program 99.5%
distribute-lft-neg-in99.5%
+-commutative99.5%
*-commutative99.5%
remove-double-neg99.5%
distribute-frac-neg299.5%
tan-neg99.5%
cancel-sign-sub-inv99.5%
*-commutative99.5%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
div-inv99.5%
*-commutative99.5%
Applied egg-rr99.5%
associate-*l/99.8%
*-un-lft-identity99.8%
frac-sub91.7%
*-un-lft-identity91.7%
Applied egg-rr91.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in x around inf 99.8%
mul-1-neg99.8%
Simplified99.8%
if -1.45e9 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 97.8%
if 1 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
*-commutative99.6%
remove-double-neg99.6%
distribute-frac-neg299.6%
tan-neg99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
tan-neg99.7%
distribute-neg-frac299.7%
distribute-neg-frac99.7%
remove-double-neg99.7%
Simplified99.7%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
associate-*l/99.7%
*-un-lft-identity99.7%
frac-sub95.8%
*-un-lft-identity95.8%
Applied egg-rr95.8%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in B around 0 98.5%
Final simplification98.5%
(FPCore (B x) :precision binary64 (if (or (<= x -1.5) (not (<= x 1.0))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.5) || !(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.5d0)) .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.5) || !(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.5) 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.5) || !(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.5) || ~((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.5], 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.5 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.5 or 1 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
*-commutative99.6%
remove-double-neg99.6%
distribute-frac-neg299.6%
tan-neg99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
associate-*l/99.8%
*-un-lft-identity99.8%
frac-sub94.0%
*-un-lft-identity94.0%
Applied egg-rr94.0%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in x around inf 98.0%
mul-1-neg98.0%
Simplified98.0%
if -1.5 < x < 1Initial program 99.8%
Taylor expanded in x around 0 96.1%
Final simplification97.1%
(FPCore (B x) :precision binary64 (if (<= B 0.00022) (/ (- 1.0 x) B) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 0.00022) {
tmp = (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 (b <= 0.00022d0) then
tmp = (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 (B <= 0.00022) {
tmp = (1.0 - x) / B;
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 0.00022: tmp = (1.0 - x) / B else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 0.00022) tmp = 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 (B <= 0.00022) tmp = (1.0 - x) / B; else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 0.00022], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 0.00022:\\
\;\;\;\;\frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 2.20000000000000008e-4Initial program 99.8%
Taylor expanded in B around 0 72.1%
if 2.20000000000000008e-4 < B Initial program 99.4%
Taylor expanded in x around 0 38.4%
Final simplification63.5%
(FPCore (B x) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.34))) (/ x (- B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(x <= 0.34)) {
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 <= 0.34d0))) 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 <= 0.34)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.0) or not (x <= 0.34): tmp = x / -B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.34)) 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 <= 0.34))) 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, 0.34]], $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 0.34\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1 or 0.340000000000000024 < x Initial program 99.6%
Taylor expanded in B around 0 53.3%
Taylor expanded in x around inf 52.3%
neg-mul-152.3%
distribute-neg-frac52.3%
Simplified52.3%
if -1 < x < 0.340000000000000024Initial program 99.8%
Taylor expanded in B around 0 57.0%
Taylor expanded in x around 0 55.2%
Final simplification53.6%
(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%
Taylor expanded in B around 0 55.3%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
Simplified55.2%
Taylor expanded in x around 0 55.4%
+-commutative55.4%
associate-+l+55.4%
*-commutative55.4%
mul-1-neg55.4%
sub-neg55.4%
div-sub55.4%
Simplified55.4%
Final simplification55.4%
(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 55.0%
Final simplification55.0%
(FPCore (B x) :precision binary64 (* B 0.16666666666666666))
double code(double B, double x) {
return B * 0.16666666666666666;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = b * 0.16666666666666666d0
end function
public static double code(double B, double x) {
return B * 0.16666666666666666;
}
def code(B, x): return B * 0.16666666666666666
function code(B, x) return Float64(B * 0.16666666666666666) end
function tmp = code(B, x) tmp = B * 0.16666666666666666; end
code[B_, x_] := N[(B * 0.16666666666666666), $MachinePrecision]
\begin{array}{l}
\\
B \cdot 0.16666666666666666
\end{array}
Initial program 99.7%
Taylor expanded in B around 0 55.3%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
Simplified55.2%
Taylor expanded in B around inf 3.3%
*-commutative3.3%
Simplified3.3%
Final simplification3.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 55.0%
Taylor expanded in x around 0 26.7%
Final simplification26.7%
herbie shell --seed 2024077
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))