• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(2949)  |  Call(2655)  |  Derive(0)  |  Import(294)
sin(x[, out])

Trigonometric sine, element-wise.

Parameters
----------
x : array_like
    Angle, in radians (:math:`2 \pi` rad equals 360 degrees).

Returns
-------
y : array_like
    The sine of each element of x.

See Also
--------
arcsin, sinh, cos

Notes
-----
The sine is one of the fundamental functions of trigonometry
(the mathematical study of triangles).  Consider a circle of radius
1 centered on the origin.  A ray comes in from the :math:`+x` axis,
makes an angle at the origin (measured counter-clockwise from that
axis), and departs from the origin.  The :math:`y` coordinate of
the outgoing ray's intersection with the unit circle is the sine
of that angle.  It ranges from -1 for :math:`x=3\pi / 2` to
+1 for :math:`\pi / 2.`  The function has zeroes where the angle is
a multiple of :math:`\pi`.  Sines of angles between :math:`\pi` and
:math:`2\pi` are negative.  The numerous properties of the sine and
related functions are included in any standard trigonometry text.

Examples
--------
Print sine of one angle:

>>> np.sin(np.pi/2.)
1.0

Print sines of an array of angles given in degrees:

>>> np.sin(np.array((0., 30., 45., 60., 90.)) * np.pi / 180. )
array([ 0.        ,  0.5       ,  0.70710678,  0.8660254 ,  1.        ])

Plot the sine function:

>>> import matplotlib.pylab as plt
>>> x = np.linspace(-np.pi, np.pi, 201)
>>> plt.plot(x, np.sin(x))
>>> plt.xlabel('Angle [rad]')
>>> plt.ylabel('sin(x)')
>>> plt.axis('tight')
>>> plt.show()

src/m/a/matplotlib-HEAD/py4science/examples/numpytemps.py   matplotlib(Download)
import nose
 
# convenience global names
from numpy import (pi, sin, cos, add, subtract, multiply, power)
 
