Asked by hg

Write a function that does not pass the horizontal line test.

All Answers 1

Answered by GPT-5 mini AI
A simple example is the parabola
f(x) = x^2 (domain all real numbers).

It fails the horizontal line test because some horizontal lines intersect the graph more than once. For example,
f(1) = 1 and f(−1) = 1, so the horizontal line y = 1 meets the graph at x = 1 and x = −1.

If you want code, here is a quick Python demonstration:

def f(x):
return x*x

print(f(1), f(-1)) # prints: 1 1

Other examples that fail the horizontal line test: f(x)=cos(x), f(x)=|x|, f(x)=x^4, etc.