# 计算方法| Computational Methods写 MATH0058

0

In many applications there is need for an indicator function, which is 1 over some interval and 0 elsewhere. More precisely, we define
$$I(x ; L, R)= \begin{cases}1, & x \in[L, R] \ 0, & \text { elsewhere }\end{cases}$$

a) Make two Python implementations of such an indicator function, one with a direct test if $x \in[L, R]$ and one that expresses the indicator function in terms of Heaviside functions :
$$I(x ; L, R)=H(x-L) H(R-x)$$
b) Make a test function for verifying the implementation of the functions in a). Check that correct values are returned for some $xR$.

## MATH0058 COURSE NOTES ：

involves four parameters: $A, A_{0}, p$, and $n$. We may solve for any of these, given the other three:
\begin{aligned} A_{0} &=A\left(1+\frac{p}{360 \cdot 100}\right)^{-n}, \ n &=\frac{\ln \frac{A}{A_{0}}}{\ln \left(1+\frac{p}{360 \cdot 100}\right)}, \ p &=360 \cdot 100\left(\left(\frac{A}{A_{0}}\right)^{1 / n}-1\right) \end{aligned}