Say I have an equation where the value is $m-4$ when $m \ge 5, n=3,4$; $n-4$ when $n \ge 5, m=3,4$; and $m+n-9$ when $m,n \ge 5$. How can I combine these all into one statement? How can I combine them with further ones, like $m-6$ where $m \ge 7, n \in [3,6]$, etc?
How to combine cases
-
0yes... I'm saying that if they are ALSO greater than or equal to 5, then add those things as well. – 2010-11-14
3 Answers
I think for the first statement the following formula should work with the given domain: $f(m,n)=(m-4)H[m-5]+(n-4)H[n-5]+H[m-5]H[n-5]$ where H is the heaviside step function.
I think the phrasing for the second part can be improved, judging from your comments above. From what I gather you can add terms such as $(m-6)H[m-7]$ for the later conditions.
For your first question, it turns out that on the values you've specified, $f(m,n) = \max(m-5,0)+\max(n-5,0) + 1$. In general, if you're trying to get a handle on a function of many variables, it's a good idea to see if it can be separated into a combination of functions of fewer variables.
For your second question, if what you mean is that you want to add $m - 6$ to the output if certain conditions are satisfied, and leave it alone otherwise, you could define $g(m,n) = f(m,n) + h(m,n)$, where $h(m,n)$ is either $m-6$ or zero depending on etc etc. Or you could just write out all the cases of $g(m,n)$, which is the systematic but mind-numbing way.
$ f(n,m) = \begin{cases} m-4 & m \geq 5,\, n=3,4, \\ n-4 & n \geq 5,\, m=3,4, \\ m+ n - 9 & m,n \geq 5. \end{cases}$