text:
Generation of vector beams with liquid crystal disclination lines

# Generation of vector beams with liquid crystal disclination lines

Miha Čančula    Miha Ravnik Faculty of Mathematics and Physics, University of Ljubljana, Slovenia    Slobodan Žumer Faculty of Mathematics and Physics, University of Ljubljana, Slovenia Jožef Stefan Institute, Ljubljana, Slovenia
July 21, 2019
###### Abstract

We report that guiding light beams, ranging from continuous beams to femtosecond pulses, along liquid crystal defect lines can transform them into vector beams with various polarization profiles. Using Finite Difference Time Domain numerical solving of Maxwell equations, we confirm that the defect in the orientational order of the liquid crystal induces a defect in the light field with twice the winding number of the liquid crystal defect, coupling the topological invariants of both fields. For example, it is possible to transform uniformly-polarized light into light with a radial polarization profile. Our approach also correctly yields a zero-intensity region near the defect core, which is always present in areas of discontinuous light polarization or phase. Using circularly polarized incident light, we show that defects with non-integer winding numbers can be obtained, where topological constants are preserved by phase vortices, demonstrating coupling between the light’s spin, orbital angular momentum and polarization profile. Further, we find an ultrafast femtosecond laser pulse travelling along a defect line splits into multiple intensity regions, again depending on the defect’s winding number, allowing applications in beam steering and filtering. Finally, our approach describing generation of complex optical fields via coupling with topological defect lines in optically birefringent nematic fluids can be easily extended to high-intensity beams that affect nematic ordering.

###### pacs:
42.70.Df, 61.30.-v, 61.30.Jf

## I Introduction

Vector light beams are distinct optical fields characterized by complex spatial modulation of both intensity profile and the polarization Hall (1996). Theoretically, they are solutions of the vector paraxial wave equation with a non-uniform polarization profile Zhan (2004a); Tovar (1998). Especially interesting are cylindrical vector beams (CVB) with an axially symmetric intensity profile, which can be focused to a smaller spot size Dorn et al. (2003) and are useful in optical particle trapping Zhan (2004b); Kawauchi et al. (2007). Furthermore, cylindrical vector beams have applications in optical microscopy Youngworth and Brown (2000) and in laser cutting Niziev and Nesterov (1999). They can be generated from linearly polarized scalar beams, such as those emmited by most lasers, by using conical Brewster prisms Kozawa and Sato (2005), few-mode fibers Volpe and Petrov (2004), or – today most commonly – by phase modulators Shih-Wei Ko et al. (2010).

Liquid crystals are central materials in modern display optics and photonics due to their birefringence and their susceptibility to external control by electric, magnetic and optical fields. The birefringence in nematics stems from the orientational order of molecules which align along a distinct direction, called the director, corresponding to the optical axis de Gennes and Prost (1995); Kleman and Lavrentovich (2003). The optical axis can spatially vary over mutiple spatial scales, from to , notably also including the visible wavelength range, which makes nematics attractive for complex optic and photonic devices Coles and Morris (2010); Peccianti et al. (2002). Of special interest for photonics are topological defects in the orientational order, where the director field is discontinuous, and the material becomes locally optically isotropic Alexander et al. (2012). These nematic defects can be in the form of points or lines, and each defect is characterized by distinct spatial variation of optical axis around the defect. Line defects, also called disclinations, are characterized by the topological invariant called winding number (also known as topological charge or strength), which specifies how many turns the optical axis (director) makes when following a loop around the disclination. The director is a headless vector, so opposite directions are equivalent, allowing for disclination lines with half-integer and integer winding numbers. Disclinations carry a high free energy cost, so their presence has to be enforced by topological constrains, boundary conditions or strong external fields Kleman and Lavrentovich (2003); Araki et al. (2011); Čopar et al. (2013).

There is a fundamental connection between the liquid crystal director and the light field if the two get coupled, for example by shining light field on a structure in the nematic director field. It has been shown that nematic disclinations can induce singularities in the light field Brasselet et al. (2009), and sufficiently strong light fields can imprint defects in liquid crystals Brasselet (2010); Porenta et al. (2012). Generation of scalar and vector vortex beams on disclinations lines in nematic films was also recently experimentally demonstrated Loussert et al. (2013). Manipulation of vector beam polarization patterns can be achieved by using a liquid crystal device called a “q-plate” Marrucci et al. (2006). It has been used for imprinting polarization singularities into light beams, with either zero-intensity regions or points with circular polarization at the core Cardano et al. (2013). The q-plate consists of a liquid crystal disclination line with a certain winding number and a fixed length, where the director structure is enforced by treating the surface. A disclination line with winding number can transform a linearly polarized scalar beam into a beam with a polarization defect with winding number , as can be shown using a single-photon state formalism Nagali et al. (2009) or using the Jones formalism Cardano et al. (2012). A light beam carries spin, manifesting itself in the classical picture as cylindrical polarization of light, as well as orbital angular momentum (OAM) if a phase vortex is present at the beam axisHumblet (1943). Transfer of angular momentum between spin and orbital degrees of freedom can be achieved in certain photonic devices Loussert et al. (2013); Zhao et al. (2007), including the q-plate Marrucci et al. (2006). Angular momentum transfer can also be calculated analytically in the paraxial approximation and assuming low material birefringence Karimi et al. (2009), but moving beyond these approximations requires numerical methods.

Our interest will be in modelling the coupling between the light field and nematic disclinations, and there exist multiple numerical methods for modelling the propagation of light through anistropic birefringent media. Jones calculus describes light with two transversal components of the electric field enforcing a fixed direction of propagation and neglecting diffraction. It is suitable for uniform media or media with spatial variations of refractive indices on a scale much larger than the wavelength of light. For more complex anisotropic media, the Berreman method can be used Berreman (1972); Stallinga (1999), which calculates the transversal components of both electric and magnetic fields and can describe more rapid spatial variations. However, these simplified descriptions fail where the diffaction and refraction cause the propagation of light in and direction to be significant, such as in the presence of discontinuities of the permittivity tensor Kriezis and Elston (2000); Hwang and Rey (2005). In these cases, a method that considers all six components of light fields must be used. The Finite Difference Time Domain (FDTD) method has proven to be a powerful tool for modelling light propagation through arbitrarily complex optically anisotropic media, computing the time evolution of the electric and magnetic field by explicitely solving Maxwell’s equationsOskooi et al. (2010); Taflove and Hagness (2005). Indeed, along with the Finite Element Method Beeckman et al. (2009), it is often used especially in the study of liquid crystal optics and photonics Kriezis and Elston (1999); Ogawa et al. (2013); Matsui et al. (2014).

In this paper, we present numerical modelling of the flow-of-light along liquid crystal disclination lines, showing that this approach allows for controllable design of both polarization and intensity of cylindrical vector light beams. Using a custom developed FDTD-based numerical approach, we find that a disclination line can transform a scalar beam into a beam with radial or azimuthal polarization, depending on the polarization of incident light. By employing nematic disclination lines with different winding numbers (), we find vector beams with further polarization profiles. Our results confirm the defect winding numbers predicted by the Jones formalism, while additionally demonstrating the necessary zero-intensity region at the defect core. Owing to the sensitivity of liquid crystals, the polarization conversion can be tuned by direct system parameters, including temperature, birefringence, and the length of the disclination. We show that light polarization always forms a defect with twice the winding number of the liquid crystal disclination and provide a simple analytical derivation that explains this relation. Unlike derivations based on photon states or the Jones formalism, our FDTD method correctly shows a zero-intensity region, which ensures that electric and magnetic fields are continuous near the defect core. By using circularly polarized incident light, we observe that it is possible to induce polarization defects with half-integer winding numbers, which is seemingly counter-intuitive and should have been prevented by the vector symmetry of the light polarization. However, this incompatibility is resolved by a phase singularity at the beam axis, demonstrating coupling between spin, orbital angular momentum and polarization. In addition to continuous light beams, we present light field modulation of femtosecond laser pulses by nematic disclinations. We assume low light intensity and neglect any effects that light has on the orientation or temperature of the liquid crystal. The light pulses undergo similar transformation of their polarization state, but interestingly also split into multiple intensity regions. The number of these intensity regions is found to be equal to , where is the disclination line’s winding number.

## Ii Methods

There is a mutual interaction between a nematic liquid crystal and light. Nematic birefringence affects the polarization of light, while the liquid crystal molecules generally tend to orient parallel to the electric field. However, in this paper, we assume that light fields are too weak to reorient the nematic, and only model the flow of light through a fixed nematic director field. We develop and implement a custom written finite-difference time-domain (FDTD) approach, which allows for modelling of the flow-of-light in general optically anisotropic materials, with notably spatially varying optical axis, such as liquid crystals. The method computes the values of all six components of electromagnetic fields at every time step by following the time derivatives of two dynamical Maxwell’s equationTaflove and Hagness (2005). Using dimensionless quantities () and assuming no free charges and currents in the material, these equations are

 ∂H∂t=−∇×E,∂E∂t=ε−1(∇×H), (1)

where and are electric and magnetic field, respectively. The two equations contain one material field, i. e. the dielectric permittivity tensor , and it is the design and spatial variation of tensor which is at the center of this paper, driving the polarization and intensity modulation of the vector light beams.

When using Eqs. 1 on a discrete lattice in the FDTD approach, it is possible to improve accuracy without sacrificing performance by defining field components at different points in space and time. The standard apporach is to use the Yee latticeYee (1966); Oskooi et al. (2010) (Figure 1a), where each field component is known at a different site. This way, all space-derivatives are of the central-difference type, giving the method second-order accuracy. However, this is true only if the components of the electric fields are uncoupled, i. e. if the permittivity tensor is diagonal, which can be achieved in a uniform birefringent material by choosing a suitable frame of reference. In liquid crystals, where the dielectric tensor and birefringent axes inherently vary in space, such a choice cannot be made, so the inherent symmetry of the Yee lattice is lost. It is possible to use the Yee lattice with arbitrary permittivity tensors, but this causes the loss of the central-difference property, reducing the accuracy and giving rise rise to numerical stability concernsWerner and Cary (2007). To alleviate these shortcomings, we use our own lattice, where notably, all three components of each of the two fields (i.e. electric and magnetic) are computed at the same point (see Figure 1b).

The introduced lattice has the same second-order accuracy as the Yee lattice and is unconditionally stableWerner and Cary (2007), at the cost of slightly decreased computational performance. To ensure all differences are central, each space-derivative has to be computed as an average of four finite differences, as opposed to one as with the Yee lattice. This larger number of operations is offset by adapting the method to support parallel computing on CPU or GPU, resulting in major performance gains. For example, a fully 3D simulation run with 2000 time steps (corresponding to cca ) on lattice points only takes a few minutes on a single Nvidia GTX Titan GPU. External light sources are modelled by partitioning the simulation cell with a boundary and empty space around the cell with an absorbing perfectly-matched layer (PML) Berenger (1994). By setting the absorbing layer’s thickness to 30 simulation points, reflection is reduced by five orders of magnitude, as commonly seen in FDTD modelling Taflove and Hagness (2005); Oskooi et al. (2010).

