The issue for your goal is your range that you create with
linspace. The default number of samples is 50 for this method and they are evenly reparted so depending on your
2 might not be in this range. Use the
num argument (third position) to increase this value and it will look better but your value might still not be in the range.
(The problem is you’re working on a list of numbers, you can’t work on a infinite set).