# How can I write a formula for this linear segments graph?

I have the following data:

60 items = $1 3,600 items =$20

86,400 items = $260 604,800 items =$1,000

Which I have used to make a line graph like so:

Is there a way I can express this graph as a formula? That I can then use the find the price of any quantity of items.

Note: I do not wish to create a smooth curve. The graph it produces needs to consist of linear segments as in the example image.

-

\begin{equation*} \left. \begin{array}{c} i \\ 0 \\ 1 \\ 2 \\ 3 \\ 4 \end{array} \begin{array}{c} x_{i} \\ 0 \\ 60 \\ 3600 \\ 86400 \\ 604800 \end{array} \begin{array}{c} y_{i}\text{ (\$)} \\ 0 \\ 1 \\ 20 \\ 260 \\ 1000 \end{array} \right. \end{equation*} The equation of the line segment between$\left( x_{i},y_{i}\right) $and$\left( x_{i+1},y_{i+1}\right) $is$^1$\begin{equation*} y=\frac{y_{i+1}-y_{i}}{x_{i+1}-x_{i}}(x-x_{i})+y_{i}\qquad i=0,1,2,3.\tag{1} \end{equation*} The function$yis defined by cases as \begin{align} y&= \begin{cases} \dfrac{1}{60}x &\text{ if }&0\leq x\leq 60\\[2ex] \dfrac{19}{3540}x+\dfrac{40}{59} &\text{ if }&60\leq x\leq 3600\\[2ex] \dfrac{1}{345}x+\dfrac{220}{23} &\text{ if }&3600\leq x\leq 86400\\[2ex] \dfrac{37}{25920}x+\dfrac{410}{3}&\text{ if }&86400\leq x\leq 604800.\\[2ex] \end{cases} \tag{2} \end{align} The computation was carried out by applying the above equation to(x_i,y_i)$for$i=0,\ldots ,3\begin{align} y_{\text{section 1}} &=\frac{1-0}{60-0}(x-0)+0=\frac{1}{60}x \\[2ex] y_{\text{section 2}} &=\frac{20-1}{3600-60}(x-60)+1 =\frac{19}{3540}x+\frac{40}{59} \\[2ex] y_{\text{section 3}} &=\frac{260-20}{86400-3600}(x-3600)+20 =\frac{1}{345}x+\frac{220}{23} \\[2ex] y_{\text{section 4}} &=\frac{1000-260}{604800-86400}(x-86400)+260 =\frac{37}{25\,920}x+\frac{410}{3}. \end{align} --^1$The equation of a straight line is of the form $$y=mx+b\tag{A}$$ If the line passes through$P_i(x_i,y_i)$, then $$y_i=mx_i+b\tag{B}$$ By subtracting both equations we eliminate$b$$$y-y_i=mx-mx_i=m(x-x_i)\tag{C}$$ If it passes through$P_{i+1}(x_{i+1},y_{i+1})$too, the angular coefficient$m$is given by $$m=\frac{y_{i+1}-y_i}{x_{i+1}-xi}\tag{D}$$ Finally substituting$m$in$(\text{C})$yields$(1)\$.