f2 =
Do you understand how floating point arithmetic works? That you only have a finite number of digits, and that when you subtract two numbers that are almost equal, then you get in trouble? MATLAB does not compute in infinite precision. This is commonly called massive subtractive cancellation. For example, if we compute the difference of two numbers, perhaps
a1 = @(x) 1 + x;
a2 = @(x) 1 + sin(x);
Now, when x is very small, we might expect to see a simple, smooth curve. After all, both functions are well defined, right?
fplot(@(x) a1(x) - a2(x),[-1e-5,1e-5])
The difference between the two functions should look almost live a cubic polynomial. What happened? Massive subtractive cancellation. Note that to make things really bad, I added both x and sin(x) to 1. Instead, plot this on the same interval.
fplot(@(x) x - sin(x),[-1e-5,1e-5])
Mathematically, the two expressions to plot are identical. But in terms of floating point arithmetic, they are not even close. I would note that on a narrower interval yet, even forming the differece of x and sin(x) will cause problems.
fplot(@(x) x - sin(x),[-1e-7,1e-7])
What did you do at the very end?
% testFunc = @(r,s,sp,k) f2(r,s,sp,k).^2 -4*f1(s,sp,k);
So you created the DIFFERENCE of two expressions that are very nearly equal to each other. The result is expected to be quite small.
% fig1=figure; fplot(@(sp) testFunc(0,0,sp,10), [-5*10^-6 5*10^-6])
And you saw floating point trash in the result. SURPRISE!
What could you have done? You might consider using symbolic tools to perform the same computations. Now you could work in sufficiently high precision to avoid the floating point trash.