text:
Method of lines transpose: High order L-stable {\mathcal{O}}(N) schemes for parabolic equations using successive convolution

# Method of lines transpose: High order L-stable O(N) schemes for parabolic equations using successive convolution

Matthew F. Causley Kettering University, Department of Mathematics, 1700 University Ave, Flint, Michigan, 48504, USA (mcausley@kettering.edu)    Hana Cho Michigan State University, Department of Mathematics, 619 Red Cedar Rd., East Lansing, Michigan, 48824, USA (chohana@msu.edu)    Andrew J. Christlieb Michigan State University, Department of Mathematics and Electrical Engineering (andrewch@math.msu.edu)    David C. Seal U.S. Naval Academy, Department of Mathematics, 121 Blake Road, Annapolis, MD 21402, USA (seal@usna.edu)
###### Abstract

We present a new solver for nonlinear parabolic problems that is L-stable and achieves high order accuracy in space and time. The solver is built by first constructing a single-dimensional heat equation solver that uses fast convolution. This fundamental solver has arbitrary order of accuracy in space, and is based on the use of the Green’s function to invert a modified Helmholtz equation. Higher orders of accuracy in time are then constructed through a novel technique known as successive convolution (or resolvent expansions). These resolvent expansions facilitate our proofs of stability and convergence, and permit us to construct schemes that have provable stiff decay. The multi-dimensional solver is built by repeated application of dimensionally split independent fundamental solvers. Finally, we solve nonlinear parabolic problems by using the integrating factor method, where we apply the basic scheme to invert linear terms (that look like a heat equation), and make use of Hermite-Birkhoff interpolants to integrate the remaining nonlinear terms. Our solver is applied to several linear and nonlinear equations including heat, Allen-Cahn, and the Fitzhugh-Nagumo system of equations in one and two dimensions.

Key words. Method of lines transpose, transverse method of lines, Rothe’s method, parabolic PDEs, implicit methods, boundary integral methods, alternating direction implicit methods, ADI schemes, higher order L-stable, multiderivative

## 1 Introduction

The prototypical parabolic differential equation is the heat equation. It forms a cornerstone of mathematics and physics, and its understanding is essential for defining more complicated mathematical models. Fourier introduced this equation as a means to describe transient heat flow. Fick quickly recognized its importance to particle and chemical concentrations. As a result, parabolic equations are now ubiquitous in describing diffusion processes, which are found in a vast array of physical problems, among which are reaction-diffusion models of chemical kinetics [18, 19, 34], phase field models describing morphology and pattern formation in multiphase fluids and solids [4, 3, 12], and even the volatility of stocks and bonds in mathematical finance [42].

Numerical solutions of (linear and nonlinear) diffusion equations have been the subject of active research for many decades. As early as the 1950’s and 60’s, it was recognized that due to the parabolic scaling, method of lines discretizations of the heat equation lead to numerically stiff systems of equations, especially for explicit time stepping. Larger time steps (on the order of the mesh spacing) can be taken with fully implicit solvers, but in practice, full matrix inversions may become difficult and costly, especially when memory is extremely limited, as was especially the case for early computers. Thus, alternate dimensionally implicit (ADI) splitting methods [13, 15, 37, 14, 16, 11], that make use of dimensional splitting and tridiagonal solvers, quickly gained popularity as part of an effort to reduce the amount of memory required to invert these systems.

Later on, memory constraints no longer defined the bottleneck for computing, and attention shifted toward methods that focused on reducing floating point operations (FLOPs), albeit with additional memory constraints. Most notable among these are Krylov methods [28, 22], boundary integral methods [20, 27], and quadrature methods [31, 23, 24, 44, 30]. However, with the advent of GPU processors, it appears that we are yet again seeing a paradigm shift towards methods that should emphasize small memory footprints, even at the expense of incurring a higher operation count. Thus, ADI-like methods, which can efficiently decompose larger problems and limit overhead communication, warrant further investigation, and these features are the motivating factor for this work.

In this paper we propose a novel numerical method for obtaining solutions to the linear heat equation, and nonlinear reaction-diffusion type equations. As an alternative to classical MOL formulations, we use the method of lines transpose (MOL), which is sometimes referred to as Rothe’s method [38], or the transverse method of lines [39]. In this case, the PDE is first discretized in time, and the resulting semi-discrete (modified Helmholtz) problem can be solved using a variety of methods. From potential theory [22, 27], the solution can be constructed by discretizing boundary integrals. However, with dimensional splitting (that is related to the original ADI formulations), the MOL can be used to analytically solve simpler, one-dimensional boundary value problems, and the subsequent solution can be constructed through dimensional sweeps, resulting in an [32, 33] or [6, 7, 5] solver. Furthermore, we extend the method to higher orders of accuracy by using a novel idea referred to as successive convolution. This strategy has recently been developed in [6] for the wave equation by the present authors. In the present work, we not only extend the method of lines transpose to parabolic problems, but we recognize the resulting expansion as a so-called resolvent expansion [1, 21], which we leverage to prove stability and convergence of the successive convolution series. In addition, we incorporate nonlinear terms with an integrating factor method that relies on high order Hermite-Birkhoff interpolants as well as the (linear) resolvent expansions developed in this paper.

The rest of this paper is organized as follows. In Section LABEL:sec:op_calc we derive the basic scheme for the one-dimensional heat equation, which is L-stable and can achieve high orders of accuracy in space and time. In Section LABEL:sec:high-order-resolvent we describe how to obtain an arbitrary order discretization in a single dimension with resolvent expansions. In Section LABEL:sec:multiple, we describe how this can be extended to multiple dimensions, and in Section LABEL:sec:Linear we present results for linear heat in one and two dimensions. In Section LABEL:sec:Source, we describe how our approach can handle nonlinear source terms, and in Section LABEL:sec:Numerical we present numerous numerical results including Allen-Cahn and the Fitzhugh-Nagumo system of equations. Finally, we draw conclusions and point to future work in Section LABEL:sec:conclusions.

## 2 First order scheme in one spatial dimension

We begin by forming a semi-discrete solution to the 1D heat equation using the method of lines transpose (MOL). Let satisfy

 ut =γuxx,(x,t)∈(a,b)×[0,T], \hb@xt@.01(2.1)

with constant diffusion coefficient , and appropriate initial and boundary conditions. The MOL amounts to employing a finite difference scheme for the time derivative, and collocating the Laplacian term at time levels and . Following a similar approach from [6], we introduce a free parameter , so that the collocation has the form111In [6], there are a total of two time derivatives (and two space), so the right hand side depends on , and .

 un+1−unΔt=γ∂xx(un+un+1−unβ2),β>0.

Next, we introduce the differential operator corresponding to the modified Helmholtz equation, defined by

 L=I−∂xxα2,α=β√γΔt. \hb@xt@.01(2.2)

After some algebra, we find that the scheme can be written as

 L[un+1−(1−β2)un]=β2un. \hb@xt@.01(2.3)

We note that there are at least two reasonable strategies for choosing :

1. Maximize the order of accuracy. For example, if we choose , then the discretization is the trapezoidal rule, which is second order accurate and A-stable.

2. Enforce stiff decay. For example, if we choose , then the discretization is the backward Euler scheme, which is first order accurate, L-stable, yet does not maximize the order of accuracy.

Here and below, we opt for the second strategy, as the stiff decay of numerical solutions of the heat equation is of paramount importance. In Section LABEL:subsec:Stability, we develop this discussion in the context of higher order schemes that relies on a careful selection of as well as repeated applications of a single inverse operator.

Upon solving equation (LABEL:eqn:First) for , we find that the equation for the update is

 un+1=(1−β2)un+β2L−1[un], \hb@xt@.01(2.4)

that requires inverting a modified Helmholtz operator. We accomplish this analytically by using Green’s functions, from which

 L−1[u]=(I−∂xxα2)−1[u]:=α2∫bae−α|x−y|u(y)dy+Bae−α(x−a)+Bbe−α(b−x). \hb@xt@.01(2.5)

The coefficients and are determined by applying prescribed boundary conditions at which we describe in Section LABEL:subsec:homogenous-solution.

###### Remark 1

Alternatively, had we followed the method of lines (MOL) and first discretized (LABEL:eqn:heat) in space, then the differential operator would be replaced by an algebraic operator , and would be inverted numerically.

###### Remark 2

Although the update (LABEL:eqn:First_update) (with ) is only first order accurate, we describe in Section LABEL:sec:high-order-resolvent how to extend our procedure to arbitrary order in time.

This MOL approach has several advantages. First, the solution is now explicit, but remains unconditionally stable. Secondly, in recent work [6, 7, 5] we show that the convolution integral in Eqn. (LABEL:eqn:L_inverse) can be discretized using a fast algorithm, where is the number of spatial points. We introduce more details in Section LABEL:subsec:High_Space, wherein we update the current algorithm to achieve a user-defined accuracy of with mesh spacing . Finally, since the solution is still continuous in space, we can decouple the spatial and temporal errors, and by combining resolvent expansions with dimensional splitting, we extend the method to multiple dimensions without recoupling the errors.

###### Remark 3

Since dimensional splitting is used, all spatial quantities are computed according to a one-dimensional convolution integral of the form (LABEL:eqn:L_inverse), which is performed on a line-by-line basis, following so-called "dimensional sweeps". Since the discrete convolution is computed in complexity, the full solver scales linearly in the number of spatial points (assuming each sweep is performed in parallel).

A fully discrete scheme is obtained after a spatial discretization of (LABEL:eqn:L_inverse). The domain is partitioned into subdomains , with . The convolution operator is comprised of a particular solution, which is defined by the convolution integral

 I[u](x):=α2∫bae−α|x−y|u(y)dy \hb@xt@.01(2.6)

and a homogeneous solution

 Bae−α(x−a)+Bbe−α(b−x), \hb@xt@.01(2.7)

both of which can be constructed in operations using fast convolution. We now describe each of these in turn, starting with the first.

### 2.1 Spatial discretization of the particular solution

The particular solution is first split into , where

 IL(x)=α2∫xae−α(x−y)u(y)dy,IR(x)=α2∫bxe−α(y−x)u(y)dy.

Each of these parts independently satisfy the first order "initial value problems"

 (IL)′(y)+αIL(y)=α2u(y) ,a

where the prime denotes spatial differentiation. By symmetry, the scheme for follows from that of , which we describe. From the integrating factor method, the integral satisfies the following identity, known as exponential recursion

 IL(xj)=e−νjIL(xj−1)+JL(xj),whereJL(xj)=α2∫xjxj−1e−α(xj−y)u(y)dy,

and

 νj=αhj,hj=xj−xj−1.

This expression is still exact, and indicates that only the "local" integral needs to be approximated. We therefore consider a projection of onto , the space of polynomials of degree . A local approximation

 u(xj−zhj)≈pj(z),z∈[0,1],

is accurate to , and defines a quadrature of the form

 JL(xj)=νj2∫10e−νjzu(xj−hjz)dz≈νj2∫10e−νjzpj(z)dz. \hb@xt@.01(2.8)

If standard Lagrange interpolation is used, then the polynomials can be factorized as

 pj(z)=r∑k=−ℓpjk(z)uj+k=zTA−1juMj, \hb@xt@.01(2.9)

where , and , and is the Vandermonde matrix corresponding to the points , for . The values of and are such that , and are centered about except near the boundaries, where a one-sided stencil is required.

Substituting this factorization into (LABEL:eqn:JL) and integrating against an exponential, we find that

 JL(xj)≈JLj:=r∑k=−ℓwjkuj+k,

where the weights satisfy

 wTj=ϕTjA−1j \hb@xt@.01(2.10)

and where

 ϕjk=νj2∫10e−νjzzkdz=k!e−νj2νj(eνj−k∑p=0(νj)pp!).

