All problems

Extending the Fit Line Beyond the Data With truncate

mediumPythonSeaborntruncate

By default the rig chart stops its fitted line at the smallest and largest loads actually applied; Calder Engineering's client wants it extended across the full axis, because they intend to quote for loads outside the tested range. The sheet therefore carries the line's value at one particular load, whether or not that load was ever tested.

Task: Print the value the fitted line gives at the requested x.

Input

The first line holds one integer n, the number of readings, where 2 <= n <= 1000. Then come n lines, each holding a reading's x and y separated by a single space, x first. Not every reading has the same x. The final line holds the x the client is asking about, which may sit outside the tested range.

Output

One line, rounded to 2 decimal places: the least-squares line's value at that x, found from its slope and its intercept together. Print whatever the line gives -- it is not clipped at zero, and a value landing a hair below zero prints as -0.00.

Example:

Input:
3
1 2
2 4
3 6
10

Output:
20.00

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…