Honestly, it's a school task 5th grade.
You can't be the equation of the line?
You have two points, for example (tнач;0) and (0;U). Make a system of equations to be solved, we obtain the equation of the line.
You can use a more advanced form of saw-tooth*rectangular.
To initialize the array even easier. Need to run a loop for x from-infinity to infinity (or other boundaries), substituting each x in your function and storing the resulting value, for example, in the list.