All problems

One Step Downhill

easyPythonGradient Descent

Kestrel Freight's model trainer has one dial left to set, and a test rig to practise on. On the rig the penalty for any setting is known exactly: it is the square of the distance between that setting and the ideal one, so the penalty is zero at the ideal setting and grows the further away you are, in either direction. The trainer never jumps straight to the answer, because on real data the ideal setting is not known. Instead it reads how steeply the penalty is changing where it currently stands, and moves downhill from there. How far one move travels is governed by the learning rate: the step taken is the learning rate's worth of that steepness, so a bigger rate travels further per move.

Task: Take one gradient-descent step from the starting setting and print where it lands.

Input

One line holding three numbers separated by single spaces: the starting setting, the ideal setting the penalty is measured against, and the learning rate.

Output

One line: the word w1, a single space, and the setting after that single step, rounded to 4 decimal places.

Example:

Input:
0 4 0.1

Output:
w1 0.8000

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…