Ask Your Question
0

How do I get the exact x value that find-root used

asked 2020-10-22 03:17:45 +0200

cybervigilante gravatar image

updated 2020-10-22 03:27:15 +0200

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
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-10-22 17:04:00 +0200

Emmanuel Charpentier gravatar image

The answer(s) of interest is(are) the yval values, the xval values are the bounds of the search interval. If those are the bounds you are interested in, you may try :

roots=[]
for xval in [-10..5, step=.1]:
    try;
        yval = find_root(cos(x)-exp(x), xval, xval+.1
        root.append((xva, yval, xval+.1))
    except:
        pass

which gives you a list of solution bracketed by the search bounds leading to them, but I have trouble seeing the point...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-10-22 03:17:45 +0200

Seen: 114 times

Last updated: Oct 22 '20