# Selecting polynomial roots and plotting against parameters

An implicit function $f(x,k)=0$ is quadratic in $x$ and contains one parameter $k$ which I must vary. Using Solve, I get two real solutions for each specific $k$: $x_1$ and $x_2$, of which I must choose the one that lies within $[0, 0.5]$. I must do this for a continuum of parameters $k$ between, say, $0$ and $1$. I then must plot the relevant $x$ solution against the parameter $k$ in a smooth curve.

Note: I also tried the unglorious method i.e. if $k$ took discrete values, I thought I could manually select say 30 points and interpolate. But any curve fitting command I tried, using various polynomial and exponential expansions, could not give me smooth curve?

Of course I hope to learn the elegant method, but under time pressure anything that gives me a smooth curve is welcome!

-
A lot easier if you show what f looks like. – b.gatessucks Sep 7 '12 at 7:44
Well, FindRoot[] supports the option of root bracketing; if all you want is an approximate root, it should be fine. Otherwise, since you say it's quadratic in $x$, one could always manipulate the quadratic formula... – J. M. Sep 7 '12 at 8:14

As J. M. says, FindRoot allows two options: either root bracketing, or the simpler choice of starting with an initial approximation for the root that is close enough. Since you said your root is unique in the [0,0.5] interval, and your function is smooth, you can expect that a starting value of 0.25 will usually give you the root you're looking for.
f[x_] := Expand[(x - 0.5*Sin[k^2])*(x - 3*k - 1)]

Additionally, as a guarantee that the iteration never veers off the brackets you have set up, use Brent's method (i.e. append the option setting Method -> "Brent" to FindRoot[]). – J. M. Sep 7 '12 at 9:48