# Defining a function with certain properties

I'm a bit rusty in mathematics so I need your help please :)

I need a function $y$ that satisfies: \begin{align*} y &= ax\\ y &= \left\{\begin{array}{ll} x &\text{if }x\geq 0;\\ 0 &\text{if }x\lt 0. \end{array}\right. \end{align*}

Is there a way to do this? What should $a$ be like? I believe I need something that is $1$ for positive value and $0$ for negative.

Thank you

-
$y=x$ for $x\ge 0$ and $y=0$ for $x<0$ is already a complete definition of a function. This function fulfills $y=ax$ with $a=1$ for $x\ge0$ and with $a=0$ for $x<0$, so if you wanted the function to fulfill $y=ax$ everywhere with a single $a$, then that contradicts the other two conditions. –  joriki Apr 12 '11 at 14:39
Guessing on the basis of Ross' answer: Did you mean you want $y=ax$ with different $a$ for positive and negative $x$? And does "something" in the last sentence refer to $a$? In that case, you've already got it all figured out correctly -- if you plug $a=1$ for $x\ge0$ and $a=0$ for $x<0$ into $y=ax$, you get $y=x$ for $x\ge0$ and $y=0$ for $x<0$. –  joriki Apr 12 '11 at 14:48
Please spend some effort making your titles informative. "Anybody know a way to" is not informative. –  Arturo Magidin Apr 12 '11 at 18:49

You can certainly define a function as $\begin {cases} y=ax \text{ if } x\ge 0 \\ y=0 \text{ if } x \lt 0 \end {cases}$. It follows the negative $x$ axis from the left to the origin, then slopes up at slope $a$ and you can choose $a$ to fit your needs (like $1$). I don't know any simpler way to express it.

-
Thank you for your answers, a friend just came about with the solution. all I needed is y = max(0,x). –  Laodimos Apr 12 '11 at 14:46
What you have written is already a function. A function is anything such that, when given an input, to specifies exactly one output - there is no requirement that a function be given by a "formula" in terms of the input. For example, here is a function that takes in real numbers and outputs real numbers: $$f(x)=\begin{cases}2x\text{ if }x>2\\5\text{ if }x=2\\(-1)^{\lfloor x\rfloor}\text{ if }0<x<2\\ \pi\cdot e^x\text{ if }x<0\end{cases}$$ It has no nice "formula" in terms of $x$, but it is still a function.
However, if you want something to write in place of $a$ to make the formula $y=a\cdot x$ do what you want, you can use the Iverson bracket, specifically $$[x\geq0]=\begin{cases}1\text{ if }x\geq 0\\0\text{ if }x<0\end{cases}$$
It is not absolutely clear what is asked for. But maybe what is wanted is $$y=(x + |x|)/2$$
And if one is allergic to $|x|$ it can be replaced by $\sqrt{x^2}$. –  André Nicolas Apr 12 '11 at 14:52