2

I'm wondering if there is a mathematical solution to the following.

I have a very simple formula of y=x*0,2.

However, if x < 100 it should result in 20, if x > 100, it should result in x*0,2.

Some examples:

  • x=10, y should be 20
  • x=50, y should be 20
  • x=150, y should be 30
  • x=400, y should be 80

I can solve this programmatically by writing a function in whatever programming language is out there but I'm curious if there is another solution too.

Any ideas?

Edit: not sure why this was put on hold as there are two answers that fit the description. Can someone explain what is unclear or is it common practice to just report it and not explain why?

ju5t
  • 23
  • 1
    You should state the problem in a more clear way. – user Sep 14 '18 at 10:19
  • Maybe $f(x)=20$ for $x>100$? – user Sep 14 '18 at 10:20
  • Sorry if it wasn't explained properly (and I pressed enter too soon). I will update my initial question with some examples. – ju5t Sep 14 '18 at 10:25
  • What you're saying is self-contradicting. You're saying that if $x<100 \Rightarrow f(x) = 20$ but if $x>20$ then $f(x) = 0.2x$. So what's the value, for example if $x=50$? 20 or $0.2x$ ? – Matti P. Sep 14 '18 at 10:25
  • Also, what's the practical problem you are facing? Clearly, you are defining some sort of partially defined function. Then what? Do you wish to implement it in some code or ...? – Matti P. Sep 14 '18 at 10:27
  • You're right, the initial question was self-contradicting. Sorry about that. Yes, it will be part of code but out of curiosity I was wondering if there is a mathematical solution for it too. Thanks for all the replies so far! – ju5t Sep 14 '18 at 10:30
  • $f(x)=10+0.1,x+0.1,|x-100|$ ? – random Sep 14 '18 at 11:03

2 Answers2

0

You can use the piecewise function:

$$ f(x)= \left\{ \begin{array}{c} 20, & \text{if}\ x < 100 \\ 0.2x, & \text{if} \ x > 100\\ \end{array} \right. $$

This is basically a combination of different functions, each defined at different ranges.

Toby Mak
  • 16,827
0

You can think like that; the main function is $f(x)=0.2x$. Lets say we want $f(x)$ for all negative numbers to be $0$, you should add $0.2|x|$ to the function, and then divide by $2$, you get $f(x)=0.1x+0.1|x|$.

Now you want $y$ to continue being a constant until $x=100$, so you should shift the graph to the right with $100$, the way to do that is replace $x$ with $x-100$. so we get $f(x)=0.1(x-100)+0.1|x-100|$.

finally you add $20$ to get the function that you need;

$$f(x)=0.1(x-100)+0.1|x-100|+20=0.1x-10+0.1|x-100|+20=\\=0.1x+0.1|x-100|+10$$

76david76
  • 1,535