Firstly, thank you very much in advance. I need to express a non-linear graph comprised (piecewise) of the following linear elements:
- A line from $(x=0,y=100)$ to $(x=10,y=100.5)$
- A line from $(x=10,y=100.5)$ to $(x=30,y=99.5)$
- A line from $(x=30,y=99.5)$ to $(x=40,y=100.5)$
I need to implement this in a program I am writing in C++.
Assuming you know how to compute $a$ and $b$ for a straight line $y=a+ b x$ foing through two points, you will end with something looking like
Y = 0.0
IF(X.GE.0.0.AND.X.LE.10.0) THEN
Y = 100.0 + 0.05 * X
ELSE IF(X.LT.30.0) THEN
Y = 101.0 - 0.05 * X
ELSE IF(X.LT.40.0) THEN
Y = 96.5 + 0.10 * X
ENDIF