The liquid crystalline birefringent profile is introduced into the FDTD simulations via a spatially-varying permittivity tensor de Gennes and Prost (1995)

 εij (2)

where is the average permittivity, is the molecular dielectric anisotropy, and is the uniaxial nematic order parameter tensor. A fixed uniaxial nematic order parameter tensor is assumed here with the optical axis (corresponding to the extraordinary refractive index) equivalent to the nematic director . In our calculations, we computed , and its inverse from the director and the nematic degree of order , which corresponded to the nematic disclinations. The director field around nematic disclination lines can be written as where is the disclination line’s winding number and can be of integer or half-integer value. Energetically, the energy of disclinations per unit lenght are proportional to Kleman and Lavrentovich (2003); therefore, typically, only disclinations with low winding numbers emerge in experimentsde Gennes and Prost (1995), so we focused only on systems with . The defect cores are modelled by reducing the nematic degree of order smoothly to zero within the core radius of few de Gennes and Prost (1995), effectively, causing the material to become optically isotropic. Indeed, the core region being much smaller than the wavelength of light, we find that its exact structure has little effect on the propagation of light. Because , and are all related symmetric tensors, only six values of are stored in claculations, saving on computer memory.

The FDTD method allows arbitrary incident light fields. We choose a scalar TEM Gaussian beam with uniform polarization, either linear or circular. In the case of a pulse source, the field amplitude varies in time as

 E0(t)∝exp(−(t−t0)22T2) (3)

where is the characteristic pulse length . Because there is no light before , effectively cutting of one tail of the Gaussian function, the peak-intensity time is chosen much larger than , so that the full shape of the pulse was captured. A value of appears sufficient to remove any artifacts and produce well-formed Gaussian-shaped pulses.

Unless stated differently, numerical and modelling parameters in Table 1 are used, corresponding to standard nematic liquid crystal (e.g. 5CB)Chirtoc et al. (2004) and visible light. Free-standing disclination lines are modelled without an external light-guiding structure, so the beams diverge while traversing the disclinations. However, the Rayleigh range in the medium – a characteristic distance from the waist at which the cross section area of the beam is doubled – is greater than the simulation cell size, ensuring that while beam divergence is noticeable, its effect on the polarization and phase profiles is negligible.

## Iii Results

### iii.1 Linear incident polarization

Nematic disclination lines of various winding numbers are used to transform the polarization profile of an incident linearly polarized light beam. Figure 2 shows the transformation of a linearly polarized light beam travelling along a disclination line. The incident beam has Gaussian intensity profile (Figure 2a) and linear uniform polarization. A zero-intensity region quickly forms at the defect core, and periodic wrinkles are seen in the intensity profile further along the line (Figure 2b-d,e). A slight shift of intensity in the direction is visible, caused by refraction towards the area where the nematic director and light polarization are parallel and the refractive index is higher. Intensity profiles at distinct cross-sections also show multiple rings, indicating a presence of higher-order Laguerre-Gaussian modes in the transformed beam. Changes in the polarization of light withing the beam are also apparent. Interestingly, the incident beam with linear polarization develops a polarization defect at the center, while polarization around the core alternates between two distinct patterns, i.e. the linearly polarized (Figure 2f,j,l,n) and the radially polarized profile (Figure 2h,k,m,o). Note that at each point in space, the polarization of light is linear (as opposed to circular), but the direction of the linear polarization is radial with respect to the center of the incident beam.

We repeat the simulations with disclinations of different winding numbers and observe that a nematic disclination line -of appropriate length- with winding number produces a defect in the light polarization with winding number , as shown in Figure 3. Similarly as with the disclination shown in Figure 2, we observe that the incident beam with linear polarization develops a polarization defect at the center, while polarization around the core alternates between two distinct patterns, of either linear or polarization. It is important to notice that exactly this polarization profile developes periodically as the light passes along the nematic disclination line, with the intermediate states characterized by partially linear (shown in red) and partially elliptical (in green) polarization. More generally, this systematic study shows that nematic disclination lines could be used as distinct microobjects for controllable generation of polarization profiles in vector light beams, in good agreement with both theoretical predictions and experimental results Marrucci et al. (2006); Loussert et al. (2013).

The relation between the winding number of the nematic disclination and the winding number of the generated vector light beam, , can be qualitatively explained by using the Jones formalism. A phase plate with a retardation of can be described with a Jones matrix Marrucci et al. (2006):

 Mδ(α)=R(−α)⋅(100eiδ)⋅R(α) (4)

where is the rotation matrix by angle , which corresponds to the local orientation of the optical axis, i.e. the nematic director (). For a distinct disclination line with winding numer , the director angle varies as , where is a constant, which for retardation (also known as the “q-plate”) gives the Jones matrix:

 Mπ(α)=(cos2αsin2αsin2α−cos2α). (5)

Applying to a linear -polarized incident beam, we obtain

 Eout=Mπ⋅E0(10)=E0⋅(cos(2sϕ+α0)sin(2sϕ+α0)) (6)

which is a now a defect light field with a winding number of generated by the defect field of nematic disclination with winding number . The distance-of-light-travelled at which the double-winding-number defect emerges in the light field is determined by the condition , from which follows

 z=(2m+1)λ2(ne−no) =(2m+1)λ2Δn,m∈Z

where is the wavelength in vacuum and is the material birefringence. At typical values for 5CB and visible light (see Table 1), the first complete defect in the polarization profile () emerges at

 zd=$480nm$2×0.15≈$1.6\SIUnitSymbolMicrom$. (7)

We should stress that the above derivation is only qualitative, as it is based on simple Jones calculus which fully neglects refraction. For example, in the Jones view, exactly at the disclination, the director angle is discontinuous, and so is the predicted electric field, which is a non-physical soultion in reality effectively solved by refraction. Indeed, our full FDTD numerical simulations clearly show that light refracts away from the defect, creating a zero-intensity region at the disclination. It is apparent that only methods which treat the electric and magnetic field as full vector fields are suitable for the study of defects in light. Away from the defect core (more than half a wavelength from the axis), the simplified Jones derivation closely matches our numerical results, and so does the predicted value of .

### iii.2 Circular incident polarization

By varying the polarization of the incident light beam, it is possible to generate a further large variety of polarization patterns along the nematic disclinations. Figure 4 shows polarization profiles of vector light beams obtained by shining incident circularly-polarized light along nematic disclinations. As in the previous section, a zero-intensity region is always observed at the axis. The polarization profiles are shown at distinct propagation lengths, where the polarization again becomes locally linear across the whole cross-section of the beam. In this case, the defects in the polarization profile appear with the same winding number as that of the disclination line. Notably, we observe polarization defects with half-integer winding numbers. This is significant because vector fields, such as the electric or magnetic field, can only form defects with integer winding numbers. The observed defects thus seemingly violate the topological contraints enforced by the vector symmetry of the light fields. However, in the case of light polarization, there are multiple possibilities of rectifying this apparent contradiction Dennis et al. (2009). At the defect core, there can be an area where light is unpolarized, such as in the polarization pattern of sunlight. Alternatively, a point of circularly polarized light (also known as a “C point”) could be present at the core Dennis (2002). Finally, as it occurs in our case and is explained later in this section, a half-integer strength phase vortex may be present Angelsky et al. (2002).

Figure 4 also shows that the polarization profile is rotated by 45 with respect to the nematic director, with the direction of this rotation depending on the handedness of the circular polarization. For right-handed circular incident polarization (RHP), the polarization profile rotates by relative to the nematic disclination, whereas for left-handed incident light (LHP) the profile is rotated by , as seen in Figure 4. Note that while the local polarization at each point is always rotated by with respect to the director, this rotation is equivalent to a global rotation by in defects with winding numbers because of the defect’s symmetry. This symmetry is different in defects with higher winding numbers; in the case of the defect, the local rotation is equivalent to a global rotation by , while the polarization profile in a defect cannot be obtained with only global rotations.

Unlike in the case of linear incident polarization, for circularly polarized incident beams the distinct defect structure in the polarization profile appears at , where the phase retardation is equal to . Using the Jones formalism from Eq. 4, we can write

 Mπ/2=R(−α)⋅(100i)⋅R(α) (8)
 (9)

Inserting , we indeed obtain a defect in the polarization profile with winding number that is rotated by with respect to the director profile of the liquid crystal disclination line, exactly as found in full FDTD numerical simulations. There are both polarization and phase singularities at the axis, meaning that there the light intensity must drop to zero, which we clearly observe in numerical simulations but is again not accounted for in the Jones formalism. As in the case with linear incident polarization, the pattern is repeating with a period of , so these defects can be seen at for each integer .

Interestingly, we observe polarization defects with half-integer winding numbers which cannot be formed by electric or magnetic fields and seemingly violate the vector symmetry of the light polarization. For a disclination line with , we obtain , resulting in the light field of the form

 Eout=E0eiϕ/2(cos(ϕ/2−π/4)sin(ϕ/2−π/4))=E0eiϕ/2J(ϕ) (10)

Considering only the polarization term , we see that , even though the two angles describe the same physical point in space. The topological constraints are preserved by a phase vortex at the axis, represented by the term , which can be seen from electric field snapshots in Figure 5. Along a closed loop around an disclination line, we see a rotation of the polarization and a phase difference, combining into a total rotation consistent with the vector nature of the electric field. We thus observe a conversion from a vortexless beam with uniform circular polarization into a beam with a polarization defect and a phase vortex. This result clearly demonstrates that the nematic disclination line couples in a complex manner the light’s spin, polarization and orbital angular momentum.

### iii.3 Femtosecond pulses along nematic disclinations

Nematic disclinations can be used also as interesting micro-objects for micro-modulation of laser light pulses, splitting the pulses into multiple eigenmodes and shaping the pulse intensity and polarization. Indeed, sending short pulses of light through samples is a strong apporach for finding waveguide modes within the FDTD method Taflove and Hagness (2005).

In a birefringent medium without a surrounding waveguide, such as the disclination lines we study here, the pulse is a sum of two polarization modes. Each of the two modes travels with a different propagation (group) velocity, interestingly, causing the pulse to split into two separate intensity regions with an intensity minimum between them, as shown in Figure 6. Additionally, each mode may have multiple intensity regions, depending on the winding number of the nematic disclination. An incident femtosecond pulse travelling along a nematic disclination with winding number gradually splits into two eigenmodes, each of which further divides into intensity regions, resulting in a total of intensity regions. For the nematic disclinations, we observe effective spliting of the light pulse into 2 intensity regions, whereas for the nematic disclinations the pulse splits into 4 intensity regions.

