Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to represent a graph in a function?

For example, I used 3 functions :

$$f(x)=x^2$$ $$g(x)=x$$ $$h(x)=3$$

These 3 functions were plotted on the same graph and the result (after edit) is as given below

How would you represent the below graph in a function, lets say $k(x)$ ?

enter image description here

share|cite|improve this question
up vote 31 down vote accepted

You can simple define $k$ to be a piecewise function:

$$k(x) := \begin{cases}x^2 & 0 \le x < 1\\ x & 1 \le x < 3\\3 & 3 \le x\end{cases}$$

Now if you really don't like that, you can work out something using $\min$:

$$k(x) = \min(x^2, x, 3)$$

But not all piecewise functions have such a nice "closed" form.

share|cite|improve this answer

You'd use a piecewise function. In this case, we have $$ k(x) = \begin{cases} x^2 & 0 \leq x \lt 1 \\ x & 1 \leq x \lt 3 \\ 3 & x \geq 3 \end{cases} $$

share|cite|improve this answer
    
This is incorrect. What makes you think $k(x)$ is defined for $-18$ when it is not on the graph? – MathematicsStudent1122 Feb 19 at 18:46
4  
@MathematicsStudent1122 That seems more like a fault in the question than a fault in the answer; it's ambiguous and it seems rather unfair to call this incorrect when it does coincide with what we see in the range we see it in (and we were not given any instruction about the range we don't see it in) – Milo Brandt Feb 19 at 21:33
    
@MiloBrandt When Student originally commented, I had $-\infty \lt x \lt 1$ for the first case; it could still work due to the ambiguity you mentioned, but it was potentially inaccurate. – DylanSp Feb 19 at 21:37
    
@DylanSp After the edit, I have removed the downvote. – MathematicsStudent1122 Feb 19 at 22:03

Depending on the context, it might also be useful to represent the function using Heaviside's step function $H(x)$, which equals $0$ for $x < 0$ and $1$ for $x > 0$. You could also define $H(0)=0$ or $H(0) = 1$ if you want, but it might not be so important, again depending on the context.

With this notation, your function may be written as $$k(x) = x^2(H(x)-H(x-1))+x(H(x-1)-H(x-3))+3H(x-3),$$ or, collecting the Heaviside terms, $$k(x) = x^2H(x)+x(1-x)H(x-1)+(3-x)H(x-3).$$

This is really just a shorthand notation for the piecewise function we're dealing with, but it is very useful for example if you're working with distributions. Also note that it doesn't really matter whether we define $H(0)=0$ or $H(0) = 1$, as $k$ evaluates to the same value at $x=1$ and $x=3$ either way, as clearly seen from the second expression of $k$.

share|cite|improve this answer
1  
In this case defining H(0)=0 or H(0)=1 is not important, but with a discontinuous piecewise function it could matter. – Nick Feb 20 at 17:40
    
@Nick Yes, indeed. – Étienne Bézout Feb 20 at 19:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.