Ask Your Question
0

Finding solution to nonlinear equations numerically in a range

asked 2012-10-15 12:15:30 -0500

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?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2012-10-15 20:24:20 -0500

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]
edit flag offensive delete link more
0

answered 2012-10-15 18:33:04 -0500

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=_)
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

Stats

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

Seen: 277 times

Last updated: Oct 15 '12