If the weights are pre-computed, then the fast convolution algorithm scales as per time step, and achieves a user-defined in space. In every example shown in this work, we choose or .

### 2.2 Homogeneous solution

The homogeneous solution in (LABEL:eqn:homogeneous_def) is used to enforce boundary conditions. We first observe that all dependence on in the convolution integral, , in (LABEL:eqn:I_def) is on the Green’s function, which is a simple exponential function. Through direct differentiation, we obtain

 Ix(a)=αI(a),Ix(b)=−αI(b). \hb@xt@.01(2.11)

Various boundary conditions at and can be enforced by solving a simple system for the unknowns and . For example, for periodic boundary conditions we assume that (at each discrete time step, )

 un(a)=un(b),unx(a)=unx(b),∀n∈N. \hb@xt@.01(2.12)

We next enforce this assumption to hold on the scheme (LABEL:eqn:L_inverse),

 L−1[un](a)=L−1[un](b) ⟺I(a)+Ba+Bbμ=I(b)+Baμ+Bb, L−1x[un](a)=L−1x[un](b) ⟺α(I(a)−Ba+Bbμ)=α(−I(b)−Baμ+Bb),

where and the identities (LABEL:eqn:derivative_integral) are used to find . Solving this linear system yields

 Ba=I(b)1−μ,Bb=I(a)1−μ. \hb@xt@.01(2.13)

Different boundary conditions (e.g. Neumann) follow an analogous procedure that requires solving a simple linear system for and .

## 3 Higher order schemes from resolvent expansions

In our recent work [6], we apply a successive convolution approach to derive high order A-stable solvers for the wave equation. The key idea is to recognize the fact that, in view of the modified Helmholtz operator (LABEL:eqn:MHL), the second derivative can be factored as

 (−∂xxα2)=L−I=L(I−L−1):=LD, \hb@xt@.01(3.1)

where

 D=I−L−1,L=(I−D)−1. \hb@xt@.01(3.2)

Substitution of the second expression into (LABEL:eqn:Lap_sc) determines the second derivative completely in terms of this new operator

 (−∂xxα2)=(I−D)−1D=∞∑p=0Dp. \hb@xt@.01(3.3)

This shows that second order partial derivatives of a sufficiently smooth function can be approximated by truncating a resolvent expansion based on successively applying to , which is a linear combination of successive convolutions (LABEL:eqn:L_inverse).

Now, we consider a solution to the heat equation (LABEL:eqn:heat), that for simplicity we take to be infinitely smooth. We perform a Taylor expansion on , and then use the Cauchy-Kovalevskaya procedure [9, 40] to exchange temporal and spatial derivatives to yield

 u(x,t+Δt)=∞∑p=0(Δt∂t)pp!u(x,t)=∞∑p=0(γΔt∂xx)pp!u(x,t)=:eγΔt∂xxu(x,t). \hb@xt@.01(3.4)

The term is a spatial pseudo-differential operator, and it compactly expresses the full Taylor series. Our goal is to make use of the formula (LABEL:eqn:Lap_D) to convert the Taylor series into a resolvent expansion. This can be performed term-by-term, and requires rearranging a doubly infinite sum. However, if we instead work directly with the operator defining the Taylor series, then

 eγΔt∂xx=e−β2(−∂xxα2)=e−β2(I−D)−1D.

At first glance this expression looks quite unwieldy. However, fortune is on our side, since the generating function of the generalized Laguerre polynomials is

 ∞∑p=0L(λ)p(z)tp=1(1−t)λ+1e−tz1−t, \hb@xt@.01(3.5)

which bears a striking resemblance to our expansion. Indeed, if we take , substitute and , then

 e−β2(I−D)−1D=∞∑p=0L(−1)p(β2)Dp=I+∞∑p=1L(−1)p(β2)Dp. \hb@xt@.01(3.6)

### 3.1 Convergence

This expansion has been considered in the context of semigroups [1, 21], where is replaced with a general closed operator on a Hilbert space . In our notation, we restate part of Theorem 4.3 in [1], which is proven therein.

###### Theorem 3.1

Let the semigroup

 T(β2) =e−β2(−∂xxα2)=∞∑p=0L(−1)p(β2)(I−∂xxα2)−p(−∂xxα2)p =∞∑p=0L(−1)p(β2)L−p(L−I)p=∞∑p=0L(−1)p(β2)Dp

be approximated by

 TP(β2)=P∑p=0L(−1)p(β2)Dp.

Then, for , there exists for each an integer such that for all integers , with ,

 ∥∥T(β2)u−TP(β2)u∥∥≤C(β2,k)Pk/2−1∥∥∥(−∂xxα2)ku∥∥∥,

where is a constant that depends only on and .

###### Remark 4

The salient point of the theorem is that, in consideration of (c.f. Eqn. (LABEL:eqn:MHL)), the approximation error is of the form , which matches the form given by a typical Taylor method.

Finally, we truncate the resolvent expansion (LABEL:eqn:Laguerre) at order . For the heat equation, this defines the numerical method as

 u(x,t+Δt)=u(x,t)+P∑p=1L(−1)p(β2)Dp[u](x,t), \hb@xt@.01(3.7)

which has a truncation error of the form

 τ:=L(−1)P+1(β2)DP+1[u](x,t)+O(ΔtP+2). \hb@xt@.01(3.8)

For , these schemes (evaluated at ) are

 un+1 =un−β2D[un], \hb@xt@.01(3.9) un+1 =un−β2D[un]−(β2−β42)D2[un], \hb@xt@.01(3.10) un+1 =un−β2D[un]−(β2−β42)D2[un]−(β2−β4+β66)D3[un]. \hb@xt@.01(3.11)

We note that for implementation, each operator is applied successively, and is defined by

 D(p+1)[u]:=D[Dp[u]],D0[u]:=u.

### 3.2 Stability

There remains one critical issue: the choice of the free parameter . In 1974, Nørsett studied a similar single-step multiderivative method for the heat equation [35] and he too, had a free parameter in his solver. We follow his lead on the Von-Neumann analysis based on his MOL discretization, but in this work we optimize to obtain stiff decay, whereas Nørsett chose to maximize the order of accuracy of the solver.

Consider the linear test problem

 dydt=λy,y(0)=1,λ∈C,

whose exact solution satisfies

 y(t+h)=ezy(t),z=hλ∈C.

Application of (LABEL:eqn:Scheme_D) to this test problem results in

 y(t+h)=P∑p=0L(−1)p(β2)^Dpy(t)=ϕ(z)y(t)

where

 ^D=−(z/β2)1−(z/β2)=1−(1−(z/β2))−1.

The generalized Laguerre polynomials satisfy many identities, the following of which is the most pertinent:

 L(0)p+1(x)−L(0)p(x)=L(−1)p+1(x)=(xp+1)ddxL(0)p+1(x). \hb@xt@.01(3.12)

Here, is the standard Laguerre polynomial . Following standard definitions, we say that a numerical scheme is -stable, provided in the left-half of the complex plane . Likewise, a scheme exhibits stiff decay if as . If an -stable method also exhibits stiff decay, it is -stable.

Now, observing that as , we find that

 limz→−∞ϕ(z)=P∑p=0L(−1)p(β2)=L00(β2)+P∑p=1(L0p(β2)−L0p−1(β2))=L0P(β2), \hb@xt@.01(3.13)

where we have used the first two expressions in (LABEL:eqn:Laguerre_Identity) to introduce a telescoping sum. We are now prepared to prove the following.

###### Theorem 3.2

Let be an approximate solution to the heat equation (LABEL:eqn:heat), given by the successive convolution scheme (LABEL:eqn:Scheme_D). Then,

1. If is chosen as the smallest root of , then the scheme achieves order , but does not exhibit stiff decay.

2. If is chosen as the smallest root of , then the scheme achieves order , and exhibits stiff decay.

3. Following the first strategy, the schemes are -stable for , whereas the second strategy ensures -stability. For both strategies, -stability is achieved for , with large values of .

Proof. The proof follows by applying the maximum modulus principle coupled with (LABEL:eqn:limit). For part 1, upon examining the truncation error (LABEL:eqn:Trunc), we see that an additional order of accuracy can be gained if we choose

 L(−1)P+1(β2)=(β2P+1)L′P+1(β2)=0.

However, for this choice, and so stiff decay does not hold. For part 2, we instead enforce stiff decay, but then the truncation error is of order . Finally, part 3 is demonstrated by the maximum amplification factors along the imaginary axis, as shown for both strategies in Figure LABEL:fig:Stab. In particular, we observe that for .

###### Remark 5

In [35], the scheme was chosen to maximize the order of accuracy, implicitly leading to eliminating the first term in the truncation error (LABEL:eqn:Trunc), which is equivalent to the first strategy. However, in this work we follow the second strategy, and choose as the smallest root of to ensure stiff decay.

For comparison we record the values of chosen for each order , to those of Nørsett in Table LABEL:tab:LagZeros. For all of our solvers, we choose to be the largest possible value that still yields provable stiff decay.

## 4 Resolvent expansions for multiple spatial dimensions

We extend the 1D solver to multiple spatial dimensions through the use of dimensional splitting. Our key observation is that we can use the factorization property of the exponential to perform the series expansion. For instance, in three dimensions, we have

 eγΔt∇2=e−β2(−∂xxα2)e−β2(−∂yyα2)e−β2(−∂zzα2). \hb@xt@.01(4.1)

Now, we first replace each term with the identity (LABEL:eqn:Laguerre) dimension by dimension, and then truncate the expansions which will be in terms of the univariate operators and for as defined by (LABEL:eqn:MHL), and (LABEL:eqn:Scheme_D) acting on a function . This infinite sum with three indices must then be truncated to order , and after a change of indices we find

 EP=∑p,q,r(P−1p,q,r)L(−1)p(β2)L(−1)q(β2)L(−1)r(β2)DpxDqyDrz, \hb@xt@.01(4.2)

in 3D, with the corresponding 2D operator given by

 EP=∑p,q(P−1p,q)L(−1)p(β2)L(−1)q(β2)DpxDqy. \hb@xt@.01(4.3)

Here we adopt the notation that sums are taken over all non-negative indices that sum to , and the multinomial coefficients are defined such that and .

###### Remark 6

The proof of stability for the multi-dimensional algorithm follows directly from that of the one-dimensional case, with the same approach applied to each spatial dimension (i.e. for the 2D case, and similarly for the 3D case).

## 5 The heat equation

### 5.1 Heat equation in 1D

We first illustrate the accuracy of our method for the 1D heat equation defined in (LABEL:eqn:heat). We consider initial conditions , for with periodic boundary conditions. We integrate up to a final time of , and set . We use the fast convolution algorithm that is fourth order accurate in space (), and set the spatial grid size to be . This ensures that the dominant error in the solution is temporal. We compute errors by the -norm, and compare against the exact solution at . The result of a temporal refinement study for and is presented in Table LABEL:tab:refinement_1D_1.

### 5.2 Heat equation in 2D

As a second example, we present results for the 2D heat equation. We consider initial conditions , for with periodic boundary conditions. We use a uniform mesh of size . Likewise, the -error is computed by comparing against the exact solution at the final time . In Table LABEL:tab:refinement_2D_1, we present results for a temporal refinement study for orders and .

## 6 Reaction-diffusion systems

We next extend our method to nonlinear reaction-diffusion systems of the form

 ut=D∇2u+F(u),(x,t)∈Ω×(0,T], \hb@xt@.01(6.1)

where , with , is a diffusion coefficient matrix, and the reaction term is a function of , . In the above, is a bounded domain, and we assume appropriate initial values and boundary conditions. We shall view the diffusion as being the linear part of the differential operator, and invert this linear part analytically, using successive convolution. To derive the scheme, we use operator calculus to first write

 (∂t−D∇2)u=F⟹(e−Dt∇2u)t=e−Dt∇2F, \hb@xt@.01(6.2)

