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?
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$$