1 | initial version |
What your code for f(t)
does is first take the sum symbolically up to 1000 terms, and then evaluate numerically.
What you want to do instead is calculate the terms numerically and sum them.
For example, like this:
def f(t):
return (1+b1)^-t + 3/2*a1^-t + 1/2*(2*b1)^-t + b1^-t + 2*sum((an^-t +an1^-t + anr^-t + 2*bn^-t +2*bn1^-t + bnr^-t).subs(n=k).n() for k in range(1,1000))
The method solve
is used to find exact solutions. For approximate solutions you can use e.g. find_root
:
find_root(lambda t: f(t) - 1, 1.48, 1.52)
It yields 1.5111899890344738
, and f(1.5111899890344738)
is approximately 1.00000000000000
.
2 | No.2 Revision |
What your code for f(t)
does is first take the sum symbolically up to 1000 terms, and then evaluate numerically.
What you want to do instead is calculate the terms numerically and sum them.
For example, like this:
def f(t):
return (1+b1)^-t + 3/2*a1^-t + 1/2*(2*b1)^-t + b1^-t + 2*sum((an^-t +an1^-t + anr^-t + 2*bn^-t +2*bn1^-t + bnr^-t).subs(n=k).n() for k in range(1,1000))
xrange(1,1000))
The method solve
is used to find exact solutions. For approximate solutions you can use e.g. find_root
:
find_root(lambda t: f(t) - 1, 1.48, 1.52)
It yields 1.5111899890344738
, and f(1.5111899890344738)
is approximately 1.00000000000000
.