where is a pseudo-differential operator. Upon integrating (LABEL:eqn:operator_calculus) over the interval , we arrive at the update equation

 u(t+Δt)−eDΔt∇2u(t)= ∫t+ΔtteD(t+Δt−τ)∇2F(τ)dτ = ∫Δt0eD(Δt−τ)∇2F(t+τ)dτ, \hb@xt@.01(6.3)

where we have made use of the abbreviated notation, . On the left hand side, the diffusion terms have been collected by this pseudo-differential operator, and will be approximated using the successive convolution techniques developed above. The reaction terms on the right hand side (LABEL:eqn:first) are fully nonlinear, and we must consider nonlinear stability when choosing a method of discretization.

We first consider approximating the integral on the right hand side (LABEL:eqn:first) with the trapezoidal rule. This defines a single-step update equation, which will be second order accurate

 u(t+Δt)−eDΔt∇2u(t)=Δt2[eDΔt∇2F(t)+F(t+Δt)]. \hb@xt@.01(6.4)

We may also obtain a single-step third order scheme, using multiderivative integration [40]. By replacing the integrand (LABEL:eqn:first) with a third order Hermite-Birkhoff interpolant and performing exact integration of the resulting function, we arrive at

 u(t+Δt)−eDΔt∇2u(t)=eDΔt∇2[2Δt3F(t)+Δt6(−DΔt∇2F(t)+ΔtdFdt(t))]+Δt3F(t+Δt), \hb@xt@.01(6.5)

where . The Hermite-Birkhoff interpolant that matches the integrand in (LABEL:eqn:first) at times , and , as well as its derivative at time produces the quadrature rule in (LABEL:eqn:3rd_scheme).

###### Remark 7

The proposed schemes in (LABEL:eqn:2nd_scheme) and (LABEL:eqn:3rd_scheme) produce nonlinear equations for that need to be solved at each time step. Therefore, any implicit solver will necessarily be problem dependent.

For the problems examined in this work, we make use of simple fixed-point iterative schemes. We stabilize our iterative solvers by linearizing about a background state , which depends on the problem under consideration.

### 6.1 A discretization of the Laplacian operator

Upon perusing the third order update equation (LABEL:eqn:3rd_scheme), we will need to use successive convolution to replace the psuedo-differential operator , as well as the Laplacian operator . This latter point has been detailed in [6], and so we comment briefly on it here. Using the one-dimensional expansion (LABEL:eqn:Lap_D), we observe that the two-dimensional Laplacian is similarly given by

 −∇2α2=−∂xxα2−∂yyα2=∞∑p=1(Dpx+Dpy),

and can be truncated at the appropriate accuracy . Here, the subscripts indicate that the convolution is only in one spatial direction, and the other variable is held fixed. Thus, is applied along horizontal lines for fixed -values, and likewise for .

## 7 Nonlinear numerical results

### 7.1 Allen-Cahn

We examine in greater detail the application of our schem to the Allen-Cahn (AC) equation [2],

 ut=ϵ2∇2u+f(u),(x,t)∈Ω×(0,T], \hb@xt@.01(7.1)

where the reaction term is , and is a bounded domain, and satisfies homogeneous Neumann boundary conditions.

For our fixed point iteration, we linearize about the stable fixed points , which satisfy . For example, the second order scheme from (LABEL:eqn:2nd_scheme) becomes

 (1+Δt)un+1,k+1=eϵ2Δt∇2(un+Δt2fn)+Δt2(fn+1,k+2un+1,k), \hb@xt@.01(7.2)

where indicates the time step as before, and now is the iteration index. By lagging the nonlinear term , the fixed point update is made explicit. Likewise, the third order scheme from (LABEL:eqn:3rd_scheme) becomes

 (1+2Δt3)un+1,k+1=eϵ2Δt∇2[un+2Δt3fn+Δt6(−ϵ2Δt∇2fn+Δtfnt)]+Δt3(fn+1,k+2un+1,k). \hb@xt@.01(7.3)

Here, is again understood by replacing it with a resolvent expansion, which is a truncated series of successive convolution operators.

### 7.2 Allen-Cahn: One-dimensional test

We demonstrate the accuracy of our proposed schemes by simulating a well-known traveling wave solution [8, 29],

 uAC(x,t)=12(1−tanh(x−Ts−st2√2ϵ)),x∈Ω=[0,4],0≤t≤T. \hb@xt@.01(7.4)

Here, is the speed of the traveling wave, and we choose . Additionally, we choose the delay time , so that the exact solution satisfies .

Results for a final time of are shown in Figure LABEL:fig:AC_1d, with two different time steps. The solutions agree well with the exact solution.

In Table LABEL:tab:refinement_AC, we present the -error in the numerical solution at a final time , using the exact solution (LABEL:AC_initial). We observe first order accuracy from the Backward Euler method, and the expected orders of accuracy from the second (LABEL:eqn:AC_2ndorder_iteration) and third (LABEL:eqn:AC_3rdorder_iteration) order schemes. To ensure that the temporal error is dominant, we have used the fourth order accurate scheme (eq. (LABEL:eqn:JL) with ), with to perform spatial integration in the successive convolutions.

In principle, we can achieve higher orders accuracy in space and time. The latter would require using higher order Hermite-Birkhoff interpolation to discretize the reaction term in (LABEL:eqn:first).

### 7.3 Allen-Cahn: Two-dimensional test

We next solve the Allen-Cahn equation in two spatial dimensions. A standard benchmark problem involves the motion of a circular interface [8, 29, 41], to which an exact solution is known in the limiting case . The radially symmetric initial conditions are defined by

 u(x,y,0)=tanh(0.25−√(x−0.5)2+(y−0.5)2√2ϵ), \hb@xt@.01(7.5)

which has an interfacial circle () centered at , with a radius of . This interfacial circle is unstable, and will shrink over time, as determined by the mean curvature [2]

 V=dRdt=−1R. \hb@xt@.01(7.6)

Here is the velocity of the moving interface, and is the radius of the interfacial circle at time (i.e., it is the radius of the curve defined by ). By integrating (LABEL:eqn:meancurvature) with respect to time, we solve for the radius as a function of time

 R(t)=√R20−2ϵ2t. \hb@xt@.01(7.7)

The location where is placed in equation (LABEL:eqn:AC) differs from other references [8, 29, 41]. Therefore, we point out that our time scales have been appropriately rescaled for comparison.

The moving interface problem was simulated using , , and , which are based on the parameters used in [29]. The numerical solution is displayed in Figure LABEL:fig:AC_2d, and we observe that the interfacial circle shrinks, as is expected.

In Figure LABEL:fig:AC_2d2, we plot compare the evolution of the radii obtained by our second order scheme with the exact radius (LABEL:eqn:velocity), for two different values of the diffusion parameter . The radius is measured by taking a slice of the solution along , and then solving for the spatial point where using linear interpolation between the two closest points that satisfy and . Refinement is performed with a fixed spatial mesh , and time steps of , and . Because the radius is derived as an exact solution in the limit (i.e., ) [2], we observe that the smaller value of is indeed more accurate.


text:
# Where does the constant of Planck $6.6\times10^{−34}$ J ⋅ s come from?

I've read that this number is made out of the mass or mass equivalent of any atomic particle equal to ($9.10939 \times 10^{-31}$ kg or electron mass) x ($2.42631 \times 10^{-12}$ m or electron Compton wavelength) / (Particle wavelength).

But where are those numbers coming from? Can someone explain where the constant exactly stands for?

• I'm not sure I understand "where are those numbers coming from" - where does Newton's gravitational constant, or the Avagadro constant "come from", for instance? Nov 27 '16 at 16:17
• @ACuriousMind Good questions too. If I want to know the energy of a photon I have to multiply the frequency with h. But why has h this value? It looks that for the mass the electron is taken and I don't know where this waselength come form. But why these parameters and not something else. Nov 27 '16 at 16:42
• Possible duplicate: physics.stackexchange.com/q/144262/50583 Nov 27 '16 at 16:43

Your title mentions Planck's constant. Planck introduced his constant when he posited that $$E=hf$$ That is, that energy is proportional to frequency. The constant of proportionality, Planck's constant, is required to convert between our unit for frequency and our unit for energy.
The numerical value reflects our man-made systems of units, and not any fundamental property of nature. In fact, a convenient system of units sets $h=1$, thus using identical units for energy and frequency.
You also ask about the Planck mass and Planck length. They are quantities of unit mass and length constructed from the fundamental constants $h$, $c$ and $G$. Their numerical values reflect man-made systems of units, and in convenient systems, they may be set to one.

format: plain


text:
## 2012-11-04

### What is the best display aspect ratio for tablets?

One marked difference between current tablets is the aspect ratio of their displays. This blog post explores the pros and cons of the different aspect ratios, along with the question whether one of them is best overall.

### The aspect ratios of current tablet displays

 Device Size Normalized aspect ratio Apple iPad mini 768px × 1024px 96 × 128 Apple iPad 1536px × 2048px 96 × 128 Google Nexus 7 800px × 1280px 87.636 × 140.217 Google Nexus 10 1600px × 2560px 87.636 × 140.217 Microsoft Surface 768px × 1366px 83.118 × 147.838 TV 3:4 96 × 128 DVD 9:16 83.138 × 147.802 Anamorphic(movie theaters) 1:2.39 71.704 × 171.372 Letter 8.5in × 11in 97.444 × 126.104 A4 210mm × 297mm 93.212 × 131.828

The last column shows the aspect ratio normalized to an area of 12288 (96 times 128). That is, all areas in that columns are the same, only the sides of the rectangles are different. The formula for the factor n with which the sides have to be multiplied is:

$n=12288width·height$

The rectangles look as follows.

 Tablet display aspect ratios

 Film aspect ratios

 Paper aspect ratios

### Is there a perfect aspect ratio?

Current tablets are optimized for different applications:

• Among the tablets covered here, the iPad works best in portrait orientation. Its display has the “widest” aspect ratio of all tablets. That aspect ratio is the same as those of XGA displays and TVs. It is also close to Letter paper. Note that the Kindle Paperwhite that is clearly optimized for being used in portrait orientation, has the same display aspect ratio as the iPad (768 × 1024 pixels). Alas, the iPad works less well for movies where black bars mean that you lose quite a bit of display space.
• The Surface works best for watching movies. Its resolution (between 1365$\frac{1}{3}$ × 768 and 1366 × 768.375) is almost 16:9, the aspect ratio of DVDs and many notebook screens.
• The Nexus is situated between the extremes iPad and Surface. It is less elongated than 16:9.
Is there such a thing as a perfect display aspect ratio for tablets? No, because the closer you get to optimal for movies, the less suited you are for being used in portrait mode. There is, however, a good compromise: notice that A4 paper is between the iPad and the Nexus when it comes to elongation. It is used widely internationally and works well in portrait mode. A4 has the interesting property that the aspect ratio remains the same if you split it in half. This property is called the Lichtenberg ratio. While A4’s aspect ratio is not as good as the Nexus’ (let alone the Surface) for displaying movies, it is still better than the iPad’s.


text:
# Tufte running headers not using full width of page

I use Minion Pro and XeLaTeX together with the tufte class. There is an issue with caps in headers (as can be noticed if removing the two line marked %% headings fixes below). My fix is to use the myheadings option – but I get a strange effect where the running headers only use up the main text block width and not the full width (the main block + sidenotes).

\documentclass[nols]{tufte-handout}
\usepackage{fontspec}
\setmainfont{Minion Pro}

\author{Author}

\begin{document}

\maketitle

\section{First section}

First section body.

\newpage

Second page.

\newpage

Notice how the headings only uses the main text block width and not the full width of the page.

\end{document}

What could be a solution?

-