Our simulations show that while the sign of the winding number is important for the polarization modes, it has no effect on the intensity profile. Both eigen polarizations have the same winding number as the director field; however the vector nature of the electric field is incompatible with non-integer defect lines. This incompatibility is solved as the director symmetry is broken by the incident polarization. Wherever an eigenmode would dictate that the polarization be perpendicular to the incident, light intensity is zero, as this mode is not present in the incident beam. Topologically more strictly, the polarization of light thus only partially forms topological defect structures, with the light field intensity dropping to zero where the polarization cannot be defined continuously. In the region between both propagation modes, the light intensity is relatively low, but interesting polarization features are still visible (Figure 6, profiles ). Here, both eigenmodes combine to form a single defect with double winding number and no azimuthal intensity dependence. This defect structure is a combination of both polarization modes and is very similar, both in shape and in origin, to those that appear in continuous light.

## Iv Conclusions

Nematic liquid crystals disclination lines are shown to act as micro-objects which transform the polarization of light and create topological defects in the light field. Complex vector light beams of various beam strength are generated from simple linearly and circularly polarized light fields. Using numerical modelling based on the FDTD approach, we show that the polarization of light obtains a defect with twice the winding number of the disclination line after traversing a distinct-length section of the line. Our results extend the prediction of the Jones method by not only predicting the winding number of light defects but also the corresponding intensity profiles. For example, a linearly polarized light beam travelling along a disclination line can become radially polarized. Notably, we show that it is possible to induce polarization defects with half-integer winding numbers by using circularly polarized incident light. The topological constraint of the electric field is preserved by a phase vortex, coupling polarization handedness, polarization defects and orbital angular momentum of the beam. We further demonstrate that guiding a short laser pulse along a disclination causes it to split into multiple intensity regions. These intensity regions are arranged into two propagation eigenmodes, each of which is further divided into regions, where is the disclination line’s winding number.

The phenomena described here are interesting for modulation of light polarization, phase and intensity, as well as for spin-orbital momentum transfer, creating light beams with various polarization and phase profiles. Due to the inherent susceptibility of liquid crystals to external stimuli, such devices could be further tuned with electric, magnetic or optical fields, offering interesting applications in information processing, possibly as electronic-photonic couplers and as parts of all-photonic circuits. Finally, the calculated polarization and intensity profiles will enable us to model the mutual interaction between liquid crystals and light fields in the future, giving a more complete model of light propagation in soft matter.

###### Acknowledgements.
The authors acknowledge funding from Slovenian Research Agency Grant Z1-5441 and Programme P1-0099. M.R. acknowledges support from EU FP7 Marie Curie Career Integration Grant FREEFLUID Channel-free liquid crystal microfluidics.

## References

You are adding the first comment!
How to quickly get a good reply:
• Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
• Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
• Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters


text:
/High-performance combinatorial optimization based on classical mechanics (via Qpute.com)

## High-performance combinatorial optimization based on classical mechanics (via Qpute.com)

### bSB and dSB algorithms

The Ising problem is to find a spin configuration minimizing the Ising energy, defined as

$EIsing=−12∑i=1N∑j=1NJi,jsisj−∑i=1Nhisi$

(1)where si denotes the ith spin taking 1 or −1, N is the number of spins, Ji,j is the coupling coefficient between the ith and jth spins (Ji,j = Jj,i and Ji,i = 0), and hi is the local field on the ith spin. Since introducing an ancillary spin reduces the Ising problem to the one without local fields (see section S1), here, we focus on the Ising problem with no local fields (hi = 0).

To solve the Ising problem, QbM uses quantum-mechanical nonlinear oscillators called Kerr-nonlinear parametric oscillators (KPOs), each of which can generate a Schrödinger cat state, i.e., a quantum superposition of two oscillating states, via a quantum-mechanical bifurcation (31). Such a KPO has recently been realized experimentally using superconducting circuits (45, 46). However, the realization of a large-scale QbM will require a long time. On the other hand, it was found that a classical-mechanical model corresponding to QbM, referred to as a classical bifurcation machine (CbM), also works as an Ising machine (31, 33). In this case, we can efficiently simulate such a classical machine using present digital computers, instead of building real machines. [This is not the case for QbM, because QbM can also be used as a universal quantum computer (47, 48), which is classically unsimulatable.] This simulation approach paves the way for large-scale Ising machines with all-to-all connectivity.

By modifying the equations of motion for CbM such that computational costs are reduced and the symplectic Euler method (49) is applicable, we obtain the following Hamiltonian equations of motion for aSB (30)

$x·i=∂HaSB∂yi=a0yi$

(2)

$y·i=−∂HaSB∂xi=−[xi2+a0−a(t)]xi+c0∑j=1NJi,jxj$

(3)

$HaSB=a02∑i=1Nyi2+VaSB$

(4)

$VaSB=∑i=1N(xi44+a0−a(t)2xi2)−c02∑i=1N∑j=1NJi,jxixj$

(5)where xi and yi are, respectively, the position and momentum of a particle corresponding to the ith spin, dots denote time derivatives, a(t) is a control parameter increased from zero, a0 and c0 are positive constants, and VaSB is the potential energy in aSB.

To qualitatively explain the operation principle of aSB, we show an example of the dynamics in aSB in Fig. 1 (A and B), where the ferromagnetic two-spin Ising problem (J1,2 = J2,1 = 1) with solutions s1 = s2 = ± 1 is solved as the simplest problem. All positions and momenta are randomly set around zero at the initial time. The initial potential has a single local minimum at the origin (top and middle of Fig. 1B), so the particles circulate around the origin (Fig. 1A and middle of Fig. 1B). When a(t) becomes sufficiently large, bifurcations occur, that is, multiple local minima of the potential appear. Then, the particles adiabatically follow one of the minima. Consequently, each xi bifurcates to a positive or negative value (Fig. 1A and bottom of Fig. 1B). Since two local minima corresponding to the two solutions have lower energies and appear earlier than the other two local minima, the particles successfully find one of the solutions. Last, the sign of xi, sgn(xi), gives the ith spin, si, for the solution of the Ising problem. It has been empirically found that aSB works well for much larger-scale and more complex problems (30).

This aSB relies on the fact that the second term in VaSB is approximately proportional to the Ising energy at the final time (30). In this approximation, analog errors arise from the use of continuous variables (positions) instead of discrete variables (spins). These analog errors in aSB may degrade solution accuracy and result in approximate solutions. Such analog errors in different dynamical approaches have also been discussed (38, 40).

To suppress analog errors, we introduce perfectly inelastic walls at xi = ± 1. That is, at each time, we replace xi with its sign, sgn(xi) = ± 1, and set yi = 0 if ∣xi∣ > 1. These walls force positions to be exactly equal to 1 or −1 when a(t) becomes sufficiently large. Moreover, we drop the fourth-order terms in VaSB, because the inelastic walls can play a role similar to the nonlinear potential walls. We thus obtain the following equations

$x·i=∂HbSB∂yi=a0yi$

(6)

$y·i=−∂HbSB∂xi=−[a0−a(t)]xi+c0∑j=1NJi,jxj$

(7)

$HbSB=a02∑i=1Nyi2+VbSB$

(8)

(9)This artificial dynamical system is the basis of the bSB. In bSB, we solve Eqs. 6 and 7 by the symplectic Euler method, where time is discretized with a time step Δt, together with the updating for the inelastic walls (see Methods for a detailed algorithm). (If we solve these equations by the standard Euler method, instead of the symplectic Euler method, then solution accuracy becomes lower. See section S2.)

Similar modification to the above walls has been proposed for SimCIM (39), but this algorithm is based on the gradient method, like the Hopfield-Tank model (42), and also uses stochastic processes. In contrast, bSB is based on a classical-mechanical system conserving energy except for the inelastic walls and adiabatic changes of energy and also uses deterministic processes except for initial value setting. As a result, the performance of bSB is quite different from that of SimCIM (see section S3 for the comparison between bSB and SimCIM).

In bSB, it is sufficient to increase a(t) to a0. Then, the final potential has only the second term related to the Ising energy. Consequently, the following condition is satisfied for all i at the final time (see section S4)

$ΔEi=2si∑j=1NJi,jsj≥0$

(10)where si = sgn (xi) is the sign of xi and ΔEi represents the change in the Ising energy for a flip of si. Note that Eq. 10 is a sufficient condition to show that the spin configuration is a local minimum of the Ising problem. Hence, solutions obtained by bSB are at least local minima in the Ising problem. In contrast, this is not necessarily guaranteed in aSB because of its nonlinear potential terms. (This means that solutions obtained by aSB can sometimes be improved by a naïve local search based on sequential spin flips.) This is another reason why bSB should achieve higher accuracy than aSB. Throughout this work, we linearly increase a(t) from 0 to a0 and set a0 to 1.

Here, we show an example of the bSB dynamics using the same two-spin problem as above. The initial potential has a single local minimum at the origin (top of Fig. 1D) and particles circulate around the origin (Fig. 1C and middle of Fig. 1D), as in aSB. In bSB, however, stable points suddenly jump from the origin to the walls at xi = ± 1, which prevents adiabatic evolution. Instead, particles move toward walls in a ballistic manner (Fig. 1C and bottom of Fig. 1D). This ballistic (nonadiabatic) behavior in bSB leads to fast convergence to a local minimum of VbSB and, consequently, to fast optimization.

For further improvement, we introduce another variant of SB by discretizing xj to sgn(xj) in the second term in Eq. 7

$x·i=∂HdSB∂yi=a0yi$

(11)

$y·i=−∂HdSB∂xi=−[a0−a(t)]xi+c0∑j=1NJi,jsgn(xj)$

(12)

$HdSB=a02∑i=1Nyi2+VdSB$

(13)

(14)The discrete version of bSB, namely, dSB (see Methods for a detailed algorithm), is expected to achieve higher accuracy than that of bSB, because analog errors are further suppressed by discretization. We found that this discretization is effective for bSB but not for other algorithms such as SimCIM and aSB (see sections S3 and S5).

Note that the singularity on the boundaries between positive and negative regions has been intentionally neglected. This leads to a violation of conservation of energy across boundaries and, hence, to escape from local minima over potential barriers, as shown below. In this sense, dSB goes beyond naïve algorithms based on classical-mechanical systems conserving energy (except adiabatic change), such as aSB and bSB. We also increase a(t) to a0 for the convergence to a local minimum of the Ising problem at the final time, as in bSB (see section S4).

Figure 1 (E and F) shows an example of the dSB dynamics using the same two-spin problem as above. Unlike aSB and bSB, the particles go back and forth between two local minima through the potential barriers (Fig. 1E and middle of Fig. 1F). This is similar to quantum tunneling, as depicted by the inset in Fig. 1I. This tunneling-like behavior is possible due to the above-mentioned neglect of the singularity on the boundaries; otherwise, the potential walls on the boundaries prevent this tunneling. In contrast, conservation of energy prevents such tunneling in aSB and bSB, as suggested by the insets in Fig. 1 (G and H). Thus, it is expected that this tunneling-like behavior will help dSB to escape local minima of the potential, and hence, dSB will outperform aSB and bSB in terms of solution accuracy.

