You will write Euler's method for Newton's law of cooling and compare it with the exact formula. A cup of coffee cools in a room at with .
The idea. The rate of change is . Euler's method moves forward by a small step in time and adds to each time. The exact answer is . A smaller step should give a smaller error.
Your tasks.
rate(T). Return for the temperature T, using K and ROOM.euler(T0, t_end, h). Start at T0 and repeat the step round(t_end / h) times. Return the final temperature.exact(T0, t). Return the exact temperature at time t.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…