Tufte uses fancyhdr for headings, and your work-around is clobbering it. If you want to redefine the header manually, use the fancyhdr way of doing it (using \fancyhead).

But there is a better way anyway.

The root cause of your difficulty is that when loaded with XeLaTeX, the tufte class does not know how to construct its \smallcaps and \allcaps macros, which produce spaced small and large capitals. It's \smallcaps that is used in the heading, which is what produces your problem.

I think the better way to achieve what you want is to get those working, using fontspec. The following seems to work

\renewcommand\smallcapsspacing[1]{{\addfontfeature{LetterSpace = 8}\scshape#1}}

You can then dispense with your workaround. The side-effect is that (as the class wants, and as is good practice) your capitals and small caps are spaced, and \allcaps and \smallcaps will work as they should. If you find the space too great, reduce the LetterSpace number somewhat. I aimed for numbers that I thought roughly matched the tufte figures.
That's great. Since I had a very long title I then used the optional short title for \title : \title[Short title]{Long … … title}– it works as I intended. –  trmdttr May 16 '13 at 12:28


text:
## PHP programming

Posted on

PHP was a great programming language in web development. It surpasses the VBscript for ASP and Perl for CGI. It is favoured because of the syntax based C and C++. It supports procedural programming paradigm and object-oriented paradigm. A lot of functions resemble C functions such as printf, fprintf, sprintf, fopen, etc. Similarly, it can work directly to the C library such as expat, zlib, libxml2, etc. A lot of great content management systems (CMS) are written in PHP, such as Drupal, WordPress, Joomla, etc.

However, a lot of new programming language emerges and surpassing it.

Taken from http://skillprogramming.com/top-rated/php-best-practices-1234

## Array is passed by value

Because PHP syntax is very similar to C and C++, it can use “&” reference operator and pass the parameter by reference in a function. But this will be very different from other languages such Python and JavaScript. Python and JavaScript function parameters are passed by value for all primitive data types, such as integer, float, string, and boolean; complex data type like object and array are passed by reference, meaning they are mutable, including Date object in JavaScript.

function change_array($arr) {$arr[0] = 100;
}

function change_object($obj) {$obj->value = 100;
}

function change_many_objects($arr) {$arr[0]->value = 100;
}

function change_object_array($obj) {$obj->array[0] = 100;
}

class MyObj {
var $value; var$array;
}

function main() {
$arr = [1, 2, 3];$obj = new MyObj();
$obj->value = 10; change_array($arr);
change_object($obj); echo$arr[0], "\n"; // still 1, not changing
echo $obj->value, "\n"; // changed to 100$arr_obj = [ new MyObj(), new MyObj(), new MyObj() ];
$arr_obj[0]->value = 10; change_many_objects($arr_obj);
echo $arr_obj[0]->value, "\n"; // changed to 100$obj_arr = new MyObj();
$obj_arr->array = [1, 2, 3]; change_object_array($obj_arr);
echo $obj_arr->array[0], "\n"; // changed to 100$obj_a = new MyObj();
$obj_a->value = 10;$obj_b = $obj_a;$obj_b->value = 20;
echo $obj_a->value, "\n"; // 20 echo$obj_b->value, "\n"; // 20

$obj_c = &$obj_a;
$obj_c->value = 30; echo$obj_a->value, "\n"; // 30
echo $obj_b->value, "\n"; // 30 echo$obj_c->value, "\n"; // 30
}

main();

In the example above, the function change_array() will not modify the array that being passed, this is because it is passed by value. Unless we use the “&” reference operator.

The function change_object() will change the object that being passed.

One of the key-points of PHP 5 OOP that is often mentioned is that “objects are passed by references by default”. This is not completely true. […]

(from PHP manual)

So, basically, the function parameters are passed by value, even though it is an array. But the object will be dealt differently. We can treat it as a pointer, if you are familiar with C++ “new” operator. In C++, “new” operator will create an instance and return a pointer to the instance. If we understand this concept, then this is how it works in PHP (according to what I know).

Consequently, the function change_many_objects() though the argument is for an array, and an array is passed into it, but the function changes the value of the object within the array. This is because the array stores the pointer to the object instances. The function does change the instance is pointed by the “pointers” stored in the array.

In summary, PHP deals array as value, which is different from Python, JavaScript, and even C and C++. However, PHP deals object as pointer, that is why object is mutable when it is passed to a function.

## Other limitations

PHP was created before the technology of RESTful API. PHP focuses on the GET and POST, but not like PUT and DELETE. The HTTP methods are server dependent. As a result, the HTTP server such as Apache requires some extra configurations for PHP to work. Unlike Node and Ruby on Rails, Node itself has a HTTP module; Ruby on Rails has WEBrick HTTP server.

Comparing to the language like Python, Node with JavaScript, Ruby, Lua, it lacks of REPL (read-eval-print loop). Interactive shell is different from REPL. With REPL, the function to print the result in the console is omitted. REPL will print the result whenever the function returns value.

## Closure

Posted on

In JavaScript, we can create closure like this,

var foo = (() => {
let x = 0;
return () => {
return x++;
}
})();

for (var i = 0; i < 10; i++) {
var x = foo();
console.log(x);
}

But translating above code into C++, it cannot work as expected for the variable, unless the variable is outside the lambda function.

// In a function
int x; // variable here
auto foo = [&x]() {
x = 0;
return [&x]() {
return x++;
};
}();
for (int i = 0; i < 10; i++) {
int x = foo();
cout << x << endl;
}

This is because C++ variable can be only accessed in the function scope. After the function return the value, the variable is not accessible anymore.

Similarly, Python can also return the function, but it cannot work as closure like JavaScript. However, Python can create non-primitive variable such as object or list so that the variable will be accessed by reference.

def _foo():
x = [0]
def increment():
x[0] += 1
return x[0]
return increment

foo = _foo()
for i in range(10):
x = foo()
print(x)

## Prayer Clock GTK3

Posted on

My first open source project, Prayer Clock, I moved from SourceForge to GitHub recently. Yeah! Everyone should git!!!

And today I just made some changes, and updated to GTK3.

With GTK 3, I removed the title bar. But not yet successfully moving the menu bar to the icon like Evince or Nautilus.

I plan to convert the right hand panel to WebKitGtk. But this will not be the priority yet.

## CSV to something

Posted on

Just revived my old script into a project in GitHub, csv_to_something. An old simple script that was created to manage some student data. Because the students data were collected through Google Forms, so I convert it to CSV, then from CSV to SQLite. So that I can use the SQL to query whatever data I need.

Using SQLite software such as sqliteman and sqlitebrowser, I can create any new table, grouping, sorting etc.

Then recently, I need some JSON data for the table. So, I revive the script to convert CSV to JSON format. With the functional programming characteristic in JavaScript, manipulating the data becomes more interesting. Using Node or any JavaScript interpreter, we can perform map and reduce. Other useful functions like find and filter can get what I want. Example,

// Read the JSON data as object
let students;
if (err) throw err;
students = JSON.parse(content);
});
let average = students.reduce((reduced, item) => item.score, 0) / data.length;
let grades = students.map(student => {
if (student.score >= 90) return 'A';
else if (student.score < 90 && student.score >= 70) return 'B';
else return 'Something else';
});

Why SQLite and JSON? Because they are extremely lightweight.

## Monty Hall problem and frog riddle

Posted on

Probability topic is the fundamental concept of the statistics. And machine learning is closely related to statistics. That is why, understand the probability very important if you are doing research, statistics, and machine learning.

Monty Hall is a very interesting problem. It says, if you are given 3 doors to choose. One of them contains a car (which you want), the other two are goats (which you don’t want). After you made your choice, before opening the door, the host will open the door that you didn’t choose yet contains the goat (he knows which door has the goat). Now, if you are given an opportunity to change your choice to another door (which you didn’t choose earlier), are you going to change?

In the first glance, you will feel that whatever you choose, the probability is always 1/3. However, the conditional probability tells you that, if you always make the switch after the host opened the door that has a goat, your probability to win the car will increase to 2/3. What??

In order to prove this, I wrote a Python script.

#!/usr/bin/env python
# This is simulating Monty Hall Paradox

import random

def monty(switch):
# random shuffle
doors = [0, 0, 1]  # one of the door contains the car
random.shuffle(doors)

openDoor = None

# choose the first door (not open)
# if the first door is 1, randomly open the other
if doors[0] == 1:
# open the door
openDoor = random.randint(1, 2)
else:  # open the door that contains goat
if doors[1] == 1:
openDoor = 2
else:
openDoor = 1

# now open the last door
if not switch:
return doors[0]
else:
if openDoor == 2:
return doors[1]
else:
return doors[2]

def main():
total = 10000
car = 0
for i in range(total):
car += monty(True)

print("Always switch the door. Total: {}, car: {}. P = {}".format(total, car, car / total))

car = 0
for i in range(total):
car += monty(False)

print("No switch the door. Total: {}, car: {}. P = {}".format(total, car, car / total))

main()

Run the code, you will always get the probabilty close to 0.6667 if you always switch the door.

Always switch the door. Total: 10000, car: 6625. P = 0.6625
No switch the door. Total: 10000, car: 3309. P = 0.3309

### Frog riddle

It also mentions about the conditional probability. Interestingly, quite a lot of comments mentioned that the author is wrong.

In order to prove that the author is correct, I wrote another Python script.

#!/usr/bin/env python

import random

# Frog 0 for female, 1 for male

def create_frog():
return random.randint(0, 1)

def has_croak(pairs):  # also male
return 1 in pairs

def has_female(frogs):
return 0 in frogs

def choose_without_croak(choose_two):
frogs = [create_frog() for i in range(3)]
# first frog at the right side
# second and third at the left side

if choose_two:
return has_female(frogs[1:])  # choose two frogs

return has_female(frogs[0:1])

def main():
total = 10000
correct = 0
for i in range(total):
correct += choose_without_croak(True)
print('Just choose two frogs. Total: {}, correct: {}. P = {}'.format(total, correct, correct / total))

correct = 0
for i in range(total):
correct += choose_without_croak(False)
print('Just choose one frog. Total: {}, correct: {}. P = {}'.format(total, correct, correct / total))

# The exact question is,
# "What is the probability of the frogs in the pair has female,
# given that one of them is male?"
def exact_calculation():
total = 10000
croak = 0
correct = 0
for i in range(total):
frogs = [create_frog() for i in range(3)]
if has_croak(frogs[1:]):
croak += 1
if has_female(frogs[1:]):
correct += 1
print('Total croak: {}, correct: {}. P = {}'.format(croak, correct, correct / croak))

main()
exact_calculation()

Running the script, you will get

Just choose two frogs. Total: 10000, correct: 7498. P = 0.7498
Just choose one frog. Total: 10000, correct: 4974. P = 0.4974
Total croak: 7474, correct: 4998. P = 0.6687182231736687

Based on the result, if you choose two frogs, the probability of survive is close to 0.75. If you choose one frog, the probability is 0.5.

Now, the tricky part is the probability 0.67 mentioned in the video. The question should be “What is the probability of the frogs in the pair has female, given that one of them is male?”

So, based on the question, my similuation needs to get the total count of the male (that has croak), and within these pairs, count the female frogs.

To convert this into mathematical expression,

$P(\text{female frog}) = 0.5$

$P(\text{at least one male frog}) = 0.75$

$P(\text{female frog} | \text{at least one male frog}) = \frac{0.5}{0.75} = 0.6667$

Then, based on the simulation and calculation, you will get the 0.6667.

## Switching display/monitor/screen in Linux

Posted on

Because I am using the Openbox (window manager), and I believe that the laptop Fn+F8 (or whatever combination with Fn) doesn’t work properly on Linux. Because the combination is detected as Super+p (aka Win+p). As a result, I wrote a Perl script to solve the switching display/monitor/screen issue on my laptop.

#!/usr/bin/perl

