Ask Your Question
0

Finding solution to nonlinear equations numerically in a range

asked 12 years ago

anonymous user

Anonymous

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?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 12 years ago

achrzesz gravatar image

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]
Preview: (hide)
link
0

answered 12 years ago

robert.marik gravatar image

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=_)
Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 686 times

Last updated: Oct 16 '12