How do I get the exact x value that find-root used
I was using this simple algorithm to find roots, but it occurred to me that I want the exact x-value at the point where find_root locates the yval. Except I'm only using the last xval. I'm unclear how I could get the actual xval that find_root used when finding the zero.
roots=[]
for xval in [-10..5,step=.1]:
try:
yval=find_root(cos(x)-exp(x),xval,xval+.1)
roots.append((xval,0))
except:
pass