# This script requires xrandr, and several bash script created by arandr

use strict;
use warnings;

# Edit these global variables based on your setting
my $primary = 'eDP1'; my$secondary = 'HDMI1';

my %scripts = (default => 'default.sh',
external_only => 'large_only.sh',
clone => 'clone.sh',
dual => 'dual.sh');
my $script_path = '~/.screenlayout'; # End edit sub get_xrandr { return xrandr; } sub is_active { my ($monitor) = @_;
for my $i (0 .. (scalar @$monitor - 1)) {
my $line =$monitor->[$i]; if ($line =~ /\*/) {
return 1;
}
}
return 0;
}

sub is_left {
my ($monitor) = @_; my$line = $monitor->[0]; if ($line =~ /\d+x\d+\+(\d+)\+\d+/) {
if ($1 > 0) { return 0; } } return 1; } sub is_default { my ($primary, $secondary) = @_; return &is_active($primary) && !&is_active($secondary); } sub is_external_only { my ($primary, $secondary) = @_; return !&is_active($primary) && &is_active($secondary); } sub is_clone { my ($primary, $secondary) = @_; return &is_active($primary) && &is_active($secondary) && &is_left($primary) && &is_left($secondary);; } sub is_dual { my ($primary, $secondary) = @_; return &is_active($primary) && &is_active($secondary) && &is_left($primary) && !&is_left($secondary);; } sub get_monitor_style { my ($primary, $secondary) = &get_monitor_details; if (&is_default($primary, $secondary)) { return 'default'; } elsif (&is_clone($primary, $secondary)) { return 'clone'; } elsif (&is_dual($primary, $secondary)) { return 'dual'; } elsif (&is_external_only($primary, $secondary)) { return 'external_only'; } return 'unknown'; } sub set_monitor_style { my ($style) = @_;
my $script = join('/',$script_path, $scripts{$style});
my $cmd = "sh$script";
$cmd; } sub switch_next_monitor_style { my$current_style = &get_monitor_style;
if ($current_style eq 'default') { &set_monitor_style('external_only'); } elsif ($current_style eq 'external_only') {
&set_monitor_style('dual');
}
elsif ($current_style eq 'dual') { &set_monitor_style('clone'); } elsif ($current_style eq 'clone') {
&set_monitor_style('default');
}
else {
print STDERR "Unknown monitor style";
}
}

sub switch_prev_monitor_style {
my $current_style = &get_monitor_style; if ($current_style eq 'default') {
&set_monitor_style('clone');
}
elsif ($current_style eq 'external_only') { &set_monitor_style('default'); } elsif ($current_style eq 'dual') {
&set_monitor_style('external_only');
}
elsif ($current_style eq 'clone') { &set_monitor_style('dual'); } else { print STDERR "Unknown monitor style"; } } sub switch_monitor_style { my ($prev) = @_;
if ($prev) { &switch_prev_monitor_style; } else { &switch_next_monitor_style; } } sub get_monitor_details { my$xrandr = &get_xrandr;
my @lines = split(/\n/, $xrandr); my @primary_lines; my @secondary_lines; my$current_block;
for my $i (0 ..$#lines) {
my $line =$lines[$i]; if ($i == 0) {
next;  # not "continue"
}
if ($line =~ /^${primary}/) {
$current_block = 'primary'; } elsif ($line =~ /^${secondary}/) {$current_block = 'secondary';
}
if ($current_block eq 'primary') { push @primary_lines,$line;
}
elsif ($current_block eq 'secondary') { push @secondary_lines,$line;
}
}
return (\@primary_lines, \@secondary_lines);
}

sub main {
my ($prev) = @_; &switch_monitor_style($prev);
}

&main(@ARGV);

The script requires “xrandr” command. Furthermore, you need to have some actual switching monitor bash script, which can be created by using ARandR. Example of the script

#!/bin/sh
xrandr --output HDMI1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output VIRTUAL1 --off --output eDP1 --off

So, my Perl script will detect existing screen setup, whether it is laptop only (“default”), external only (“external_only”), laptop with external monitor at the right side (“dual”), or clone (“clone”) for both monitor sharing same screen. Therefore, we need to create four bash scripts using ARandR for these settings.

To invoke the script,

perl /path/to/monitor_switch.pl

This will switch to the screen to the “next” setting, in this order: default -> external_only -> dual -> clone -> default.

In order to switch between default and external_only, I extended the script with an argument.

perl /path/to/monitor_switch.pl prev

When passing with an argument (any argument), the monitor setup will switch in the reverse order: default -> clone -> dual -> external_only -> default. By this, we can switch between default and external_only easily.

Next, just apply the keybinding (aka hotkey or shortcut) to your preferred combination, then you can switch the screen with your favourite key combination.

Yeay!

P/S: The reason I wrote this script is, when I show my screen on external only, and the power is cut, the screen doesn’t switch to laptop automatically. That means, I cannot see anything to change my screen display. Before the script is written, I blindly use the Terminal, Ctrl+R, and type the keyword and press Enter to switch back. But this is extreemly impractical.

## ROC, AUC, WTF?

Posted on

These few days I was spending my whole time to understand this ROC (receiver operating characteristic) curve. In machine learning, ROC is a very common way to evaluate the prediction performance. The AUC (area under curve) of ROC indicates the accuracy of prediction of a classifier.


text:
• Home
• /
• Blog
• /
• Terminating and Non-Terminating Decimals(Meaning, Conversions & Examples)

# Terminating and Non-Terminating Decimals(Meaning, Conversions & Examples)

August 15, 2022

This post is also available in: हिन्दी (Hindi)

Decimal numbers are one of the ways to represent both whole numbers and fractions. Decimal numbers consist of two parts – the whole part and the decimal (fractional) part separated by a decimal point ‘$.$’.

The decimals are categorized into two broad categories depending on whether it has a finite number of decimal places or an infinite number of decimal places.

The decimals with a finite number of decimal places are called terminating decimals and the ones with an infinite number of decimal places are called non-terminating decimals.

The non-terminating decimals are further divided into two types – recurring decimals or non-recurring decimals depending on whether the digits after the decimal point repeat in a fixed pattern or not.

## What is a Terminating Decimal?

Terminating decimals are the numbers that have a fixed or a finite number of digits after the decimal point. Decimals are used to express the whole number and fraction together that are separated from each other by inserting a “$.$” i.e. a decimal point. For example, $3.6$, $3$ is the whole number and $6$ is the decimal fraction.

The numbers that are terminating decimal numbers are rational numbers and hence can be expressed in the form $\frac {p}{q}$, where both $p$ and $q$ are integers and $q \ne 0$. For example, the number $3.6$ can be written as $\frac {18}{5}$ which is an improper fraction where both $18$ and $5$ are integers, and obviously, $5 \ne 0$. The fraction $\frac {18}{5}$ can also be written in the form $3 \frac {3}{5}$ which is a mixed fraction

Note: The terminating decimals are rational numbers and can be written in the form $\frac {p}{q}$ which be either of the following two types.

• proper fractions
• improper fractions which can be expressed as mixed numbers or mixed fractions

Note: All natural numbers, whole numbers, and integers are terminating decimal numbers.  For example, the numbers $34$, $97$ or $-56$ can also be written as $34.0$, $97.0$ or $-56.0$.

Maths can be really interesting for kids

## What is Non Terminating Decimal?

Non terminating decimals are the numbers that have an infinite number or an uncountable number of digits after the decimal point. These decimals are also used to express the whole number and fraction together that are separated from each other by inserting a “$.$” i.e. a decimal point. For example, $7.454545…$, or $2.78654324573067…$. In the case of non terminating decimal numbers, the digits do not terminate after the decimal point.

The non terminating decimals are further divided into two types.

• Non terminating but recurring decimal numbers
• Non terminating and non recurring decimal numbers

## What is Recurring Decimal?

The recurring decimals or non terminating but recurring decimal numbers are the numbers that consist of two parts a whole part and the fractional part separated by a decimal point ‘$.$’ and the number of decimal places are infinite but repeats in a fixed pattern.

All non terminating but repeating decimal numbers are rational numbers and can be expressed in the form $\frac {p}{q}$.

Examples of non-terminating but repeating decimals are $5.222222…$, $8.12121212…$, $-56.453453453…$.

In the case of $5.222222…$, the digit $2$ is repeating and it appears an infinite number of times in the number or never terminates. The number $5.222222…$ can also be written as $5. \overline{2}$.

In the case of $8.121212121212…$, the digits $12$ are repeating and they appear an infinite number of times in the number or never terminate. The number $8.121212121212…$ can also be written as $8. \overline{12}$.

Similarly, in the case of $-56.453453453…$, the digits $453$ are repeating and they appear an infinite number of times in the number or never terminate. The number $-56.453453453…$ can also be written as $-56. \overline{453}$.

## What is Non Recurring Decimal?

The non recurring decimals or non terminating and non recurring decimal numbers are the numbers that consist of two parts a while part and the fractional part separated by a decimal point ‘$.$’ and the number of decimal places are infinite and never repeats.

All non terminating and non recurring decimal numbers are irrational numbers, i.e., these are the numbers that are not rational numbers and cannot be expressed in the form $\frac {p}{q}$.

Examples of non terminating and non recurring decimal numbers are $5.6754246089…$, $-3.8975630986…$.

Note: $\pi = 3.1415926535 8979323846 2643383279 5028841971$ is the most widely used non terminating and non recurring decimal number.