Note that both bSB and dSB maintain the advantage of aSB over SA, namely, high parallelizability. Therefore, they are expected to realize both high speed and high accuracy simultaneously.

### Performance for a 2000-spin Ising problem with all-to-all connectivity

To compare the performance of bSB and dSB with that of aSB, we solved a 2000-spin Ising problem with all-to-all connectivity. This problem was named K2000 and previously solved by aSB (30), a CIM (11), and a recently developed digital chip called STATICA (27), which is based on the above-mentioned SCA. This problem can be regarded as a 2000-node MAX-CUT problem (11, 30); so, here, we evaluate performance using cut values (see section S6 for the definition of the cut value and the relation between MAX-CUT and the Ising problem). The best cut value for K2000 is estimated to be 33,337 (see section S7).

The lines and symbols in Fig. 2A show average and maximum cut values, respectively, for 1000 trials as functions of the number of time steps, Nstep. (Throughout the paper, Nstep denotes the total number of time steps for each trial and the values of cost functions (cut values or Ising energies) as functions of Nstep are final values, not intermediate values, in each trail.) The results clearly show that both bSB and dSB outperform aSB in terms of both speed and accuracy. In addition, only dSB obtained the best value. On the other hand, best values obtained by bSB and aSB become lower for larger Nstep. This result suggests that the best values may be obtained accidentally by nonadiabatic processes in bSB and aSB. For large Nstep, dynamics becomes more adiabatic and the chance to obtain better solutions by nonadiabatic processes may be lost.

We implemented 2048-spin-size bSB and dSB machines (bSBM and dSBM) using single FPGAs (see section S8 for details) and solved K2000 by them. Figure 2B shows the comparison between our machines and the above three other machines (11, 27, 30), where the lines and the crosses show the average values of our machines and the others, respectively, for 100 trials, and the bars show the maximum and minimum values among the 100 trials. (The bars for our machines are shown at only typical computation times.) Only our dSBM obtained the best value in a short time (2 ms), thereby simultaneously realizing both high speed and high accuracy. Also, our bSBM is remarkably fast, about three times faster than STATICA (27), the previously fastest machine for K2000. Note that the results by STATICA for K2000 are predicted values by a simulator, and a real STATICA chip is still 512-spin size (27). On the other hand, in this work, we have implemented faster real machines.

### Benchmarking using time-to-solution and time-to-target

To evaluate the computation speed more quantitatively, here, we introduce two metrics: time-to-solution (TTS) and time-to-target (TTT). TTS is a standard metric for evaluating Ising machine speeds (14, 23, 28, 29), defined as the computation time for finding an optimal or best known value with 99% probability. TTT uses a target value, instead of an optimal value, as a good approximate solution. In this work, we define the target as 99% of the optimal or best known value. TTS and TTT are formulated as Tcom log (1 − 0.99)/ log (1 − PS) (14, 23), where Tcom is the computation time per trial and PS is the success probability for finding the optimal (TTS) or target (TTT) value. PS is estimated from experimental results with many trials. When PS > 0.99, TTS and TTT are defined as Tcom.

In the following, we compare TTS and TTT of our 2048-spin-size bSBM and dSBM with those of other recently developed machines shown in Fig. 3A. Since the bSBM can quickly find good approximate solutions and the dSBM can find optimal solutions of large-scale problems, we use the bSBM and dSBM for evaluations of TTT and TTS, respectively. TTS and TTT of other machines are cited or estimated from the data in the literature (see section S9 for details), because we could not use such machines for the present work. This limits the range of instances that can be used for this benchmarking. Also note that some machines are not the latest ones, as mentioned below.

Figure 3B shows the results of TTT. For K2000, the TTT of our bSBM (0.26 ms) is much shorter than those of STATICA (27) (1.50 ms, a predicted value by a simulator) and the CIM (11) (1.1 s). As a 2000-spin-size instance with sparse connectivity, we also solved G22, which is one of the well-known MAX-CUT benchmark instances called G-set and was solved by the CIM (11). For G22, the TTT of our bSBM is two orders of magnitude shorter than that of the CIM. These results demonstrate that our bSBM can find good approximate solutions faster than other recently developed machines of the same spin size. (TTTs of our machines for other G-set instances are provided in table S2.)

Next, we show the results of TTS in Fig. 3C. We start with the same two instances, namely, K2000 and G22. The TTS of our dSBM for them are 1.3 and 2.7 s, respectively. While TTS for K2000 has not been reported so far, TTS for G22 was evaluated with a SimCIM implemented on a FPGA (29), which is based on a recently proposed algorithm called chaotic amplitude control (CAC) (29, 40). The TTS of the SimCIM is estimated at 12 s (see section S9). Thus, our dSBM has achieved a shorter TTS for G22 than that of the state-of-the-art machine. (TTSs of our machines for other G-set instances and the comparison between them and those of the SimCIM are provided in table S2 and fig. S6, respectively.)

We also solved other various instances of the Ising problem (MAX-CUT) by dSBM to compare it with other machines shown in Fig. 3A. For small-scale problems, we can simultaneously perform multiple trials using the 2048-spin-size machine by a block-diagonal structure of the J matrix, as done using a CIM (14). This so-called batch processing improves the success probability PS by selecting the best result among multiple trials, while Tcom is defined as the computation time per batch. In the limit as the number of trials per batch Nbatch goes to infinity, PS may exceed 0.99, and then TTS and TTT become Tcom from the above definitions. In this sense, the TTS and TTT are well defined even for batch processing.

As shown in Fig. 3C, for two small-scale problems with 60 spins (all-to-all connectivity) and 200 spins (sparse connectivity), our dSBM achieved much shorter TTSs than those of a QA and a CIM (14). (This QA is not the latest version.) For 100-spin and 700-spin problems with all-to-all connectivity, the TTSs of the dSBM are much shorter than those of the SimCIM with CAC (29). These short TTSs of dSBM compared to the SimCIM come not from computation speed or implementations but the algorithmic advantage of dSB over CAC. That is, dSB needs fewer matrix-vector multiplications (MVMs), which is the most computation-intensive part in both algorithms, to obtain solutions than does the SimCIM with CAC. [The numbers of MVMs to solutions of the 100-spin and 700-spin problems are 9.4 × 10 and 8.1 × 104, respectively, for dSB but 5.6 × 103 and 7.8 × 105, respectively, for CAC (29).] For two 1024-spin problems (all-to-all connectivity) with different ranges of Ji,j, the dSBM achieved shorter TTSs than those of a Digital Annealer (DA) (23), which is based on an FPGA implementation of “Digital Annealer’s algorithm” developed from SA and outperformed CPU implementations of SA (25) and parallel tempering (50). (This DA is not the latest version.) Last, for 60-spin and 100-spin problems with all-to-all connectivity, the TTSs of the dSBM are comparable to those of another state-of-the-art machine based on an FPGA implementation of the above-mentioned RBM’s stochastic sampling (28), the size of which, however, is limited to 200 spins. Overall, we conclude that our bSBM and dSBM have achieved remarkably high performance for the present benchmark instances compared to the recently developed machines.

This is a syndicated post. Read the original post at Source link .

format: plain


text:
# Part 4 of 4 - Real-Time Facial Expression Recognition

#### | Final Capstone Project for the Diploma Program in Data Science | BrainStation Vancouver |

| Arash Tavassoli | May-June 2019 |

This is the fourth notebook in a series of four:

• Part 1 - Exploratory Data Analysis

• Part 2 - Data Preprocessing

• Part 3 - Model Training and Analysis

• Part 4 - Real-Time Facial Expression Recognition

### What to expect in this notebook:¶

A Real-time Facial Expression Recognizer that will use the trained models from Part 3 to do real-time expression classification from the video captured by the computer's webcam

## Building a Real-Time Facial Expression Recognizer with OpenCV¶

In this part we use the trained model from Part 3 and pair its prediction capabilities with OpenCV to build a simple, but fun, tool to take the live video from computer's webcam and do real-time prediction on the detected face:

1. Inputs the trained model and list of expected classes
2. Starts capturing the video from computer's webcam
3. Detects the largest face on each frame (with min size limit of 1/20 of the frame's smaller dimension)
4. Predicts the facial expression using the trained model
5. Annotate the frame with a box around the face and the predicted expression (and probabilities for each class)
6. Releases the frame to the screen
In [1]:
import cv2
import numpy as np
from keras import models

Using TensorFlow backend.

In [2]:
root_dir = '/Users/Arash/Google Drive/Colab Notebooks/BrainStation Capstone - Colab'

In [3]:
# A function to get the trained model and start a real-time
# facial expression recognizer using computer's webcam (OpenCV):

def RealTimeExpressionRecognizer(model, classes):

video = cv2.VideoCapture(0)

# Setting color and font params:
cv_color = (33, 83, 244)
cv_font = cv2.FONT_HERSHEY_SIMPLEX

while True:

# Converting the frame to grayscale:
im = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

# Detecting faces in frame (with min size limit of 1/20 of the frame's smaller dimension):
min_acceptable = int(min(frame.shape)/20)
detected_faces = face_cascade.detectMultiScale(im, minSize = (min_acceptable, min_acceptable))

# Checking if there is no face:
if detected_faces is ():

# Text box to instruct the user of how to quit the live stream:
cv2.putText(img = frame,
text = 'Press Q to quit',
org = (10, 20),
fontFace = cv_font, fontScale = 0.7, thickness = 1,
color = (255,255,255))

# Text box for when there is no face detected in the frame:
no_face_text = "I'm waiting! Show me your smile! :)"
textsize = cv2.getTextSize(no_face_text, cv_font, 1, 2)[0]
textX = int((frame.shape[1] - textsize[0]) / 2)
textY = int((frame.shape[0] + textsize[1]) / 2)
cv2.putText(img = frame,
text = no_face_text,
org = (textX, textY),
fontFace = cv_font, fontScale = 1, thickness = 2,
color = (255,255,255))
else:

# Picking the largest face, cropping, resizing and scaling it:
x, y, width, height = detected_faces[np.argmax(detected_faces[:,2])]
im = im[y:y + height, x:x + width]
im = cv2.resize(im, (100, 100))
im = im/255

# preparing for model prediction, feeding to model:
img_array = np.array(im)
img_array = img_array.reshape(1,100,100,1)
prediction = model.predict(img_array)[0]

# Drawing the rectangle and inserting texts:
cv2.rectangle(frame, (x, y), (x + width, y + height), cv_color, 3)

# Text box to instruct the user of how to quit the live stream:
cv2.putText(img = frame,
text = 'Press Q to quit',
org = (10, 20),
fontFace = cv_font, fontScale = 0.5, thickness = 1,
color = (255,255,255))

# Adding prediction probabilities to the frame:
cv2.putText(img = frame,
text = f'{classes[0]}: {int(prediction[0]*100)}%',
org = (x + width + 10, y + 10),
fontFace = cv_font, fontScale = 0.5, thickness = 1,
color = cv_color)
cv2.putText(img = frame,
text = f'{classes[1]}: {int(prediction[1]*100)}%',
org = (x + width + 10, y + 30),
fontFace = cv_font, fontScale = 0.5, thickness = 1,
color = cv_color)
cv2.putText(img = frame,
text = f'{classes[2]}: {int(prediction[2]*100)}%',
org = (x + width + 10, y + 50),
fontFace = cv_font, fontScale = 0.5, thickness = 1,
color = cv_color)
if len(classes) == 5:
cv2.putText(img = frame,
text = f'{classes[3]}: {int(prediction[3]*100)}%',
org = (x + width + 10, y + 70),
fontFace = cv_font, fontScale = 0.5, thickness = 1,
color = cv_color)
cv2.putText(img = frame,
text = f'{classes[4]}: {int(prediction[4]*100)}%',
org = (x + width + 10, y + 90),
fontFace = cv_font, fontScale = 0.5, thickness = 1,
color = cv_color)

cv2.putText(img = frame,
text = f'You are {classes[np.argmax(prediction)]}',
org = (x, y - 20),
fontFace = cv_font, fontScale = 1, thickness = 2,
color = cv_color)

# Showing the frame with annotations:
cv2.imshow("Real-Time Facial Expression Recognizer", frame)

# Allowing for quit using Q key:
key=cv2.waitKey(1)
if key == ord('q'):
break
video.release()
cv2.destroyAllWindows()

All we need to do now is to load the trained models and feed them into the RealTimeExpressionRecognizer function:

### 1. Model with 3 Classes (Happy, Sad and Surprised):¶

In [ ]:
# Loading the trained model:

# List of expected classes:

RealTimeExpressionRecognizer(model, classes)

### 2. Model with 5 Classes (Neutral, Happy, Sad, Surprised and Angry):¶

In [ ]:
# Loading the trained model:

# List of expected classes:
classes = ['Neutral', 'Happy', 'Sad', 'Surprised', 'Angry']

RealTimeExpressionRecognizer(model, classes)

WARNING:tensorflow:From /Users/Arash/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /Users/Arash/anaconda3/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use rate instead of keep_prob. Rate should be set to rate = 1 - keep_prob.
WARNING:tensorflow:From /Users/Arash/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Heads-up: Due to some compatibility issues between Jupyter Notebook and OpenCV, it is recommended to run this code as a stand-alone .py file on the terminal or an IDE such as PyCharm. Running on Jupyter Notebook is expected to work but you may not be able to close the capturing screen using the Q key (in such case you will need to force quit and restart the Python kernel).


text:
# 7.6 Modeling with trigonometric equations  (Page 9/14)

 Page 9 / 14

A muskrat population oscillates 33 above and below average during the year, reaching the lowest value in January. The average population starts at 900 muskrats and increases by 7% each month. Find a function that models the population, $\text{\hspace{0.17em}}P,$ in terms of months since January, $\text{\hspace{0.17em}}t.$

A fish population oscillates 40 above and below average during the year, reaching the lowest value in January. The average population starts at 800 fish and increases by 4% each month. Find a function that models the population, $\text{\hspace{0.17em}}P,$ in terms of months since January, $\text{\hspace{0.17em}}t.$

$P\left(t\right)=-40\mathrm{cos}\left(\frac{\pi }{6}t\right)+800{\left(1.04\right)}^{t}$

A spring attached to the ceiling is pulled 10 cm down from equilibrium and released. The amplitude decreases by 15% each second. The spring oscillates 18 times each second. Find a function that models the distance, $\text{\hspace{0.17em}}D,$ the end of the spring is from equilibrium in terms of seconds, $\text{\hspace{0.17em}}t,$ since the spring was released.

A spring attached to the ceiling is pulled 7 cm down from equilibrium and released. The amplitude decreases by 11% each second. The spring oscillates 20 times each second. Find a function that models the distance, $\text{\hspace{0.17em}}D,$ the end of the spring is from equilibrium in terms of seconds, $\text{\hspace{0.17em}}t,$ since the spring was released.

$D\left(t\right)=7{\left(0.89\right)}^{t}\mathrm{cos}\left(40\pi t\right)$

A spring attached to the ceiling is pulled 17 cm down from equilibrium and released. After 3 seconds, the amplitude has decreased to 13 cm. The spring oscillates 14 times each second. Find a function that models the distance, $\text{\hspace{0.17em}}D,$ the end of the spring is from equilibrium in terms of seconds, $\text{\hspace{0.17em}}t,$ since the spring was released.

A spring attached to the ceiling is pulled 19 cm down from equilibrium and released. After 4 seconds, the amplitude has decreased to 14 cm. The spring oscillates 13 times each second. Find a function that models the distance, $\text{\hspace{0.17em}}D,$ the end of the spring is from equilibrium in terms of seconds, $\text{\hspace{0.17em}}t,$ since the spring was released.

$D\left(t\right)=19{\left(0.9265\right)}^{t}\mathrm{cos}\left(26\pi t\right)$

For the following exercises, create a function modeling the described behavior. Then, calculate the desired result using a calculator.

A certain lake currently has an average trout population of 20,000. The population naturally oscillates above and below average by 2,000 every year. This year, the lake was opened to fishermen. If fishermen catch 3,000 fish every year, how long will it take for the lake to have no more trout?

Whitefish populations are currently at 500 in a lake. The population naturally oscillates above and below by 25 each year. If humans overfish, taking 4% of the population every year, in how many years will the lake first have fewer than 200 whitefish?

$20.1\text{\hspace{0.17em}}$ years

A spring attached to a ceiling is pulled down 11 cm from equilibrium and released. After 2 seconds, the amplitude has decreased to 6 cm. The spring oscillates 8 times each second. Find when the spring first comes between $\text{\hspace{0.17em}}-0.1\text{\hspace{0.17em}}$ and effectively at rest.

A spring attached to a ceiling is pulled down 21 cm from equilibrium and released. After 6 seconds, the amplitude has decreased to 4 cm. The spring oscillates 20 times each second. Find when the spring first comes between $\text{\hspace{0.17em}}-0.1\text{\hspace{0.17em}}$ and effectively at rest.

17.8 seconds

The average annual population increase of a pack of wolves is 25.
how do you find the period of a sine graph
Period =2π if there is a coefficient (b), just divide the coefficient by 2π to get the new period
Am
if not then how would I find it from a graph
Imani
by looking at the graph, find the distance between two consecutive maximum points (the highest points of the wave). so if the top of one wave is at point A (1,2) and the next top of the wave is at point B (6,2), then the period is 5, the difference of the x-coordinates.
Am
you could also do it with two consecutive minimum points or x-intercepts
Am
I will try that thank u
Imani
Case of Equilateral Hyperbola
ok
Zander
ok
Shella
f(x)=4x+2, find f(3)
Benetta
f(3)=4(3)+2 f(3)=14
lamoussa
14
Vedant
pre calc teacher: "Plug in Plug in...smell's good" f(x)=14
Devante
8x=40
Chris
Explain why log a x is not defined for a < 0
the sum of any two linear polynomial is what
Momo
how can are find the domain and range of a relations
the range is twice of the natural number which is the domain
Morolake
A cell phone company offers two plans for minutes. Plan A: $15 per month and$2 for every 300 texts. Plan B: $25 per month and$0.50 for every 100 texts. How many texts would you need to send per month for plan B to save you money?
6000
Robert
more than 6000
Robert
can I see the picture
How would you find if a radical function is one to one?
how to understand calculus?
with doing calculus
SLIMANE
Thanks po.
Jenica
Hey I am new to precalculus, and wanted clarification please on what sine is as I am floored by the terms in this app? I don't mean to sound stupid but I have only completed up to college algebra.
I don't know if you are looking for a deeper answer or not, but the sine of an angle in a right triangle is the length of the opposite side to the angle in question divided by the length of the hypotenuse of said triangle.
Marco
can you give me sir tips to quickly understand precalculus. Im new too in that topic. Thanks
Jenica
if you remember sine, cosine, and tangent from geometry, all the relationships are the same but they use x y and r instead (x is adjacent, y is opposite, and r is hypotenuse).
Natalie
it is better to use unit circle than triangle .triangle is only used for acute angles but you can begin with. Download any application named"unit circle" you find in it all you need. unit circle is a circle centred at origine (0;0) with radius r= 1.
SLIMANE
What is domain
johnphilip
the standard equation of the ellipse that has vertices (0,-4)&(0,4) and foci (0, -15)&(0,15) it's standard equation is x^2 + y^2/16 =1 tell my why is it only x^2? why is there no a^2?
what is foci?
This term is plural for a focus, it is used for conic sections. For more detail or other math questions. I recommend researching on "Khan academy" or watching "The Organic Chemistry Tutor" YouTube channel.
Chris
how to determine the vertex,focus,directrix and axis of symmetry of the parabola by equations


text:
My Math Forum Help with limits for calculus homework

 Calculus Calculus Math Forum

 June 6th, 2010, 12:36 PM #1 Newbie   Joined: Jun 2010 Posts: 2 Thanks: 0 Help with limits for calculus homework Evaluate the integral for n = 0, 1, 2, and 3. http://www.webassign.net/cgi-bin/symima ... 29%29%20dx I've already solved the one for n=0, it's 10. not sure how to exactly go about on the other ones.
 June 6th, 2010, 01:25 PM #2 Global Moderator   Joined: May 2007 Posts: 6,821 Thanks: 723 Re: Help with limits for calculus homework Integration by parts can give you the integral involving x^n in terms of the integral involving x^(n-1). Start with n=1 and work your way up.
 June 6th, 2010, 01:45 PM #3 Newbie   Joined: Jun 2010 Posts: 2 Thanks: 0 Re: Help with limits for calculus homework I've tried. but I keep getting answers that don't make sense. I've taken the the integral from 0 to inf, and at n=1. I've let u=x, dv=e^-x and so on. However, my answer is still wrong.
 June 6th, 2010, 04:13 PM #4 Global Moderator     Joined: Oct 2008 From: London, Ontario, Canada - The Forest City Posts: 7,963 Thanks: 1148 Math Focus: Elementary mathematics and beyond Re: Help with limits for calculus homework I believe I have an answer for n = 1, if it's any help: $\int10xe^{-x}\,dx$ Integration by parts: Let $u\,=\,10x,\,du\,=\,10\,dx,\,dv\,=\,e^x\,dx,\,v\,=\ ,-e^{-x}$ $-10xe^{-x}\,-\,\int-10e^{-x}\,dx$ $=\,-10xe^{-x}\,+\,\int10e^{-x}\,dx$ $\,=-10xe^{-x}\,-\,10e^{-x}$ (We're doing a definite integral so I'll leave out the constant of integration). If my intuition is correct, to evaluate the definite integral we take the limit: $\lim_{x \to \infty}\left(-10xe^{-x}\,-\,10e^{-x}\right)\,=\,\lim_{x \to \infty}-10xe^{-x}\,-\,\lim_{x \to \infty}10e^{-x}$ $=\lim_{x \to \infty}\,-10xe^{-x}\,-\,0$ For the limit $-10\lim_{x \to \infty}xe^{-x}$ rewrite as $\frac{x}{1/e^{-x}}$ and apply L'Hopital's Rule, thus the limit is . So, $\int_{0}^{\infty}10xe^{-x}\,=\,0\,-\,(-10)\,=\,10$ I think my math is good -- hope it helped.
 June 6th, 2010, 05:02 PM #5 Global Moderator   Joined: Dec 2006 Posts: 20,966 Thanks: 2216 By the definition of the gamma function, $\int_0\,^\infty10x^ne^{-x}dx\,=\,10\text{\Gamma}(n+1).$ If n is a non-negative integer, that's 10(n!). I'll leave it to you to look up anything more you need (or use the method mathman suggested). Integration by parts: let $u\,=\,10x,\,du\,=\,10\,dx,\;dv\,=\,e^{-x}\,dx,\,v\,=\,-e^{-x}.$ $\int10xe^{-x}\,dx\,=\,-10xe^{-x}\,-\,\int-10e^{-x}\,dx\,=\,-10xe^{-x}\,-\,10e^{-x}\,+\,\text{C.}$ etc.
June 8th, 2010, 03:48 PM   #6
Global Moderator

Joined: May 2007

Posts: 6,821
Thanks: 723

Re:

Quote:
 Originally Posted by skipjack By the definition of the gamma function, $\int_0\,^\infty10x^ne^{-x}dx\,=\,10\text{\Gamma}(n+1).$ If n is a non-negative integer, that's 10(n!). I'll leave it to you to look up anything more you need (or use the method mathman suggested). Integration by parts: let $u\,=\,10x,\,du\,=\,10\,dx,\;dv\,=\,e^{-x}\,dx,\,v\,=\,-e^{-x}.$ $\int10xe^{-x}\,dx\,=\,-10xe^{-x}\,-\,\int-10e^{-x}\,dx\,=\,-10xe^{-x}\,-\,10e^{-x}\,+\,\text{C.}$ etc.
Integration by parts:

$\int_0\,^\infty10x^ne^{-x}dx\,=n\int_0\,^\infty10x^{n-1}e^{-x}dx\$, etc.

 June 9th, 2010, 04:53 PM #7 Newbie   Joined: Jun 2010 Posts: 21 Thanks: 0 Re: Help with limits for calculus homework You can make this a series so that you do not have to repeat the integral. So basically if you call Un=Integral(10*x^n*e^(-x)) (n>0). You do the integral by parts of that and you will get Un=-10X^(n)*e^(-x) + nUn-1 and Uo=10 like u already figured. And all you have to do now is plug in n for each number. Sorry I don't know how to put an integral here so hope u can read it.

 Tags calculus, homework, limits

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post hamburgertime Calculus 4 September 15th, 2013 11:58 PM kingkos Calculus 2 December 7th, 2012 03:19 AM anoonpinkness Calculus 2 March 15th, 2011 10:35 AM AbbyMac Calculus 2 May 5th, 2010 08:48 AM kingkos Algebra 2 December 31st, 1969 04:00 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top


text:
# a better way to measure game closeness

TLDR: The final score does not tell the whole story regarding how close a game was. Integrated Point Differential (IPD) improves upon Point Differential by accounting for the score throughout the game, as opposed to just the final score. Spread Integrated Point Differential (SIPD) adjusts IPD with respect to the spread, and could be a useful proxy for whether a bet was the right side (even if it didn’t cover).

What is the best way to measure how close a game is?

So the obvious answer is, check the score. But the score is not necessarily indicative of how close a game is. If a team jumps out to a 31-0 halftime lead, and proceeds to win 31-24, this game was never close, even though the final margin was just 7 points. See Panthers Seahawks 2015 playoffs.

In contrast, if in the middle of the third quarter the score is 24-21, and the team with 21 ends up winning 48-27, the game was a lot closer than the final score indicates (garbage time touchdowns). See Patriots Cowboys 2007 regular season.

So, perhaps there’s a better way to measure game closeness than point differential.

### Integrated Point Differential (IPD)

I sought to create a better metric for evaluating how ‘close’ a game is. I’ve called my metric “integrated point differential,” or ‘ipd’ for short. To calculate ipd for a given team in a given game, we take the integral of the team’s point differential throughout the game with respect to time, where point differential is defined by ([team score] - [opponent score]).

It’s simpler than it may sound. To get an idea of the intuition behind the metric, consider the following game between the Patriots and Dolphins.

Patriots Dolphins Time Transpired (Seconds) Quarter
0 0 0 1
3 0 300 1
3 7 780 1
3 10 1580 2
6 10 2210 3
13 10 2930 4
20 10 3430 4

The rows in the table represents every time there was a score in the game. “Time Transpired (Seconds)” displays how much time had already transpired in the game when the score occurred (there are 60 minutes, or 3600 seconds, in a game). For instance, the first score of the game was a field goal by the patriots, 300 seconds into the game. Note 1800 seconds is halftime, and 3600 seconds is the end of the game.

Here is the plot for the point differential throughout the game.

The point differential starts at 0 when the game begins (the score is 0 to 0). It jumps to three when the Patriots score at 300 seconds in, and drops to -4 when the Dolphins score a touchdown to lead 7-3. We continue this process for the whole game.

This game was by no means a blowout for the Patriots; the Patriots were trailing for a large portion of the game and never sealed the deal until the fourth quarter. We can see that the point differential is negative for a large stretch of the game when the Patriots are behind. To calculate the Patriot’s ipd in this game, we simply take the integral of the point differential, which in this case is equal to calculating the area of the space colored blue.

The ipd metric comes out to:$$\text{ipd} = 3*480 - 4*800 - 7*630 - 4*720 + 3*500 + 10*170 = \boxed{-5850}$$Now consider an alternative outcome:

Patriots Dolphins Time Transpired (Seconds) Quarter
0 0 0 1
7 0 300 1
14 0 780 1
17 0 1580 2
20 0 2210 3
20 3 2930 4
20 10 3430 4

Note the final score of the game is the same. Here is the point differential plot.

Once again, the point differential is 0 to begin (game is tied 0-0). The Patriots score a touchdown at 300 seconds in, and the point differential jumps to 7. The point differential is at its maximum when the Patriots lead 20-0 starting at the 2210 second mark, and ending at the 2930 second mark.

This game would have felt like much more of a blowout. The Patriots were in clear control of the game, before the Dolphins scored a few ‘garbage time’ points near the end. The ipd for this game is$$\text{ipd} = 7*480 + 14*800 + 17*630 + 20*720 + 17*500 + 10*170 = \boxed{49870}$$To summarize, we have two games with the same final score, but vastly different game flows. The ipd metric is able to capture this and reflects how the second game was a much more ‘dominant’ victory by the Patriots.

### Spread Integrated Point Differential (SIPD)

Another interesting approach we can take is adapting this metric to NFL spreads. If you’re not familiar with betting terminology, check out my basic guide.

Just as the final score is not necessarily indicative of how close a game was, it is also not necessarily indicative of how good a bet was. In other words, even if a team covers, they may have gotten lucky or it might have been a close call. As a gambler, we aren’t interested in games where the outcome could go either way; we are more interested in determining games where the spread may be set completely inaccurately, making the winning side a ‘safe bet.’

Thus, it stands to reason that one might be interested in a metric that measures how ‘safe’ a bet was. SIPD works as a simple modification to the ipd calculation. Instead of integrating the point differential over time, we integrate the point differential over time translated according to the spread. For instance, if the spread is Patriots -3, and the Patriots are ahead by 14, then the point differential (14) translated according to the spread (-3) is 11. If the Patriots are ahead by 3, then the point differential translated according to the spread is 0.

For instance, let’s take the (first) game from the IPD section where the Patriots won 20-10. Suppose the spread in that game was Patriots -3. Then our graph would look like:

The SIPD here would be $$\text{sipd} = -3*300 + 0*480 - 7*800 -10*630 - 7*720 +0*500 + 7*170 = \boxed{-16650}$$

The Patriots would have covered, but the sipd accurately reflects that for much of the game, it may have seemed like the Patriots would not have covered, and that the Dolphins may have in fact been the better bet (i.e. if the same game was played in a million alternative universes, perhaps the Dolphins would have covered more often than not).

Note that the sipd is a translation of ipd; we can calculate (for non-overtime games): $$\text{sipd} = \text{ipd} + \text{spread} *3600$$

### IPD in Practice

Using Python’s BeautifulSoup Module, I scraped box score data from Pro-Football-Reference and calculated the IPD and SIPD for every game from 2002 to 2016.

Point differential are calculated with respect to the home team (i.e. point differential = [home score] - [away score]). Thus, ‘blowouts’ by the road team will have very negative point differentials.

Some interesting findings:

Five Lowest IPDs (Biggest Road Blowouts)

Date Home Team Away Team Home Score Away Score IPD
Week 7, 2010 Broncos Raiders 14 59 -112,130
Week 6, 2014 Buccaneers Ravens 17 48 -101823
Week 13, 2005 Eagles Seahawks 0 42 -99351
Week 14, 2007 Ravens Colts 20 44 -94082
Week 10, 2010 Washington Eagles 28 59 -93801

The most interesting game here is the Colts’ blowout of the Ravens, where the Colts won by “just” 24 points. The game would rank 146th in terms of ‘road blowout’ by point differential alone (i.e. between 2002 and 2016, there were 145 games in which the road team won by 25 or more), but ranks 4th in IPD rankings. Here, IPD captures how the Colts led 30-0 with 11:57 left to go in the second quarter, and 44-7 until the Ravens tacked on two garbage time touchdowns in the 4th quarter - box score for reference. In this sense, IPD better captures how badly the Colts destroyed the Ravens than point differential alone.

Meanwhile, the biggest road blowout in terms of point differential was Patriots @ Bills in Week 10, 2007, when the Patriots won 56-10. This game ranked 7th in IPD.

Five Highest IPDs (Biggest Home Blowouts)

Date Home Team Away Team Home Score Away Score IPD
Week 6, 2009 Patriots Titans 59 0 121046
Week 3, 2014 Falcons Buccaneers 56 14 118517
Week 13, 2014 Rams Raiders 52 0 113257
Week 14, 2012 Seahawks Cardinals 58 0 112586
Week 7, 2011 Saints Colts 62 7 105891

Nothing surprising here - the only ‘anomaly’ is the Falcons Bucs game, which ranked 17th on point differential alone (i.e. there were 16 games between 2002 and 2016 in which the home team won by 43 or more). However, IPD captures how the Falcons led 56-0 until 8:46 in the 4th, when the Buccaneers tossed two garbage time touchdowns.

### SIPD in Practice

Things get more interesting when we look at SIPD - the games with highest absolute (i.e. apply absolute value) SIPD could be viewed, in hindsight, as the ‘safest’ bets - games in which the spread was wildly off, where your bet was least in doubt.

Another way we can interpret this: NFL games involve quite a bit of luck. If you cover your bet, that doesn’t mean you made the right bet - i.e. if the game was played in 10,000 alternative universes, each side might cover 5,000 times. However, obviously sportsbooks can’t set perfect spreads every time - there will be games which the spread is wildly off, where perhaps if the game was played in 10,000 alternative universes, one side might cover 8,000 times. Games with extremely high absolute SIPD are games in which we are most confident that the spreads were off.

Obviously, we don’t know the SIPD until after the game is over. However, maybe studying previous games with high absolute SIPDs can give us insight on how we can identify future games in which spreads are off.

Anyways, here are the eleven games in which absolute SIPD was highest. Point Differential is once again calculated with respect to the home team. The spread shown is also with respect to the home team (i.e. negative spread means home team was favored, positive spread means road team was favored).

Eleven Highest Absolute SIPD

Rank Date Home Team Away Team Spread Home Score Away Score SIPD
1 Week 7, 2010 Broncos Raiders -7 14 59 -137330
2 Week 14, 2014 Saints Panthers -9 10 41 -114464
3 Week 10, 2013 Colts Rams -7 8 38 -108266
4 Week 3, 2014 Falcons Buccaneers -6 56 14 96917
5 Week 10, 2012 Dolphins Titans -7 3 37 -96911
6 Week 1, 2015 Buccaneers Titans -3 14 42 -94884
7 Week 16, 2009 Giants Panthers -8.5 9 41 -94714
8 Week 13, 2014 Rams Raiders -6 52 0 91657
9 Week 7, 2009 Bengals Bears +2 45 10 91039
10 Week 6, 2014 Buccaneers Ravens +3 17 48 -91023
11 Week 13, 2010 Chargers Raiders -13 13 28 -90249

The reason I include 11 games - and not 10 - was because I think the 11th-ranked game is interesting. Unlike the other games, the point differential was 15 points - nothing to write home about.

However, the SIPD indicates that betting on the Raiders here would have been an extremely safe bet. And the game flow verifies this: the Chargers were favored by 13, but the Raiders led 14-0 in the first quarter, 21-3 at the half, and 21-6 at the end of the third quarter. At that point, the Chargers would have needed to outscore the Raiders by at least 28 to cover. If you bet on the Raiders, your money was never in doubt.

### Summary

• IPD improves over point differential in representing your internal sense of how close a game was. For games where you say “the game was closer than the score indicates,” this will be reflected by a lower (absolute) IPD.
• IPD is useful in finding good games to watch. The team with a negative IPD won? Likely a comeback. The 2017 Super Bowl between the Patriots and Falcons had a -40859 IPD for the Patriots (note the IPD accurately reflects how for much of the game, things didn’t feel close). Games with extremely low (absolute) IPDs and high scores are likely exciting back-and-forth battles with several lead changes.
• SIPD is useful tool for betters, as a metric that sheds light on how ‘off’ a spread was. The higher the SIPD, the more covering was never in doubt.
• With the understanding that the game of football involves a lot of luck, SIPD may also be a useful metric for determining if you ‘made the right bet.’ For instance, you might lose a bet on a backdoor cover, but a positive SIPD might be a good proxy for whether you had the right side (i.e. in 10,000 universes you would have covered in more than half).
• Although all examples were in reference to football here, IPD and SIPD can easily be extended to other sports as well.


text:
### Rate of Convergence for the Zero Relaxation Limit

Wen Shen, Aslak Tveito, and Ragnar Winther

Abstract: Some recent results on the rate of convergence towards equilibrium for some $2\times2$ systems of conservation laws which include stiff relaxation terms are presented. We focus our attention on certain specific model problems. We will discuss the possibility of deriving properties like bounds on the total variation, stability with respect the initial data and error estimates for finite difference schemes which are independent of the relaxation parameters, and explain how such bounds can be used to obtain estimates on the rate of convergence for the zero relaxation limit.

Paper:
Available as PostScript
Title:
Rate of convergence for the zero relaxation limit
Author(s):
Wen Shen, <wens@ifi.uio.no>
Aslak Tveito, <aslak@ifi.uio.no>
Ragnar Winther, <ragnar@ifi.uio.no>
Publishing information:


text:
# Calculating Expected Value and Variance Given Random Variable Distributions.

I am trying to solve the following question from one of my classes.

I generally understand how to find the expected value and variance when given a random variable. However, when doing so, it is usually with an example where the values and probabilities of the random value are pretty easily defined (like rolling a die). In this example, I'm unsure of how to go about setting up and solving the problem because I'm not sure what values X or Y could take on and what the probabilities of those values would be. Could anyone show how to find expected values and variances in this problem?

The question tells you exactly what values $X$ and $Y$ can take and what the probabilities are. $X$ takes the values $2$ and $-2$, each with probability $1/2$. $Y$ takes the values $4$ and $-1$, with probabilities $0.2$ and $0.8$.
• Your calculation of $E(X^2)$ is wrong: $(-2)^2 = 2^2$, not $-(2^2)$. Also notice that $(100 X)^2 = 100^2 X^2$, not $100 X^2$. – Robert Israel Sep 22 '14 at 4:47
"I will throw a fair coin, if it comes up heads I will give you $2$ dollars if not, you will give me $2$ dollars. You can also choose to play with unfair coin which comes up heads $20 \%$ of the time. If it comes up heads I will give you $4$ dollars if not, you will give me $1$ dollar. "
In the fair coin case your expected profit: $$2*0.5+(-2)*0.5 = 0$$ In the unfair coin case: $$4*0.2+(-1)*0.8=0$$
It is better not to waste your time with him because your expected profit is $0$.


text:
September 18, 2020, 11:43:43 am

You can help CodeWalrus stay online by donating here.

 WARNING: If you upgrade your TI-83 Premium CE or TI-84 Plus CE to OS 5.5.1 and higher, it removes all compatibility with most games and removes ASM/C programming. You will need a jailbreak tool called ArTIfiCE in order to add ASM/C support back and some games such as First Fantasy and 1000 Bornes also requires ASMHOOK. Downgrading new hardware revisions is impossible and older ones requires a special tool. Likewise, do NOT update your TI-Nspire CX past OS 4.5.0, else using Ndless and ASM/C programs will be impossible.

## Caleb Learns Linux

Started by Caleb Hansberry, November 09, 2015, 11:28:29 pm

0 Members and 1 Guest are viewing this topic.

#### Streetwalrus

##### November 15, 2015, 09:27:37 am #15
That's unfortunate, it will be hard to troubleshoot without access to the machine. Your best bet at this point is a reinstall I suppose. :/

#### Travis

##### November 15, 2015, 04:58:48 pm #16
Yeah, reinstalling is probably the easiest way for now while you're still learning your way around, even if it wouldn't be strictly necessary if you knew what was wrong and how to fix it.

One good idea is to write down (or keep in a text file somewhere) everything you do on the system as root or with sudo, so if something breaks you can retrace your steps and try to figure out what you might have done to cause it. It also gives you a list of things to redo if you have to reinstall or switch to another distro so you don't have to figure it all out again. I wish I had done that on my current Arch desktop system; I plan to get back into that habit when I change to some other distro which I'm planning to do someday because rolling release doesn't seem to work well for me.

The recommended way to make modules load automatically on boot on Arch-based systems is described here: https://wiki.archlinux.org/index.php/Kernel_modules#Automatic_module_handling
Basically, you make a file in /etc/modules-load.d/ and list the modules you want. Putting "brcmsmac" on a line in one of these files ought to work. On my Arch desktop right now, I have '/etc/modules-load.d/custom.conf' which I created and just threw things in:

# Load extra needed modules that aren't loaded automaticallyloop#uvesafb#acpi_cpufreqvboxdrvvboxnetfltvboxnetadp

Lines starting with # are ignored; the rest are modules I wanted loaded on boot because they don't load automatically for whatever reason. (In case you're curious, 'loop' is the module that allows mounting and accessing things like the contents of ISO and disk image files directly as if they were actually on a disk in my system, the 'vbox...' stuff is drivers for VirtualBox (lets me run other OSes in virtual machines from inside the main OS), and the commented-out lines are apparently stuff I was once fooling around with and decided I didn't need (I might as well delete those).

Can't really answer the backlight thing since I've never really had to mess with ACPI stuff much.

#### Streetwalrus

##### November 15, 2015, 05:02:35 pm #17
Why would you load loop on boot ? I thought it was supposed to be automatically loaded when you mount something with -o loop (and apparently mount is smart enough to make this option implicit).

#### Travis

##### November 15, 2015, 07:22:28 pm #18
It doesn't seem to work for me. I have to always load it separately before the mount -o loop or losetup commands work.

#### Streetwalrus

##### November 15, 2015, 08:30:40 pm #19
Strange, it seems to work fine over here, I don't even need to specify -o loop, and the module gets loaded.

#### Lionel Debroux

##### November 21, 2015, 09:04:09 pm #20
Under Debian sid amd64, loop isn't loaded by default or automatically when I use mount -o loop, either.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.

#### Caleb Hansberry

##### December 04, 2015, 02:15:45 am #21
Aaaaah been too long since I posted my update here, I know.
So I've been messing around with Antergos. Reinstalled it with Gnome (I think, whatever the default was) as the desktop environment instead of KDE. Now the wifi works fine for some reason. The brightness is the same issue, but I succeeded in making a script that worked, I had to chmod +x it which was interesting. It takes the value of "/sys/class/backlight/intel_backlight/brightness", stores it into a variable called "luminance", adds or subtracts 1000 (the range is 0 to 13046), and stores it back.

Next I need to make some sort of exponential function to control the brightness. This will be hard. The brightness changes much more dramatically at lower numbers, so should change less, and less at high numbers. Like 6000 to 12000 is a small difference, and 20 to 1000 is a big difference (20 is the lowest you can stil lsee anything on the screen). Got any ideas as to how this would work? I never was very good at math, never really finished Algebra, and don't know where to start.

Next I need to install Python for programming. I know it has python installed, but I need a good beginner tutorial that is aimed at graphics not math, and I'll need a good IDE.

#### semiprocoder

##### December 04, 2015, 02:37:00 am #22 Last Edit: December 04, 2015, 02:50:29 am by semiprocoder
Well, instead of adding or subtracting to or from the brightness, I suggest multiplying/dividing the brightness by some value. It would be best if you start with 20 and then add from there.

Here are some values I calculated, which 20 as the min val and 13046 as the max val.
~3.655 with 5 different brightness values
~1.9118 with 10 different brightness values
~1.5404 with 15 different brightness values
and ~1.3827 with 20 different brightness values.

I calculated it using this, with n=num different brightness values:
(13046/20)^(1/n)=(652.3)^(1/n)
same thing(hopefully) but just in latex:
$$(\frac{13046}{20})^{\frac{1}{n}}=652.3^{\frac{1}{n}}$$

In other words, $$\sqrt[n]{652.3}$$.
Hope that makes sense, and otherwise just use my precalculated variables.

#### Travis

##### December 04, 2015, 01:25:43 pm #23 Last Edit: December 04, 2015, 01:41:54 pm by Travis
Ooh, this is one of those fun, practical uses for using graphing calculators. You can experiment with different formulas like the ones "semiprocoder" gave in function graphing mode and play with them until you get a curve that does what you want. It can take some trial and error, but eventually you get a feel for what math operations do what to the graph. Or, if you have some idea of a few inputs you want to map to what outputs at different points, you can throw them into the statistics editor and find a regression model that might be close to what you want. (Perhaps I just happen to have a bit too much fun doing this. It's definitely educational, though.)

Implementing the equations in bash scripting might be slightly tricky, though, since math is very limited, and I don't think it does floating point. You can easily pass the equations to external programs like 'bc' or even python and capture the output result and use it, though.

Graphics in Python has a bunch of choices, depending on what "system" you want to use. It has its own Tkinter GUI toolkit built in (and apparently a turtle graphics module as well), but there are also libraries for using SDL, GTK+, Qt, and other GUI toolkits with Python. There are certainly a number of IDEs available, but I don't know much about them. I haven't really felt the need to use an IDE, personally; a good text editor with good multiple-file and Python-syntax support, some open terminal windows, and an interactive shell like ipython, work pretty well for me.

#### Caleb Hansberry

##### December 04, 2015, 10:04:11 pm #24
Nice, guys! 1.3827 is a nice enough number. The math part definitely confused me though to be honest. I actually tried using my CSE for the task first but it threw an error that I didn't understand

Can't figure out how to get it into bash though. I believe all I need to do is multiply brightness by 1.3827 and then store the result back into brightness, but first I need to figure out how to do that part, and then I need to stop it from giving the LCD panel a decimal number (was that the technical name? a number with numbers to the right of the decimal point) cause it won't like that. Then I also need to stop it from giving it a number above 13046. I tried just stripping off the numbers to the right of the decimal point, but that does weird stuff to the math when you multiply, remove them, and then divide, and remove them again.
Maybe I could store the variable that it does math on elsewhere, and only turn it back into an integer when it's stored into Brightness.

For Python, most likely Turtle is fine right now. So I can just program in Nano then?

Anyways, here's my code:
brightness=$(cat /sys/class/backlight/intel_backlight/brightness) luminance=$(expr $brightness * 1.3827) if$luminance > 13046 then $luminance=13046 echo$luminance | sudo tee /sys/class/backlight/intel_backlight/brightness

But it doesn't work >_> something about the "if" command used there?

#### Yuki

##### December 04, 2015, 10:14:01 pm #25
You're missing a few stuff here. Here's a more correct code.

if [ $luminance -gt 13046 ] then luminance=13046 fi Read Zarmina! YUKI-CHAAAANNNN In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader --Snektron if you wanna throw money at me and/or CodeWalrus monthly it's here #### Caleb Hansberry ##### December 05, 2015, 01:15:45 am #26 Last Edit: December 05, 2015, 01:26:11 am by Caleb Hansberry Ah, thanks Juju! When I tried it, it told me some error, but then Travis gave me a different code which I used and it worked well - sorry that I didn't use your's But, it finally works right! I could change the brightness with the function keys out of the box in windows, but for some reason it failed in Linux. But now it finally is put together. The finished script that Travis and the others helped me put together is: brightness=$(cat /sys/class/backlight/intel_backlight/brightness)luminance=$(python -c "print(min(int(round($brightness * 1.3827)),13046))")echo \$luminance | sudo tee /sys/class/backlight/intel_backlight/brightness

It changes the brightness with 20 levels beautifully, and I do understand how it works which is great Then I just made a file in the /etc/acpi/events/ directory containing:
event=video/brightnessup BRTUP 00000086 00000000action=/usr/local/bin/brightnessup

To tie the ACPI event to the script, and it worked well! Next I need to tell it to run "sudo systemctl start acpid.service" when it boots up, because it doesn't work without that.

[EDIT] Okay so I added an entry to .bashrc to start the acpid service. However, that means the brightness buttons don't work until I open the terminal and type my sudo password. How else should I be doing this so I don't need to type my password to execute this command and don't need to open the terminal?

#### Travis

##### December 05, 2015, 05:32:31 pm #27 Last Edit: December 05, 2015, 05:34:23 pm by Travis
Try "sudo systemctl enable acpid.service". That should set it to start acpid automatically during bootup.

#### Caleb Hansberry

##### December 22, 2015, 11:01:50 pm #28
Thanks Travis, that worked fine!

Sorry I've been really busy this season, plus the netbook screen got damaged so half the screen flickers now. Turns out netbooks are really very finicky. I'll get back to it as soon as I can though.

#### Caleb Hansberry

##### August 31, 2016, 03:45:48 am #29
Alright, I think I'll be able to return! I'm pretty committed to giving Linux a fair shot even if it's loads of work

The netbook screen got worse and I couldn't handle it anymore, I just threw it away (on ebay for cost of shipping). So I finally got a new HDD for my desktop and wanna try dual booting Windows and Linux. Unless a different distro offers something major, I'll still plug away at Antergos, my experience wasn't bad with it.

How do I set that up? I'm installing Linux on a 160GB HDD, and have windows on 120GB SSD and a 1TB data drive. Should I modify the 160 from linux or windows to make the swap and root partitions?


text:
Spike raster plot

A graphical representation of neural activity - spike timing.

Background

The most important information of spikes or action potentials is timing. Size and shape do not matter. Therefore, in many cases it used to be enough to just store these spike timings offline. You would delete the actual shape of the spikes or the membrane potential between spikes present in the recorded voltage trace, in order to save space on your hard drive. Nowadays, computer space is no longer so much a limitation, and scientists are getting interested in items such as local field potentials and oscillations (and the size and shape of spikes). Still, for the analysis of spikes, creating a raster or a dot plot is one of the first things you would want to do. A raster (dot) plot graphically shows a tick (dot) at the time a spike was present in the recorded voltage trace.

Data

Here, you will create a raster plot of the activity of a neuron in the auditory cortex, that was recorded while 13 tones of different frequencies (200 Hz to 16 kHz, logarithmically spaced) at 4 different sound levels (40, 50, 60 and 70 dB) were presented 10 times (making a total of 520 trials). The data for this tutorial can be found here. Detection of action potentials and sorting of the spikes has already been done (by Jan Schnupp's BrainWare in TDT; if you are interested, you can find a review on spike detection and sorting here and a Matlab toolbox here).

Analysis

At every trial, the recording started 300 ms before the presentation a 150 ms long tone. Spikes at the start of the trial are timestamped 0 ms.

First, as always, you will have to load the data.

whos tonespike % to see the structure in your command space

In your workspace, you will see that the data are stored in a structure (struct), and this structure has a size of 1x520. To obtain the spike timings of the first trial, type:

t = tonespike(1).spiketime; % Spike timings in the first trial

This is a vector containing 12 elements / spike times (check this yourself). Every trial will have its own number of spikes, as the cell will not fire the same number of spikes for every stimulus. This is why the data are stored in a struct-array as this allows you to store vectors of different sizes. The second trial only has 5 spikes:

t = tonespike(2).spiketime; % Spike timings in the second trial

Now, let's plot a raster of the 180th trial:

t       = tonespike(180).spiketime; % Spike timings in the 180th trial
nspikes   = numel(t); % number of elemebts / spikes
for ii = 1:nspikes % for every spike
line([t(ii) t(ii)],[179.5 180.5],'Color','k'); % draw a black vertical line at time t (x) and at trial 180 (y)
end
xlabel('Time (ms)'); % Time is in millisecond
ylabel('Trial number');
You might notice that after 300 ms (the tone onset) spikes occur more often. So the firing rate of this neuron seems to increase, even for one trial, during the presentation of a sound.

The increase in firing rate will be more clear, when we plot all the trials. For that we add an extra for-loop.

ntrials = numel(tonespike); % number of trials
for jj = 1:ntrials
t       = tonespike(jj).spiketime; % Spike timings in the jjth trial
nspikes   = numel(t); % number of elemebts / spikes
for ii = 1:nspikes % for every spike
line([t(ii) t(ii)],[jj-0.5 jj+0.5],'Color','k');
% draw a black vertical line of length 1 at time t (x) and at trial jj (y)
end
end
xlabel('Time (ms)'); % Time is in millisecond
ylabel('Trial number');

You will see something similar to the top figure (also indicated by thick black vertical lines are onset and offset of the stimulus; note also the different y-axis label and ticks). The number of spikes increase during tone presentation (between 300 and 450 ms) for about half of the trials (and after tone offset there is another burst). You might notice that this neuron's activity is not very reproducible from trial to trial. This is to be expected, as neurons are usually tuned to specific stimulus features, and most trials contained different stimuli. However, even during an exact stimulus repeat, the neural response will contain an element of randomness. What this actually means for the reliability of neural information transmission, will be explained in other tutorials.

Matlab Code

The pa_spk_rasterplot.m file in the PandA toolbox easily produces the raster plots for structure arrays, and also for matrices.


text:
Sue M.

# gradient fields and exact differentials

A. let f(x,y)= xexy, and C be the path y=1/x from (1,1) to (0,∞)
1. calculate F=∇f
2. Calculate the integral ∫cF*dr
- directly
- by using the fundamental theorem for line integrals

B. Left f(x,y) = sinxcosx
1. calculate F=∇f

By:

Experienced Math Tutor

Sue M.

thank you for the help!
For part B i got F=<cos2x-sin2x, 0> is that correct?

if so,
1.what is the maximum value ∫cF*dr can have over all possible paths C in the plane?
2.What is the path that C can have for which this maximum value is attained?

Report

06/24/16

Darryl K.

Yes.  I cannot answer the other 2 questions right away.  I will get with you Saturday night.
Report

06/24/16

Sue M.

thank you!
Report

06/25/16

Darryl K.


text:
# geometry tessellate command

Syntax

geometry tessellate keyword ... <range>

Primary keywords:

Tessellate nodes. The nodes are tessellated in the current geometry set using the Qhull (http://www.qhull.org) package. Polygons are created in the current set, by default. See the to-set and start-set keywords to output polygons to different geometry sets. If the set keyword is not given, then the current set is used.

convex-hull

Calculate the convex hull of the nodes in the current geometry set. This keyword is not compatible with the start-set.

delaunay

Calculate the Delaunay simplices of the nodes of the current geometry set.

set s

Specify the geometry set.

start-set s

Each Delaunay simplex or Voronoi region is placed in a unique set. Each set name is a combination of s with the ID of the set post-pended to s. For example, the set with ID = 13 with s = con would have name con13. This keyword cannot be used with the convexhull keyword.

to-set s

Place the resulting polygons in the set with name s. This set is created if it does not exist.

voronoi

Calculate the Voronoi regions of the nodes in the current geometry set.

Note

Voronoi regions with points at infinity are skipped when producing the output.