A fly starts out 2 meters from a lightbulb, flies closer to the light, then flies away 2 meters again, goes towards the bulb , hits the bulb and finally flies away

lightbulb

#1

A fly starts out 2 meters from a lightbulb, flies closer to the light, then flies away 2 meters again, goes towards the bulb , hits the bulb and finally flies away. Can you write a function for this?

Answer:

(t) = { 2 when t = 0,
2-t for t between 0 and x
2+t fot t between x and y
2-t for t after y until f(t) = 0
(any function as long as it does not approach(0,0) again }