Is your child struggling with Maths?
We can help!
Country
• Afghanistan 93
• Albania 355
• Algeria 213
• American Samoa 1-684
• Andorra 376
• Angola 244
• Anguilla 1-264
• Antarctica 672
• Antigua & Barbuda 1-268
• Argentina 54
• Armenia 374
• Aruba 297
• Australia 61
• Austria 43
• Azerbaijan 994
• Bahamas 1-242
• Bahrain 973
• Belarus 375
• Belgium 32
• Belize 501
• Benin 229
• Bermuda 1-441
• Bhutan 975
• Bolivia 591
• Bosnia 387
• Botswana 267
• Bouvet Island 47
• Brazil 55
• British Indian Ocean Territory 246
• British Virgin Islands 1-284
• Brunei 673
• Bulgaria 359
• Burkina Faso 226
• Burundi 257
• Cambodia 855
• Cameroon 237
• Cape Verde 238
• Caribbean Netherlands 599
• Cayman Islands 1-345
• Central African Republic 236
• Chile 56
• China 86
• Christmas Island 61
• Cocos (Keeling) Islands 61
• Colombia 57
• Comoros 269
• Congo - Brazzaville 242
• Congo - Kinshasa 243
• Cook Islands 682
• Costa Rica 506
• Croatia 385
• Cuba 53
• Cyprus 357
• Czech Republic 420
• Denmark 45
• Djibouti 253
• Dominica 1-767
• Egypt 20
• Equatorial Guinea 240
• Eritrea 291
• Estonia 372
• Ethiopia 251
• Falkland Islands 500
• Faroe Islands 298
• Fiji 679
• Finland 358
• France 33
• French Guiana 594
• French Polynesia 689
• French Southern Territories 262
• Gabon 241
• Gambia 220
• Georgia 995
• Germany 49
• Ghana 233
• Gibraltar 350
• Greece 30
• Greenland 299
• Guam 1-671
• Guatemala 502
• Guernsey 44
• Guinea 224
• Guinea-Bissau 245
• Guyana 592
• Haiti 509
• Heard & McDonald Islands 672
• Honduras 504
• Hong Kong 852
• Hungary 36
• Iceland 354
• India 91
• Indonesia 62
• Iran 98
• Iraq 964
• Ireland 353
• Isle of Man 44
• Israel 972
• Italy 39
• Jamaica 1-876
• Japan 81
• Jersey 44
• Jordan 962
• Kazakhstan 7
• Kenya 254
• Kiribati 686
• Kuwait 965
• Kyrgyzstan 996
• Laos 856
• Latvia 371
• Lebanon 961
• Lesotho 266
• Liberia 231
• Libya 218
• Liechtenstein 423
• Lithuania 370
• Luxembourg 352
• Macau 853
• Macedonia 389
• Malawi 265
• Malaysia 60
• Maldives 960
• Mali 223
• Malta 356
• Marshall Islands 692
• Martinique 596
• Mauritania 222
• Mauritius 230
• Mayotte 262
• Mexico 52
• Micronesia 691
• Moldova 373
• Monaco 377
• Mongolia 976
• Montenegro 382
• Montserrat 1-664
• Morocco 212
• Mozambique 258
• Myanmar 95
• Namibia 264
• Nauru 674
• Nepal 977
• Netherlands 31
• New Caledonia 687
• New Zealand 64
• Nicaragua 505
• Niger 227
• Nigeria 234
• Niue 683
• Norfolk Island 672
• North Korea 850
• Northern Mariana Islands 1-670
• Norway 47
• Oman 968
• Pakistan 92
• Palau 680
• Palestine 970
• Panama 507
• Papua New Guinea 675
• Paraguay 595
• Peru 51
• Philippines 63
• Pitcairn Islands 870
• Poland 48
• Portugal 351
• Puerto Rico 1
• Qatar 974
• Romania 40
• Russia 7
• Rwanda 250
• Samoa 685
• San Marino 378
• Saudi Arabia 966
• Senegal 221
• Serbia 381 p
• Seychelles 248
• Sierra Leone 232
• Singapore 65
• Slovakia 421
• Slovenia 386
• Solomon Islands 677
• Somalia 252
• South Africa 27
• South Georgia & South Sandwich Islands 500
• South Korea 82
• South Sudan 211
• Spain 34
• Sri Lanka 94
• Sudan 249
• Suriname 597
• Svalbard & Jan Mayen 47
• Swaziland 268
• Sweden 46
• Switzerland 41
• Syria 963
• Sao Tome and Principe 239
• Taiwan 886
• Tajikistan 992
• Tanzania 255
• Thailand 66
• Timor-Leste 670
• Togo 228
• Tokelau 690
• Tonga 676
• Tunisia 216
• Turkey 90
• Turkmenistan 993
• Turks & Caicos Islands 1-649
• Tuvalu 688
• U.S. Outlying Islands
• U.S. Virgin Islands 1-340
• UK 44
• US 1
• Uganda 256
• Ukraine 380
• United Arab Emirates 971
• Uruguay 598
• Uzbekistan 998
• Vanuatu 678
• Vatican City 39-06
• Venezuela 58
• Vietnam 84
• Wallis & Futuna 681
• Western Sahara 212
• Yemen 967
• Zambia 260
• Zimbabwe 263
• Less Than 6 Years
• 6 To 10 Years
• 11 To 16 Years
• Greater Than 16 Years

## Converting Terminating Decimals to Fractions

As discussed above the terminating decimals are rational numbers and hence can be converted into the form $\frac {p}{q}$. The following steps are used to convert a terminating decimal to a fraction.

Step 1: Write the decimal number as a numerator but without a decimal point. e.g., for $7.8$ the numerator will be $78$, and similarly, for $14.76$ the numerator will be $1476$.

Step 2: Count the number of digits in decimal places and write the denominator as a power of $10$, with the number of decimal places as power. For example, in the case of $7.8$, the number of digits after the decimal point is $1$, therefore denominator will be $10$. And similarly, in the case of $14.76$, the number of digits after the decimal point is $2$, therefore the denominator will be $100$.

Step 3: Reduce the fraction, if required.

### Examples

Ex 1: Convert $15.8$ to a fraction.

The numerator will be  $158$ (Decimal number without decimal point).

Number of digits after decimal places = $1$.

Therefore, the denominator will be $10^{1} = 10$.

And fraction is $\frac {158}{10} = \frac {79}{5}$ . (Reducing it to the lowest form)

It can also be written as $15 \frac {4}{5}$ as a mixed fraction.

Ex 2: Convert $2.548$ to a fraction.

The numerator is  $2548$ (Decimal number without decimal point).

Number of digits after decimal places = $3$.

Therefore, the denominator is $10^{3} = 1000$.

And fraction is $\frac {2548}{1000} = \frac {637}{250}$. (Reducing it to the lowest form)

It can also be expressed as a mixed fraction as $2 \frac {137}{250}$.

## Converting Non Terminating But Recurring Decimals to Fractions

A non-terminating but recurring decimal number can be converted to its rational number equivalent as

Step 1: Assume the repeating decimal to be equal to some variable $x$

Step 2: Write the number without using a bar and equal to  $x$

Step 3: Determine the number of digits having a bar on their heads or the number of digits before the bar for mixed recurring decimal

Step 4: If the repeating number is the same digit after decimal such as $0.333333…$  then multiply by $10$, if repetition of the digits is in pairs of two numbers such as  $0.252525…$ then multiply by $100$ and so on

Step 5: Subtract the equation formed by step $2$ and step $4$

Step 6: Find the value of $x$ in the simplest form

### Examples

Ex 1: Convert $0.222222… \left(= 0. \overline{2} \right)$ to a rational number

Let $x = 0.222222…$ —————————————- (1)

Since only $1$ digit is repeated multiply both sides by $10$

$10 \times x = 10 \times 0.222222…$

$=> 10x = 2.222222…$ ————————————– (2)

Subtract (1) from (2)

$9x = 2 => x = \frac {2}{9}$

Therefore, $0.222222… \left(= 0. \overline{2} \right) = \frac {2}{9}$

Ex 2: Convert $1.343434… \left(= 1. \overline{34} \right)$ to a rational number

Let $x = 1.343434…$ —————————————- (1)

Since $2$ digits are repeated multiply both sides by $100$

$100 \times x = 100 \times 1.343434…$

$=> 100x = 134.343434…$ ————————————– (2)

Subtract (1) from (2)

$99x = 133 => x = \frac {133}{99}$

Therefore, $1.343434… \left(= 1. \overline{34} \right) = \frac {133}{99} = 1 \frac {34}{99}$

Ex 3: Convert $6.27454545… = 6.27 \overline{45}$ to a rational number

Let $x =$6.27454545…$—————————– (1) Since$2$numbers$2$and$7$are not repeated, therefore, multiply both sides by$100100 \times x = $100 \times 6.27454545…$ —————————– (1)

$=> 100x = 627.454545…$ —————————————————-(2)

Also, $2$ numbers $4$ and $5$ are repeating, therefore, multiply both sides by $100$

$100 \times 100x = 100 \times 627.454545…$

$=> 10000x = 62745.454545…$ ———————————————(3)

Now subtract (2) from (3)

$9900x = 62118 => x = \frac {62118}{9900} = \frac {31059}{4950} = 6 \frac {1359}{4950}$

## Identifying Terminating & Non Terminating Decimals

You can classify any rational number in the form $\frac {p}{q}$, where $p$ and $q$ are integers and $q \ne 0$ as recurring or non recurring without actually dividing the numerator and denominator.

The first step here is to reduce the fraction in its lowest or simplest form.

The next step is to check the denominator part of the fraction, i.e., $q$.

If $q$ can be factorized in the form $2^{m}5^{n}$, then the number is terminating otherwise not.

Note: These types of  fractions are terminating

• The prime factor of the denominator is only $2$, such as $2$, $4$, $8$, $16$, … Fractions $\frac {1}{2}$, $\frac {3}{4}$, $\frac {5}{8}$, $\frac {11}{16}$ are all terminating decimals.
• The prime factor of the denominator is only $5$, such as $5$, $25$, $125$, $625$, … Fractions $\frac {3}{5}$, $\frac {19}{25}$, $\frac {79}{125}$, $\frac {107}{625}$ are all terminating decimals.
• The prime factors of the denominator are $2$ and $5$, such as $10$, $20$, $250$, … Fractions $\frac {3}{10}$, $\frac {17}{20}$, $\frac {127}{250}$ are all terminating decimals.

