[SciPy-User] Sequence not work

Robert Kern robert.kern@gmail....
Wed Mar 27 06:14:04 CDT 2013


On Wed, Mar 27, 2013 at 3:11 AM, El suisse <elsuizo37@gmail.com> wrote:

> Hi
> I have to represent the following sequence:
>
> [image: z[2]=2]
> [image: z[n+1]=2^{n-1/2}\sqrt{1-\sqrt{1-4^{1-n}z[n]^{2}}]  [image:
> n=2,3,4....]
>
>
> and my code is as follows:
>
>
> #!/usr/bin/env python
>
>
> import matplotlib.pyplot as plt
>
> import numpy as np
>
>
> num_muestras = 100
>
> z = np.zeros(num_muestras)
>
>
>
> z[2] = 2.0  #En Python se cuenta desde el cero
>
> for n in range(2,num_muestras-1):
>
>
>     z[n+1] = np.power(2,n-(1/2)) * (np.sqrt(1- np.sqrt(1-np.power(4,1-n) *
> np.power(z[n],2))) )
>

(1/2) should be 0.5 . (1/2) gives 0, not 0.5. The division of integers in
Python 2.x defaults to returning an integer, not a floating point number
(for a variety of reasons that you can Google for if you want an
explanation).

-- 
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130327/e0939d80/attachment.html 


More information about the SciPy-User mailing list