I have a function:
$f(n) = 1 - \left(\frac{1}{n}\right)$
I want to add another variable $k$ to this equation such that: if $k=n$ , then $f(n,k)=1$
if $n=1$, then $f(n,k)=0$ How can we do that ?
I have a function:
$f(n) = 1 - \left(\frac{1}{n}\right)$
I want to add another variable $k$ to this equation such that: if $k=n$ , then $f(n,k)=1$
if $n=1$, then $f(n,k)=0$ How can we do that ?
Consider the function
$g(n,k) = 1 - \frac{1}{n} + \frac{1}{k}$
Then if $k = n$, you have $g(n,k) = 1$. (Note that $n$ and $k$ can not be equal to $0$.)
As Ross Millikan suggested, for your new question, you can consider the function:
$h(n,k) = \begin{cases} g(n,k) & \quad n \neq 1 \\ 0 & \quad n = 1 \end{cases}$
$h$ is a perfectly good function and satisfy the property that $n \neq 1$ and $k = n$, then $h(n,k) = 1$; and if $n = 1$, then for all $k$, $h(n,k) = 0$.
For the first part, a key point is that if $ab=0$, then $a=0$ or $b=0$. So this suggests that whatever you add on should be multiplied by what you already have, since the equation as you give it solves $f(1,k)=0$. Multiplying all that by something won't change the result.
Similarly, for the second part, what simple relationship gives $1$ when two numbers are equal? There's a basic operation that does exactly what you want for that part. Stick them together and you should have a suitable solution.
Assuming that the following statement will never be true - n=k=1 - you can also do this without an "if" statement. Try $(1-\frac{1}{n})^{n-k}$. If n=1, then the fraction $\frac{1}{n}$ will be $\frac{1}{1}=1$, and $1-1=0$. $0^{anything} = 0$. The other issue is if $n=k$. In this case, $n-k = 0$ and $anything^0 = 1$.
I think this equation is also good because at $f(1,1)$, your constraints have given both of the values $0$ and $1$, so it is undefined at $f(1,1)$. At $f(1,1)$, my equation gives you $0^0$, which is undefined.