If the prime factors of the denominator are any number other than $2$ and $5$, the number is a non terminating decimal. For example, $\frac {7}{30}$ is a non terminating decimal. Although $2$ and $5$ are the prime factors of $30$, along with these prime factors, $3$ is also a prime factor of $30$. (Prime factorization of $30$ is $2 \times 3 \times 5$.

## Finding Number of Decimal Places in Recurring Decimals

You can find the number of places in a terminating decimal number without actually dividing the numerator by the denominator.

To do so express the denominator, i.e., $q$ in $\frac {p}{q}$ as $2^{m}5^{n}$.

• If $m \gt n$, then the number will terminate after $m$ decimal places
• If $n \gt m$, then the number will terminate after $n$ decimal places

### Examples

Ex 1: Find the number of decimal places in the expansion of $\frac {7}{40}$.

$40 = 2 \times 2 \times 2 \times 5 = 2^{3}\times 5^{1}$.

Since prime factors of $40$ are $2$ and $5$ only, $\frac {7}{40}$ is a terminating decimal number.

Power of $2$ is $3$ and that of $5$ is $1$, therefore, $\frac {7}{40}$ will terminate after $3$ decimal places.

$\frac {7}{40} = 0.175$.

Ex 2: Find the number of decimal places in the expansion of $\frac {51}{250}$.

$250 = 2 \times 5 \times 5 \times 5 = 2^{1}\times 5^{3}$.

Since, prime factors of $250$ are $2$ and $5$ only, so $\frac {51}{250}$ is a terminating decimal number.

Power of $2$ is $1$ and that of $5$ is $3$, therefore, $\frac {51}{250}$ will terminate after $3$ decimal places.

$\frac {51}{250} = 0.204$.

Ex 3: Find the number of decimal places in the expansion of $\frac {7}{100}$.

$100 = 2 \times 2 \times 5 \times 5 = 2^{2}\times 5^{2}$.

Since prime factors of $100$ are $2$ and $5$ only, $\frac {7}{100}$ is a terminating decimal number.

Power of $2$ is $2$ and that of $5$ is $2$, therefore, $\frac {7}{100}$ will terminate after $2$ decimal places.

$\frac {7}{100} = 0.07$.

## Conclusion

The decimal numbers are of two types terminating and non terminating. The non terminating decimal numbers are further divided into two categories – non terminating but recurring and non terminating and non recurring. The terminating decimals and the non terminating but recurring decimals are also called rational numbers whereas the non terminating and non recurring decimal numbers are irrational numbers.

## Practice Problems

Which of the following are terminating decimal numbers? Also, find the number of decimal places in terminating decimals without actually dividing.

• $\frac {5}{100}$
• $\frac {7}{75}$
• $\frac {49}{600}$
• $\frac {19}{200}$
• $\frac {127}{1450}$
• $\frac {68}{350}$

## FAQs

### What is a non terminating decimal?

Non terminating decimals are the numbers that have an infinite number or an uncountable number of digits after the decimal point. These decimals are also used to express the whole number and fraction together that are separated from each other by inserting a “$.$” i.e. a decimal point. For example, $7.454545…$, or $2.78654324573067…$. In the case of non terminating decimal numbers, the digits do not terminate after the decimal point.

### What is the terminating decimal?

Terminating decimals are the numbers that have a fixed or a finite number of digits after the decimal point. Decimals are used to express the whole number and fraction together that are separated from each other by inserting a “$.$” i.e. a decimal point. For example, $3.6$, $3$ is the whole number and $6$ is the decimal fraction.

### How do you find terminating and non terminating decimals?

Express the denominator of the fraction as the product of its prime factors. If the prime factors are only $2$ or $5$ and are expressed in the form $2^{m}5^{n}$, then the fraction is terminating, otherwise not.

### What are non terminating, non repeating decimals?

The decimal numbers where there are infinite decimal places and are not repeating or showing any fixed pattern are called non terminating, non repeating decimal numbers. For example $8.56425889209034…$.

### What are non terminating, repeating decimals?

The decimal numbers where there are infinite decimal places but are repeating or shows some fixed pattern is called non terminating but repeating decimals. For example $34.777777…$, $92.82828282…$.


text:
## SeSim - Stock Exchange Simulator

By | February 19, 2017

Earning money by day trading is considered to be extremely hard. I've often read that about 95% of people who attempt day trading will lose money. This might be true and coincidences with my observations among people I know, because I don't know anybody who is able to make money by day trading.

But who are these 5% of people making money by day trading ? Do they really exist?

Sometimes I believe the only people making money by day trading are people writing about day trading or people teaching other people in day trading or people selling software for day trading or any other people doing things related to day trading but actually don't do day trading.

Do these 5% really exist?
If they exist, they are already rich, for sure, because they are the successful day traders, and if they still keep on day trading, they have a lot of power  to move the market.

So there was the question: What if I was one of these 5%? What if I was mighty? What if I had a nearly  unlimited amount of money? What if I had such a huge amount of money, that my orders will move the market? How does it feel to move the market by placing huge orders? What can I achieve by placing big orders?

Because it's very hard to jump out from the 95%  to the upper 5%  in real live, I decided to write a little piece of software which simulates real live market situations while cheating me into the upper 5% of day traders with a lot of money.

The program is called SeSim - The Stock Exchange Simulator. It is open source. You can download the source code from github. The software is still under development, but basic functionality is already given.

In the future I will write more about it here, how to us it, how to install it.

Stay tuned.

## Day Trading and Commission Fees

By | December 25, 2016

Imagine you were a day trader, and you make in average one trade per day on 200 days a year.
Further imagine you have to pay a commission fee of $10 when buying shares, and again you have to pay a commission fee of$10 when selling shares, which is effectively $20 per trade. So you can simply calculate: You will pay$4,000 per year in commission fees.
Or in other words: You have to make with your trades a profit of at least $4,000 a year to make no losses. And now take a look at your account balance. If you start with$1,000, you have to have a yearly performance of 500%, which would results in a profit of $4,000, only to pay the commission fees. You are only on the winning side, if your performance is better than 500%. If you start with$10,000 you have to raise your account only 40% up ($14,000), to pay the commission fees to make no loss, but still no win. And last: If you start width$100,000, your performance has to be at 4%, to pay the commission fees.

So remember: Your biggest enemy are neither the other traders, nor the trend or whatever, your biggest enemy in dat trading are the commission fees in relation to your trading capital.

## Hykker Mechanical Keyboard

By | December 23, 2016

A Hykker mechanical keyboard with pretty nice Chinese blue switches illuminates my desktop. It's Christmastime.

## Integer Factorization Using Backtracking with Erlang

By | December 18, 2016

In an earlier post I showed an algorithm to factorize integers using backtracking. The algorithm was implemented in python. Here we have now the same thing in erlang.

To run the code, copy the script and save it to a file named "factorize.erl".

Then enter a shell and compile the module using the following command:

$erlc factorize.erl  Now you can factorize an integer (in our example 129) with this command: $escript factorize.beam 129
[3,43]

It seams, the erlang version is much faster than the python version.

Here is the Erlang code.

Have fun!

-module(factorize).

-export([
main/1
]).

getbit(X, N) ->
(X bsr N) band 1.

setbit(X, N, 1) ->
X bor (1 bsl N);
setbit(X, N, 0) ->
X band (bnot (1 bsl N)).

bitcmp(_I1, _I2, _N, _N)->
0;
bitcmp(I1, I2, N, I)->
B1=getbit(I1, I),
B2=getbit(I2, I),
if
B1 /= B2 ->
B1 - B2;
true ->
bitcmp(I1, I2, N, I + 1)
end.

bitcmp(I1, I2, N) ->
bitcmp(I1, I2, N, 0).

fac_check(I, 1, _I2, P, _Bits) when P == I ->
false;
fac_check(I, _I1, 1, P, _Bits) when P == I ->
false;
fac_check(I, _I1, _I2, P, _Bits) when P > I ->
false;
fac_check(I, _I1, _I2, P, _Bits) when P == I ->
true;
fac_check(I, _I1, _I2, P, Bits) ->
bitcmp(I, P, Bits).

fac_check(I, I1, I2, Bits) ->
fac_check(I, I1, I2, I1 * I2, Bits).

fac_run(I, _I1, _I2, _N, 4) ->
[I];
fac_run(I, I1, I2, N, B) ->
B1 = getbit(B, 0),
B2 = getbit(B, 1),
I1N = setbit(I1, N, B1),
I2N = setbit(I2, N, B2),

R = fac_check(I, I1N, I2N, N + 1),

case R of
true ->
lists:append(factorize(I1N), factorize(I2N));
0 ->
F=fac_run(I, I1N, I2N, N+1, 0),
if
F =/= [I] ->
F;
true ->
fac_run(I, I1, I2, N, B + 1)
end;
_ ->
fac_run(I, I1, I2, N, B + 1)
end.

fac_run(I, I1, I2) ->
fac_run(I, I1, I2, 0, 0).

factorize (I) ->
lists:sort(fac_run(I, 0, 0)).

main(Val) ->
[X]=Val,
R=factorize(list_to_integer(X)),
io:write(R),
io:format("~n").

## Edward Snowdens Cryptic Post

By | August 10, 2016

ffdae96f8dd292374a966ec8b57d9cc680ce1d23cb7072c522efe32a1a7e34b0

## Comparing an IBM Model M Keyboard with an HP C1405A

By | April 16, 2016

IBM Model M Keyboard from 1985

HP Keyboard from somewhere in the 90ies

Today I want to  compare my both favorite keyboards, an IMB Model M from 1985 and an Hewlet Packard keyboard C1405A from the 90ies. Both keyboards have a good  typing sound, a good feedback, both are very heavy wighted,  but I don't want to lose too many words, see yourself, which is the better one. Next I give you two text examples, on typed on the IBM Model M and the other on the HP C1405A.  I have marked them both in different colors, so you can better distinguish them.

This is typed on the IBM Model M keyboard:

The quick brown fox jumps over the lazy dog.

And this is typed on the HP C1405A keyboard:

The quick brown fox jumps over the lazy dog.

Do you see the difference?

## Want to SSH or Telnet into a Cisco Wireless AP with Default Username and Password?

By | March 28, 2016

You probably know, that you can't enable ssh or telnet on a Cisco AP, until you have set a custom password, different from the default credentials ( username = Cisco, password = Cisco).

The Cisco WLC prevents you from that indeed bad practice.

But finally, with AC-Tube, the Open Source CAPWAP AC, you are free to do even this! Because AC-Tube is still in an early development stage, there is no fool proof web interface, where you simply check a box to enable SSH or telent. But if you open an sqlite3 shell and modify the wtpprops table while you have actube running with a  joined AP you get it to work.

Isn't it nice? Isn't it?

## Problems with FTP when Installing FreeBSD

By | February 13, 2016

If you have problems installing FreeBSD using FTP, because you are behind a NAT that doesn't handle FTP properly, simply chose HTTP.

In the "Mirror Selection" dialog select the "Main Site", and then chose "Other":

And now simply replace ftp with http:

The installation should work now.

## Integer Factorization Using Backtracking

By | February 1, 2016

Here is an algorithm, written in Python, to factorize integers, using backtracking. The time consumption should be around  $\mathcal O 2 ^ {\frac n 2}$.
So it's not the fastest one, but it's nice.
To use it, save the code to a file. If you call the file, for example, "factorize.py", then run

python factorize.py <integer to factorize>

Have fun!

import sys
def getbit(i,n):
return (i>>n)&1

def setbit(i,n,val=1):
if val==1:
return i | (1<<n)
return i & (~(1<<n))

def bitcmp(i1,i2,n):
for i in range (0,n):
b2 = getbit(i2,i)
b1 = getbit(i1,i)
if b1!=b2:
return b1-b2
return 0

def fac_check(i,i1,i2,bits):
p = i1*i2
if p>i:
return -3
if p==i:
if i1==1 or i2==1:
return -4
return 10
return bitcmp(i,p,bits)

def factorize_run(i,i1,i2,n):
for b in range (0,4):
i1 = setbit(i1,n,getbit(b,0))
i2 = setbit(i2,n,getbit(b,1))
rc = fac_check(i,i1,i2,n+1)
if rc==10:
return factorize(i1)+factorize(i2)
if rc==0:
f = factorize_run(i,i1,i2,n+1)
if f!=[i]:
return f
return [i]

def factorize(i):
l = factorize_run(i,0,0,0)
l.sort()
return l

fpr = int(sys.argv[1])

print "Factorizing "+str(fpr)+" ..."
rc = factorize(fpr)
print rc

## Don't use Hotmail.com, Live.com, Outlook.com ...

By | January 30, 2016

Have you ever missed an important event, because you haven't got the invitation email, but an invitation email was evidently sent to you?
If so, you are probably using an email address at hotmail.com or outlook.com or in general Microsoft's mail services, also including addresses at live.com and other  domains.

The reason for this is Microsoft's questionably spam protection. When an email arrives at their servers, the email is nearly always accepted, but then, if they think the email came from a server, which sends spam, the email is silently dropped. Neither the sender will ever get a notification, that the email didn't arrive, nor the recipient will be notified, that there was an email for her or him, respectively. The email is not even delivered to the recipients spam folder. The email is lost.
In terms of paper mail:  its the same as the sender brings the paper mail to the post office, the sender pays for a stamp, the post officer accepts the mail, postmarks the mail, and as soon as the sender turns aways from the counter, the post officer throws the mail into the trash under the desk.

So, Microsoft's mail services are not reliable. Silently dropping emails violates RFC 5321 as you can read in chapter 6.1.

If you want to be reachable by email, you must not use Hotmail or any of Microsoft's mail services. You should use Gmail or any other mail service instead, where the sender gets an appropriate error message if an email is not accepted or delivered to the recipient. In case of an error message the sender can take action to fix the problem with the mail server, that might send spam, or the sender can try to contact you over another path, like snail mail or telephone.


text:
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

# vvvv gamma 2020.2 release

Hello everyone!

Here is the second big release this year for vvvv gamma! Available for download and purchase. Now!

It comes with improvements that strengthen the toolkit character of vvvv gamma and VL, which are outlined over here: vvvv-the-tool.

It also comes with small improvements for object-oriented programming patterns by introducing the This node. Many of those changes were motivated to be able to roll out a certain library. So this is the last version without that exact library.

Bugfix releases:

• 2020.2.2 on October 1st, 2020
• 2020.2.3 on November 17, 2020
• 2020.2.4 on November 25, 2020
• 2020.2.5 on January 8, 2021

For the full list of changes, see the The Log of Changes.

### Updating libraries

This release introduces a breaking change for certain NuGet packages! If you use any of the following packages then you'll have to make sure to use the latest available version:

• VL.OpenCV
• VL.Devices.Kinect2
• VL.Devices.AzureKinect
• VL.Devices.AzureKinect.Body
• VL.Devices.Nuitrack
• VL.Devices.RealSense
• VL.MediaFoundation
• VL.Elementa -pre
• VL.Audio -pre
• VL.IO.OSC -pre
• VL.RunwayML -pre

So when updating to 2020.2.x you need to update to the latest version of these libraries. See Manage Nugets on how to do so via command-line.

### Running 2020.1.x on the same machine

If, after running 2020.2.x and updating the above libraries you want to run 2020.1.x again, you'll have to make sure to first remove the new packs that are only working for 2020.2.x.

To do so, you'd go to your

    AppData\Local\vvvv\gamma\nugets

and either delete packs selectively or simply clean the whole directory and re-install NuGets as you need them.

### Info for library developers

This breaking change only affects your library if it is using a CSharp-project that is referencing VL.Core! In this case, all you have to do is to update VL.Core to 2020.2.x.

Then please communicate which version of your library is compatible with which version of vvvv.

Sorry for the inconvenience, we hope to make it up soon, by sharing a certain library...

Happy patching & see you soon,
yours devvvvs!

gregsn, Friday, Jan 8th 2021
• 1

# Shoutbox

~4d ago

NoseBleedIndustries: Please, integration with this low cost mechanical display, so beautiful! https://www.vestaboard.com/

~4d ago

NoseBleedIndustries: Please, integration with this low cost mechanical display, so beautiful! https://www.vestaboard.com/

~8d ago

joreg: @mediadog they are here: workshop-videotracking-node10

~9d ago

mediadog: Hmmm slides for node10 video tracking cannot be found: workshop-videotracking-slides

~10d ago

~11d ago

mediadog: Where are the 50beta42 offline instalers? The offline installers are still linked to 41, not 42.

~11d ago

~14d ago

id144: thanks @gegenlicht & @bjoern, i hope the festival sorted it.

~16d ago

Patxi7: @joreg done


text: Draw a custom shape. Draw vertical lines from the outer circle (except on major and minor axis). Draw better horses with a solid understanding of horse anatomy and mechanics . So Cute! Thanks for contributing an answer to TeX - LaTeX Stack Exchange! Learn how to draw three types of braids step by step . How to Draw a 90-Degree Line in Photoshop. Step 13. On the Home tab, in the Tools group, click the arrow next to Rectangle, and then do one of the following: To draw a rectangle, select the Rectangle tool. Now, just add the final, dark lines! Tutorial â 5 Steps to Draw a State Machine Diagram Page 3 of 11 2. 4. Enter its description: When the balance of the bank account hits $0. Continue to draw all the connections on the network diagram. Step 12. If your brush is too big or too small, double-click the tool's icon in the toolbox, scroll down to the "Size" bar, and click and drag left or right on the bar to shrink or enlarge your drawing tool. Typically, when you draw on a form, you handle the formâs Paint event and perform the drawing using the Graphics property of the PaintEventArgs, as shown in this example. 3. This example draws a line on a form. Next, draw a horizontal line that extends off the bottom end of the vertical line. Then we draw a second line coming from the same point, but this time above the horizon line. Then, draw a shorter vertical line that extends down from one end of the first line. Finally, draw a vertical line between the ends of the 2 horizontal lines to finish the rectangle. 3. View this post on Instagram . Horses are notoriously difficult to capture. Finish the haircut in a simple way. Example 1: This example draws a rectangle that is filled with red color. Plus, get it wrong and your steed will quickly start to look comical. If you're using the "Fill" tool, simply click once the item you want to fill with your selected color. Try to draw the lines near the minor axis a little longer, but draw them a little shorter as you move toward the major axis. The tables represent Business entities on the ERD. Image by author (CC with attribution) In this article, I share all tricks of the trade how I draw professional charts every day with minimal effort. Hold Shift and start drawing to the left or right to draw a horizontal line, and up or down to draw a vertical line. Could someone please show me a minimal working example of using C language for Cairo with Gtk3 to draw a single line in a GtkDrawingArea.I've tried to modify testcairo.c in the Gtk3 tests folder but I can't get it to work. Doing so will draw along with your cursor. Name the table. 8. Next, draw arrows on the shape that show the forces acting on the object. Step 7. 7. How to draw a cute cartoon polar bear in less than 2 min! Select the zero balance state. The star of David, also known as the "Hebrew Star", is basically two triangles on top of each other. These will be parallel to the minor axis, and go inward from all the points where the outer circle and 30 degree lines intersect. There are two rules: Tasks (activities) are represented as arrows; Milestone dates are nodes; PERT charts are also called activity-on-arrow diagrams (project managerâs slang). Draw a rectangle or circle. I Want to draw a circle with 12 equidistant points .in clockwise direction and lable the equidistant points by$1,\bar{1},2,\bar{2},3,\bar{3},\cdots,6,\bar{6},the last step ,I want to connect 1 and 2,1 and 3 ,2 and 3 whcih make 12 ,13,23,be a chord of the circle â¦ Double click on the table to open a window (table editor) at the bottom. 7 min read. Step 15. Draw connections between components. I am required to implement this myself). Move the mouse to the platform and click on the location where you want to place the table. But avoid â¦. Create a new master shape. So i have this code which makes a box, but want to make the corners +, the lengths |, and the widths - . (Yes, I am aware OpenGL can draw lines. In this tutorial, we'll learn how to draw three different types of braids: three-strand, French, and fishtail. If you want to create a real TV remote in your app you can create a different types of buttons (for example: d-pad button, volume button, channel button and so on). 8. You can draw the gantt chart without doing a network diagram, and many people do (I have as well). Photoshop will straighten them for you. This window provides options to enter the table name (entity). Make sure itâs the same length as the first horizontal line you drew. Please be sure to answer the question.Provide details and share your research! 03/30/2017; 2 minutes to read; a; In this article. \tikz [c/.style={insert path={circle[radius=2pt]}}] \draw (0,0) -- (1,1) [c] -- (3,2) [c]; There is also an example for the key handler /.pic (p.255) to produce the same filled circle. Draw the side of the haircut in the front. There's no mass of fur to hide behind, there are all kinds of difficult angles on the head, and the skeleton works differently to what we're typically used to. Tip: You can adjust the arrow style by clicking on it. I am using OpenGL ES 2.0 I have a bunch a quads to be drawn, would love to be able to have to pass only 4 vertices per quad as if I were using GL_QUADS, but basically I just want to know the best way of drawing a bunch of separate quads. All you'll need to get started is some reference photos of these hairstyles, a pencil, an eraser, a pen, and paper. But if you want to build the most efficient schedule and know what items to focus on during the project, you need to know the critical path tasks. Draw the "helmet", leaving some distance around the head. Draw tables on the platform. Select the table icon or press T from the vertical menu bar. Sketch the rhythm of the rest of the haircut. Step-by-step guide on how to draw a sequence diagram in UML using Lucidchart. Then let's draw a braid! Télécharge la dernière version de How to Draw Graffiti Letters pour Android This tutorial will help you plan and create a sequence diagram using standard practices. Now you know how to draw three cute, celebrating chibi girls, as well as any chibi in any outfit you want. Level 3/5 difficulty. Step 14. These methods has the advantage to be really simple, but are not good for me because: The appearance of the point depend on the path command action (draw, fill, ...). Next, click the arrow icon in the menu bar and choose one of the two other styles. To draw â¦ How to Draw Cherry 2.0. This article will show you how to draw this star. So far what I've found I could do: -GL_TRIANGLES(6 vertices per quad) -Degenerate GL_TRIANGLE_STRIP(6 vertices per quad) Possibities I've found: â¦ Use the UML shape library and sequence diagram templates provided when you start a free account in Lucidchart! Drag the title bar of Description pane and move it next to the state account with funds.Select account with funds and enter the description: When the balance of the bank account exceeds \$0. OK,I rewrie the question. I am using GLUT and so far have figured out how to open a blank window. Lifetime Buyers can choose between downloading zip files of each movie or streaming them on any of their devices. Step 5. Once I figure out how to draw pixels, I will use that to implement the Bresenham line drawing algorithm. It should be relatively close to the bottom of your paper. Draw an upside down triangle. How to Draw a PERT Chart. To draw a free body diagram, start by sketching a simple representation of the body you want to make the diagram of, like a square to represent a box. Now we are going to move to the left-hand vanishing point and draw in two lines below the horizon line leading from this second point going across the page. Can someone tell me how to draw a single white pixel at a coordinate, say (100,200)? Ready to get started? Elideb Elideb. 9,394 1 1 gold badge 14 14 silver badges 16 16 bronze badges. Add two more lines coming from this vanishing point, and we will now have the rear of our box. The Shift key is also useful here. For example, draw a downward arrow to signify the weight of the object, since gravity pulls the object down. STEP 1 - Draw a table of values for the x and y coordinates. It takes the surface, color, and pygame Rect object as an input parameter and draws a rectangle on the surface. this.spriteBatch.Draw (SimpleTexture, new Rectangle(0, 0, 100, 1), null, Color.Blue, -(float)Math.PI/4, new Vector2 (0f, 0f), SpriteEffects.None, 1f); share | improve this answer | follow | edited Apr 13 '11 at 12:03. answered Jan 15 '11 at 0:43. Draw a rectangle or circle. pygame.draw.rect(): This function is used to draw a rectangle. Now let me show you how to draw a 90-degree line in Photoshop. Subscribe or Buy... CartoonSmart students can now choose between buying Lifetime Access to our courses or purchasing one of our affordable Subscription plans. Please don't suggest the tutorials at the Cairo site; Zetcode.com or gnome.org which are either not for use with Gtk3 or not minimal working examples. How to: Draw a Line on a Windows Form. Step 6. Change your tool's size. Add the x coordinates 0, 1, 2, 3 and 4. How to Draw a Curved Line in Photoshop Step 1 Asking for help, clarification, or responding to other answers. Double-click on any component and then click and hold one of the orange circles, and drag the line to the appropriate symbol. Edit a shape. Sketch along with Tangled Story Artist & Frozen 2 Director of Story Marc Smith as he draws Rapunzel!


text:
# Mathematics - Objective Type Questions - Plus Two - Collection 1

In this post, we present some sample objective type questions that can be asked in the higher secondary mathematics examination. There are a total of 40 one mark questions divided into sets of 8. It is really worth giving a good practice on these questions as this would equip the candidate well for the final examination.

1) If A =