def test1():
    """Verify an expression using temporaries.
    # 4.5*cos(3*x**2): 4
    # The final temporaries for each term are added and the result stored as y,
    # which is also created.  So we have 1 array for the result and 7 temps.
    y = sin(x) + sin(2*x) - 4.5*cos(3*x**2)
 
    # Now we do it again, but here, we control the temporary creation
    # ourselves.  We use the output argument of all numpy functional forms of
    # store the output back into the temporary or we accumulate it in z.
 
    # sin(x)
    sin(x,z)
 
    # + sin(2*x)
    add(z,sin(multiply(2,x,tmp),tmp),z)
def test2():
    """Compute the same expression, using in-place operations
    """
    x = np.linspace(0,2*pi,100)
 
    y = sin(x) + sin(2*x) - 4.5*cos(3*x**2)
 
    # This version of the code uses more in-place operators, which make it a
    # bit more readable and still avoid temporaries
    tmp = np.empty_like(x)
 
    # sin(x)
    z = sin(x)
    z = sin(x)
 
    # + sin(2*x)
    z += sin(multiply(2,x,tmp),tmp)
 
    # - 4.5*cos(3*x**2)
    power(x,2,tmp)

src/m/a/matplotlib-HEAD/matplotlib/examples/pylab_examples/quadmesh_demo.py   matplotlib(Download)
y = np.linspace(-1.5,1.5,n*2)
X,Y = np.meshgrid(x,y);
Qx = np.cos(Y) - np.cos(X)
Qz = np.sin(Y) + np.sin(X)
Qx = (Qx + 1.1)
Z = np.sqrt(X**2 + Y**2)/5;
Z = (Z - Z.min()) / (Z.max() - Z.min())

src/m/a/matplotlib-HEAD/examples/pylab_examples/quadmesh_demo.py   matplotlib(Download)
y = np.linspace(-1.5,1.5,n*2)
X,Y = np.meshgrid(x,y);
Qx = np.cos(Y) - np.cos(X)
Qz = np.sin(Y) + np.sin(X)
Qx = (Qx + 1.1)
Z = np.sqrt(X**2 + Y**2)/5;
Z = (Z - Z.min()) / (Z.max() - Z.min())

src/a/u/aureservoir-HEAD/python/examples/filtering.py   aureservoir(Download)
	w0 = 2 * N.pi * f0 / Fs
	if( BW != None ):
		#print BW
		alpha = N.sin(w0)*N.sinh( N.log(2)/2 * BW * w0/N.sin(w0) )
		#Q = ( 2*N.sinh(N.log(2)/2*BW*w0/N.sin(w0)) )**(-1)
		#print Q
	else:
		# calc with Q
		alpha = N.sin(w0)/(2.*Q)
	gain = abs( (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	       (N.cos(2*cf*N.pi*T) - N.sqrt(3. - 2**(3./2.)) * \
	       N.sin(2*cf*N.pi*T))) * (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	       (N.cos(2*cf*N.pi*T) + N.sqrt(3. - 2**(3./2.)) * \
	       N.sin(2*cf*N.pi*T))) * (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * (N.cos(2*cf*N.pi*T) - \
	       N.sqrt(3. + 2**(3./2.)) * N.sin(2*cf*N.pi*T))) * \
	       (-2*N.exp(4*1j*cf*N.pi*T)*T + 2*N.exp(-(B*T) + \
	       2*1j*cf*N.pi*T) * T * (N.cos(2*cf*N.pi*T) + \
	       N.sqrt(3. + 2**(3./2.)) * N.sin(2*cf*N.pi*T))) / \
	gain = abs( (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	       (N.cos(2*cf*N.pi*T) - N.sqrt(3. - 2**(3./2.)) * \
	       N.sin(2*cf*N.pi*T))) * (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	       (N.cos(2*cf*N.pi*T) + N.sqrt(3. - 2**(3./2.)) * \
	       N.sin(2*cf*N.pi*T))) * (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * (N.cos(2*cf*N.pi*T) - \
	       N.sqrt(3. + 2**(3./2.)) * N.sin(2*cf*N.pi*T))) * \
	       (-2*N.exp(4*1j*cf*N.pi*T)*T + 2*N.exp(-(B*T) + \
	       2*1j*cf*N.pi*T) * T * (N.cos(2*cf*N.pi*T) + \
	       N.sqrt(3. + 2**(3./2.)) * N.sin(2*cf*N.pi*T))) / \
 
	# init the rest
	tmp = 2*T*N.cos(2*cf*N.pi*T) / N.exp(B*T)
	Bfilt[:,0,1] = -(tmp+2*N.sqrt(3.+2**1.5)*T*N.sin(2*cf*N.pi*T)/N.exp(B*T))/2.
	Bfilt[:,1,1] = -(tmp-2*N.sqrt(3.+2**1.5)*T*N.sin(2*cf*N.pi*T)/N.exp(B*T))/2.
	Bfilt[:,2,1] = -(tmp+2*N.sqrt(3.-2**1.5)*T*N.sin(2*cf*N.pi*T)/N.exp(B*T))/2.
	Bfilt[:,3,1] = -(tmp-2*N.sqrt(3.-2**1.5)*T*N.sin(2*cf*N.pi*T)/N.exp(B*T))/2.

src/m/a/matplotlib-HEAD/matplotlib/examples/mplot3d/surface3d_demo2.py   matplotlib(Download)
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
 
x = 10 * np.outer(np.cos(u), np.sin(v))
y = 10 * np.outer(np.sin(u), np.sin(v))
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x, y, z,  rstride=4, cstride=4, color='b')

src/m/a/matplotlib-HEAD/examples/mplot3d/surface3d_demo2.py   matplotlib(Download)
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
 
x = 10 * np.outer(np.cos(u), np.sin(v))
y = 10 * np.outer(np.sin(u), np.sin(v))
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x, y, z,  rstride=4, cstride=4, color='b')

src/m/a/Matplotlib--JJ-s-dev-HEAD/examples/pylab_examples/quadmesh_demo.py   Matplotlib--JJ-s-dev(Download)
y = np.linspace(-1.5,1.5,n*2)
X,Y = np.meshgrid(x,y);
Qx = np.cos(Y) - np.cos(X)
Qz = np.sin(Y) + np.sin(X)
Qx = (Qx + 1.1)
Z = np.sqrt(X**2 + Y**2)/5;
Z = (Z - Z.min()) / (Z.max() - Z.min())

src/m/a/Matplotlib--JJ-s-dev-HEAD/examples/mplot3d/surface3d_demo2.py   Matplotlib--JJ-s-dev(Download)
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
 
x = 10 * np.outer(np.cos(u), np.sin(v))
y = 10 * np.outer(np.sin(u), np.sin(v))
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x, y, z,  rstride=4, cstride=4, color='b')

src/m/a/matplotlib-HEAD/matplotlib/examples/user_interfaces/embedding_in_wx3.py   matplotlib(Download)
    def init_plot_data(self):
        a = self.fig.add_subplot(111)
 
        x = npy.arange(120.0)*2*npy.pi/60.0
        y = npy.arange(100.0)*2*npy.pi/50.0
        self.x, self.y = npy.meshgrid(x, y)
        z = npy.sin(self.x) + npy.cos(self.y)
    def OnWhiz(self,evt):
        self.x += npy.pi/15
        self.y += npy.pi/20
        z = npy.sin(self.x) + npy.cos(self.y)
        self.im.set_array(z)
 
        zmax = npy.amax(z) - ERR_TOL

src/m/a/matplotlib-HEAD/matplotlib/examples/units/ellipse_with_units.py   matplotlib(Download)
 
theta = npy.arange(0.0, 360.0, 1.0)*npy.pi/180.0
x = 0.5 * width * npy.cos(theta)
y = 0.5 * height * npy.sin(theta)
 
rtheta = angle*npy.pi/180.
R = npy.array([
    [npy.cos(rtheta),  -npy.sin(rtheta)],
    [npy.sin(rtheta), npy.cos(rtheta)],

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next