Ask Your Question

# Finding solution to nonlinear equations numerically in a range

Hi,

this question is probably quite easy to solve. I've got two nonlinear equations with a solution in the range of (0,1). As described in the sage tutorial I tried the following:

var('p t')
eq2 = p==1 - (1 - (1 - (1 - 0.01)^1036)^20)*(1 - t)^(9)
eq1 = t==(2*(1 - 2*p))/((1 - 2*p)*16 + 15*p(1 - (2*p)^1023))
solns = solve([eq1,eq2],t, solution_dict=True)
[[s[t].n(10)] for s in solns]


Unfortunately this doesn't work. In addition I tried find_root, but failed miserably. Any ideas?

edit retag close merge delete

## 2 answers

Sort by ยป oldest newest most voted

You can also use mpmath

from mpmath import *
mp.dps = 30; mp.pretty = True
f1 = lambda t,p:1 - (1 - (1 - (1 - 0.01)**1036)**20)*(1 - t)**(9)-p
f2 = lambda t,p:(2*(1 - 2*p))/((1 - 2*p)*16 + 15*p*(1 - (2*p)**1023))-t
findroot([f1,f2],(1,1))
[2.39470409963011871605945052144e-309]
[    0.999398871164408619804930822283]

more

Hi, the system is special in some sense, I think that you can do the following

var('t')
p=1 - (1 - (1 - (1 - 0.01)^1036)^20)*(1 - t)^(9)
eq1 = t==(2*(1 - 2*p))/((1 - 2*p)*16 + 15*p(1 - (2*p)^1023))
eq1.find_root(-100,100)


and then

p.subs(t=_)

more

## Your Answer

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

Add Answer

## Stats

Asked: 2012-10-15 12:15:30 -0600

Seen: 252 times

Last updated: Oct 15 '12