$\begin{bmatrix} 1\\ 2 \\ 3 \end{bmatrix}$

then the value of AAT is

a) 3
b) 0
c) 1
d) 2

2) If the matrix

$\begin{bmatrix} -1 &3 &2 \\ 1 & k &-3 \\ 1 &4 &5 \end{bmatrix}$

has an inverse then the values of K

a) k is any real number
b) k = -4
c) k ≠ -4
d) k ≠ 4

3) If the equation -2x+y+z=l, x-2y+z=m, x+y-2z=n such that l+m+n=0, then the system has

a) a non-zero unique solution
b) trivial solution
c) Infinitely many solutions
d) No Solution

4) Which of the following is not true regarding the non-singular matrices A, B

a) A (adj A) = (adj A) A
b) (AB)-1= B-1A-1
c) (AB)T = BTAT
d) (AT)-1≠ (A-1)T

5) If $\underset{a}{\rightarrow}$ and $\underset{b}{\rightarrow}$ are two unit vectors and ϴ is the angle between them, then ($\underset{a}{\rightarrow}$ + $\underset{b}{\rightarrow}$ ) is a unit vector if
a) ϴ=��/3     b)  ϴ=��/4    c) ϴ=��/2    d) ϴ=2��/3
6) The shortest distance of the point (2,10,1) from the plane $\underset{r}{\rightarrow}$ .(3$\underset{i}{\rightarrow}$ - $\underset{j}{\rightarrow}$ + 4$\underset{k}{\rightarrow}$ ) = 2    is

a) $2\sqrt{26}$

b)

c) 2

d)

7) If the magnitude of moment about the point $\underset{j}{\rightarrow}$ + $\underset{k}{\rightarrow}$ of a force $\underset{i}{\rightarrow}$ + a $\underset{j}{\rightarrow}$ - $\underset{k}{\rightarrow}$ acting through the point $\underset{i}{\rightarrow}$ + $\underset{j}{\rightarrow}$ is then the value of a is

a) 1
b) 2
c) 3
d) 4

8) If the points (3, 2, - 4), (9, 8, - 10) and ($, 4, - 6) are collinear then$ is

a) 5
b) -5
c) 5/2
d) 10

Check out part 2 here.