Learning an arbitrary function using a feedforward net
You need to scale the input. Neural networks work best with a limited input domain, and train badly when it is exceeded.

For statistical data, you would typically scale your input to have mean 0, standard deviation 1.

Here, you will be better off fitting the input to roughly -1 to 1. 

Up to you where you scale the values, but usually this is done outside of the NN code. So I would do something like:

nn_input = (t - 15)/15


And then use nn_input in the training and evaluation loops. As you are putting these directly into a sorted array for plotting, you won't need to do any further re-mapping back or maintain a conversion function. However, in the more common case of arbitrary inputs, you would need to store the conversion factors somewhere (in this case just hardcoded as a function perhaps) in order to make use of the trained NN.

Another thing that may help is shuffling your input/output data pairs during training to remove correlation between sequence of input pairs.