
(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 11 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 (sin B)) (cos B))))
double code(double B, double x) {
return (1.0 / sin(B)) - ((x / sin(B)) * cos(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / sin(b)) - ((x / sin(b)) * cos(b))
end function
public static double code(double B, double x) {
return (1.0 / Math.sin(B)) - ((x / Math.sin(B)) * Math.cos(B));
}
def code(B, x): return (1.0 / math.sin(B)) - ((x / math.sin(B)) * math.cos(B))
function code(B, x) return Float64(Float64(1.0 / sin(B)) - Float64(Float64(x / sin(B)) * cos(B))) end
function tmp = code(B, x) tmp = (1.0 / sin(B)) - ((x / sin(B)) * cos(B)); end
code[B_, x_] := N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(N[(x / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Cos[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sin B} - \frac{x}{\sin B} \cdot \cos 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%
tan-quot99.7%
associate-/r/99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (B x)
:precision binary64
(if (<= x -43000.0)
(- 1.0 (/ x (tan B)))
(if (<= x 27000000000.0)
(- (/ 1.0 (sin B)) (/ x B))
(/ (* x (cos B)) (- (sin B))))))
double code(double B, double x) {
double tmp;
if (x <= -43000.0) {
tmp = 1.0 - (x / tan(B));
} else if (x <= 27000000000.0) {
tmp = (1.0 / sin(B)) - (x / B);
} else {
tmp = (x * cos(B)) / -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 <= (-43000.0d0)) then
tmp = 1.0d0 - (x / tan(b))
else if (x <= 27000000000.0d0) then
tmp = (1.0d0 / sin(b)) - (x / b)
else
tmp = (x * cos(b)) / -sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -43000.0) {
tmp = 1.0 - (x / Math.tan(B));
} else if (x <= 27000000000.0) {
tmp = (1.0 / Math.sin(B)) - (x / B);
} else {
tmp = (x * Math.cos(B)) / -Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -43000.0: tmp = 1.0 - (x / math.tan(B)) elif x <= 27000000000.0: tmp = (1.0 / math.sin(B)) - (x / B) else: tmp = (x * math.cos(B)) / -math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -43000.0) tmp = Float64(1.0 - Float64(x / tan(B))); elseif (x <= 27000000000.0) tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); else tmp = Float64(Float64(x * cos(B)) / Float64(-sin(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -43000.0) tmp = 1.0 - (x / tan(B)); elseif (x <= 27000000000.0) tmp = (1.0 / sin(B)) - (x / B); else tmp = (x * cos(B)) / -sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -43000.0], N[(1.0 - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 27000000000.0], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Cos[B], $MachinePrecision]), $MachinePrecision] / (-N[Sin[B], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -43000:\\
\;\;\;\;1 - \frac{x}{\tan B}\\
\mathbf{elif}\;x \leq 27000000000:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \cos B}{-\sin B}\\
\end{array}
\end{array}
if x < -43000Initial 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%
add-exp-log46.3%
log-rec46.3%
Applied egg-rr46.3%
exp-neg46.3%
add-exp-log99.7%
add-sqr-sqrt46.3%
associate-/r*46.3%
metadata-eval46.3%
sqrt-div46.3%
add-exp-log46.3%
exp-neg46.3%
pow146.3%
pow146.3%
add-sqr-sqrt46.3%
sqrt-unprod46.3%
sqr-neg46.3%
sqrt-unprod0.0%
add-sqr-sqrt45.8%
add-exp-log45.8%
Applied egg-rr45.8%
*-inverses97.9%
Simplified97.9%
if -43000 < x < 2.7e10Initial program 99.7%
Taylor expanded in B around 0 98.7%
if 2.7e10 < 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.6%
*-rgt-identity99.6%
tan-neg99.6%
distribute-neg-frac299.6%
distribute-neg-frac99.6%
remove-double-neg99.6%
Simplified99.6%
tan-quot99.6%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
distribute-frac-neg299.7%
Simplified99.7%
Final simplification98.7%
(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 (<= x -7200.0) (- 1.0 (/ x (tan B))) (if (<= x 6200000.0) (- (/ 1.0 (sin B)) (/ x B)) (* x (/ -1.0 (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -7200.0) {
tmp = 1.0 - (x / tan(B));
} else if (x <= 6200000.0) {
tmp = (1.0 / sin(B)) - (x / 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 <= (-7200.0d0)) then
tmp = 1.0d0 - (x / tan(b))
else if (x <= 6200000.0d0) then
tmp = (1.0d0 / sin(b)) - (x / 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 <= -7200.0) {
tmp = 1.0 - (x / Math.tan(B));
} else if (x <= 6200000.0) {
tmp = (1.0 / Math.sin(B)) - (x / B);
} else {
tmp = x * (-1.0 / Math.tan(B));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -7200.0: tmp = 1.0 - (x / math.tan(B)) elif x <= 6200000.0: tmp = (1.0 / math.sin(B)) - (x / B) else: tmp = x * (-1.0 / math.tan(B)) return tmp
function code(B, x) tmp = 0.0 if (x <= -7200.0) tmp = Float64(1.0 - Float64(x / tan(B))); elseif (x <= 6200000.0) tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / 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 <= -7200.0) tmp = 1.0 - (x / tan(B)); elseif (x <= 6200000.0) tmp = (1.0 / sin(B)) - (x / B); else tmp = x * (-1.0 / tan(B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -7200.0], N[(1.0 - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6200000.0], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7200:\\
\;\;\;\;1 - \frac{x}{\tan B}\\
\mathbf{elif}\;x \leq 6200000:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B}\\
\end{array}
\end{array}
if x < -7200Initial 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%
add-exp-log46.3%
log-rec46.3%
Applied egg-rr46.3%
exp-neg46.3%
add-exp-log99.7%
add-sqr-sqrt46.3%
associate-/r*46.3%
metadata-eval46.3%
sqrt-div46.3%
add-exp-log46.3%
exp-neg46.3%
pow146.3%
pow146.3%
add-sqr-sqrt46.3%
sqrt-unprod46.3%
sqr-neg46.3%
sqrt-unprod0.0%
add-sqr-sqrt45.8%
add-exp-log45.8%
Applied egg-rr45.8%
*-inverses97.9%
Simplified97.9%
if -7200 < x < 6.2e6Initial program 99.7%
Taylor expanded in B around 0 98.7%
if 6.2e6 < x Initial program 99.6%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
associate-/l*99.6%
distribute-rgt-neg-in99.6%
distribute-neg-frac99.6%
Simplified99.6%
distribute-frac-neg99.6%
clear-num99.6%
tan-quot99.6%
neg-sub099.6%
Applied egg-rr99.6%
neg-sub099.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification98.7%
(FPCore (B x) :precision binary64 (if (<= x -1.3) (/ 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.3) {
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.3d0)) 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.3) {
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.3: 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.3) 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.3) 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.3], 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.3:\\
\;\;\;\;\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.30000000000000004Initial program 99.5%
Taylor expanded in x around inf 95.6%
mul-1-neg95.6%
associate-/l*95.5%
distribute-rgt-neg-in95.5%
distribute-neg-frac95.5%
Simplified95.5%
distribute-frac-neg95.5%
clear-num95.3%
tan-quot95.4%
neg-sub095.4%
Applied egg-rr95.4%
neg-sub095.4%
distribute-neg-frac95.4%
metadata-eval95.4%
Simplified95.4%
*-commutative95.4%
associate-*l/95.5%
neg-mul-195.5%
Applied egg-rr95.5%
if -1.30000000000000004 < x < 1Initial program 99.7%
Taylor expanded in x around 0 98.1%
if 1 < x Initial program 99.6%
Taylor expanded in x around inf 98.6%
mul-1-neg98.6%
associate-/l*98.5%
distribute-rgt-neg-in98.5%
distribute-neg-frac98.5%
Simplified98.5%
distribute-frac-neg98.5%
clear-num98.5%
tan-quot98.5%
neg-sub098.5%
Applied egg-rr98.5%
neg-sub098.5%
distribute-neg-frac98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification97.6%
(FPCore (B x) :precision binary64 (if (<= x -1.15) (- 1.0 (/ 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.15) {
tmp = 1.0 - (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.15d0)) then
tmp = 1.0d0 - (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.15) {
tmp = 1.0 - (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.15: tmp = 1.0 - (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.15) tmp = Float64(1.0 - Float64(x / 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.15) tmp = 1.0 - (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.15], N[(1.0 - N[(x / N[Tan[B], $MachinePrecision]), $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.15:\\
\;\;\;\;1 - \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.1499999999999999Initial 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.7%
*-rgt-identity99.7%
tan-neg99.7%
distribute-neg-frac299.7%
distribute-neg-frac99.7%
remove-double-neg99.7%
Simplified99.7%
add-exp-log48.1%
log-rec48.1%
Applied egg-rr48.1%
exp-neg48.1%
add-exp-log99.7%
add-sqr-sqrt48.1%
associate-/r*48.1%
metadata-eval48.1%
sqrt-div48.1%
add-exp-log48.1%
exp-neg48.1%
pow148.1%
pow148.1%
add-sqr-sqrt48.1%
sqrt-unprod48.1%
sqr-neg48.1%
sqrt-unprod0.0%
add-sqr-sqrt45.3%
add-exp-log45.3%
Applied egg-rr45.3%
*-inverses95.5%
Simplified95.5%
if -1.1499999999999999 < x < 1Initial program 99.7%
Taylor expanded in x around 0 98.1%
if 1 < x Initial program 99.6%
Taylor expanded in x around inf 98.6%
mul-1-neg98.6%
associate-/l*98.5%
distribute-rgt-neg-in98.5%
distribute-neg-frac98.5%
Simplified98.5%
distribute-frac-neg98.5%
clear-num98.5%
tan-quot98.5%
neg-sub098.5%
Applied egg-rr98.5%
neg-sub098.5%
distribute-neg-frac98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification97.6%
(FPCore (B x) :precision binary64 (if (or (<= x -1.55) (not (<= x 1.0))) (/ x (- (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.55) || !(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.55d0)) .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.55) || !(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.55) 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.55) || !(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.55) || ~((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.55], 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.55 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.55000000000000004 or 1 < x Initial program 99.6%
Taylor expanded in x around inf 97.0%
mul-1-neg97.0%
associate-/l*97.0%
distribute-rgt-neg-in97.0%
distribute-neg-frac97.0%
Simplified97.0%
distribute-frac-neg97.0%
clear-num96.9%
tan-quot96.9%
neg-sub096.9%
Applied egg-rr96.9%
neg-sub096.9%
distribute-neg-frac96.9%
metadata-eval96.9%
Simplified96.9%
*-commutative96.9%
associate-*l/97.0%
neg-mul-197.0%
Applied egg-rr97.0%
if -1.55000000000000004 < x < 1Initial program 99.7%
Taylor expanded in x around 0 98.1%
Final simplification97.6%
(FPCore (B x) :precision binary64 (if (<= B 0.0044) (/ (- 1.0 x) B) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 0.0044) {
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.0044d0) 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.0044) {
tmp = (1.0 - x) / B;
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 0.0044: tmp = (1.0 - x) / B else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 0.0044) 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.0044) tmp = (1.0 - x) / B; else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 0.0044], 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.0044:\\
\;\;\;\;\frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 0.00440000000000000027Initial program 99.7%
Taylor expanded in B around 0 64.6%
if 0.00440000000000000027 < B Initial program 99.5%
Taylor expanded in x around 0 59.3%
Final simplification63.2%
(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(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 <= 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%
Taylor expanded in B around 0 51.4%
Taylor expanded in x around inf 49.6%
neg-mul-149.6%
distribute-neg-frac249.6%
Simplified49.6%
if -1 < x < 1Initial program 99.7%
Taylor expanded in B around 0 46.9%
Taylor expanded in x around 0 46.3%
Final simplification47.7%
(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 48.8%
Final simplification48.8%
(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 48.8%
Taylor expanded in x around 0 27.2%
Final simplification27.2%
herbie shell --seed 2024057
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))