Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Tiny results of find root

    I was finding roots with a simple loop but got two odd results:

    g(x) = (x^2)*cos(2*x)
    for num in [-10..10,step=.1]:
        try:
            root=find_root(g,num,num+.1)
            print(root)        
        except:
            pass

    -8.639379797371932
    -7.0685834705770345
    -5.497787143782152
    -3.9269908169872405
    -2.356194490192345
    -0.7853981633974483
    -7.755114791616843e-09 
Are these two actual roots or a numerical error and how would I tell the difference?
    7.755077210568017e-09
    0.7853981633974483
    2.356194490192345
    3.9269908169872405
    5.497787143782152
    7.0685834705770345
    8.639379797371932