Euler’s Method

Challenge

Naturally, your favorite class of the day is AP Calculus BC and you've recently been learning Euler's Method. Your teacher has had a lot on their plate, so they've just been using the same curve for your homework problems every day, y'(x) = x^2 - 6y^2, y(5) = 2. To simplify matters, you're going to write a program to automate this trivial task for you.

For each input, you will receive a space-separated set of two numbers (each between -10 and 10). The first is your step size and the second is the x-value of the point you need the estimated y-value for (to the nearest tenth and incuding trailing zero if necessary). Your output will be between -1,000 and 1,000.

Sample Input 1:0.8 5.8Sample Output 1:2.8

Sample Input 2:0.9 7.7Sample Output 2:-645.1

Notes:

  • the inputs will be passed in (through stdin) separated by newlines; make sure your output is also separated by newlines
  • the first line of input will contain only one integer representing the number of additional lines of input you will receive

Solution