Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem with find_root

Hello, I'm running into a problem with "find_root." To give an example, when I use the following code, "find_root" returns a value that is not a root:


sage: var('q') sage: h = ((q+.2(40 - q))^-0.5)/((40-q+.2(q))^-0.5) == ((q+.2(40 - q))^.5-(50)^.5+(50-8)^.5)/((40-q+.2(q))^0.5-(50)^.5+(50-32)^.5) sage: h_a = find_root(h, 0, 40) sage: print h_a sage: #h_a = 11.76222222321 sage: t = ((h_a+.2(40 - h_a))^-0.5)/((40-h_a+.2(h_a))^-0.5) sage: print t sage: z = ((h_a+.2(40 - h_a))^.5-(50)^.5+(50-8)^.5)/((40-h_a+.2(h_a))^0.5-(50)^.5+(50-32)^.5) sage: print z 40.0 0.447213595499989

3.56694309609917e13

As you can see, sage returns a root of 40, which is not a root (to check this, note that t does not equal z). My question is why find_root is doing this. There are several ways in which I could fix the problem "locally;" e.g. setting the bounds between 0 and 30 returns the correct root of 11.76, but I need to eliminate the error to apply my code to a more general problem. Please let me know if I am doing something wrong here!

Thanks!

Problem with find_root

Hello, I'm running into a problem with "find_root." To give an example, when I use the following code, "find_root" returns a value that is not a root:


sage: var('q') var('q')

sage: h = ((q+.2(40 - q))^-0.5)/((40-q+.2(q))^-0.5) == ((q+.2(40 - q))^.5-(50)^.5+(50-8)^.5)/((40-q+.2(q))^0.5-(50)^.5+(50-32)^.5) (q))^0.5-(50)^.5+(50-32)^.5)

sage: h_a = find_root(h, 0, 40) 40)

sage: print h_a h_a

sage: #h_a = 11.76222222321 11.76222222321

sage: t = ((h_a+.2(40 - h_a))^-0.5)/((40-h_a+.2(h_a))^-0.5) (h_a))^-0.5)

sage: print t t

sage: z = ((h_a+.2(40 - h_a))^.5-(50)^.5+(50-8)^.5)/((40-h_a+.2(h_a))^0.5-(50)^.5+(50-32)^.5) (h_a))^0.5-(50)^.5+(50-32)^.5)

sage: print z 40.0 z

40.0

0.447213595499989

3.56694309609917e13

As you can see, sage returns a root of 40, which is not a root (to check this, note that t does not equal z). My question is why find_root is doing this. There are several ways in which I could fix the problem "locally;" e.g. setting the bounds between 0 and 30 returns the correct root of 11.76, but I need to eliminate the error to apply my code to a more general problem. Please let me know if I am doing something wrong here!

Thanks!