Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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,yval))
    except:
        pass

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,yval))
roots.append((xval,0))
    except:
        pass