A function that depends on properties of the input argument?

170 Views Asked by At

I was just wondering if one can write a mathematical function whose parameters depend on the properties of the input argument, and if yes, then how. Say, for example, a function that gives out the square of the argument if the argument if odd and gives out cube of the argument if the argument is even. How do I write this function mathematically? Also, how do I study this function and understand its properties? Any help regarding this, including other resources, would be very helpful.

PS: I belong to the field of biochemistry, so I don't have much knowledge regarding mathematics, I just keep studying maths as a hobby; so forgive me if my question is too naïve. Also, sorry for the computer science-like explanation of my question, I ain't familiar with terminology in this field :)

1

There are 1 best solutions below

0
On BEST ANSWER

You can write the definition of such $f$ like this: $$f(n)=\begin{cases}n^2&\text{if }n\text{ is odd}\\n^3&\text{if }n\text{ is even}\end{cases} $$