text:
## Introduction

Earthquakes produce dissipation of energy trapped by the pressure gradient forming between two walls moving at different velocity during the interseismic period. Regardless the tectonic setting, any motion along fault planes determines the shear between two volumes generating the double-couple mechanism1. Earthquakes modify the Earth’s surface, which can now be precisely measured by InSAR data. The original model of elastic rebound2 predicts symmetric displacement on both fault walls, consistent with observations from earthquakes occurring along strike-slip faults. The advent of GPS and Differential SAR Interferometry (DInSAR) data has proven to be essential to carry out a step forward in analysing earthquakes and their coseismic effects on the ground3,4. Along dipping faults, the recorded displacement is asymmetric because the hangingwall systematically moves more than the footwall. Ground deformation maps show that the displacement (either subsidence or uplift) of hangingwall blocks is larger than that of footwall blocks. In fact, normal fault-related earthquakes are characterized by larger coseismic hangingwall subsidence than correlated footwall uplift5; vice versa, along thrust faults, the hangingwall uplifts, whereas the footwall barely moves6. This is geologically obvious because in extensional geodynamic settings the dominating subsidence generates sedimentary basins, whereas the larger hangingwall uplift in contractional settings determines the growth of orogens, although extensional and compressional tectonics may occur also in areas characterized by regional uplift or subsidence7. Different types of energy accumulation have been proposed as a function of fault motion in favour or against gravity8,9. In fact, the number and duration of aftershocks is larger for extensional earthquakes with respect to the other tectonic settings, possibly because they work in favour of gravity10. In this paper, we compute the volumes characterized by uplift and subsidence during the extensional tectonics-related Central Italy 2016 seismic sequence and we speculate on a model explaining why the coseismically subsided volume is much bigger than the uplifted one. Is this phenomenology consistent with the coseismic horizontal elastic rebound or more suitable with the hangingwall gravitational collapse? We address the question whether the rock volume dilated in the brittle layer during the interseismic preparatory period was only elastically stretched1 or alternatively fractured and permeated by a population of thousands of microfractures8.

## Geologic and Geophysical Setting of the Amatrice-Norcia (Central Italy) 2016 Seismic Sequence

On August 24th 2016, an Mw 6.0 earthquake (hypocentral depth at about 8 km) started a seismic sequence in Central Italy that had its apex with a Mw 6.5 (hypocentral depth at about 7 km) on October 30th. More than 100,000 aftershocks struck the area during the more than 30 months long and still active sequence11,12, including a Mw 5.9 event on October 26th, 2016 and other six 5.9 > Mw ≥ 5 events (Fig. 1; data from ISIDe working group, 2016; http://iside.rm.ingv.it/iside/standard/index.jsp and 12). In section, the seismicity illuminates a triangular volume with scattered clouds along a SW-dipping normal fault system dipping 45°–55° and conjugated NE-dipping faults. The faults tip between 6 and 10 km depth over a few km thick, 2°–15° NE-dipping low-angle normal faults system (Fig. 2).

The Apennines are in the hangingwall of a ‘westerly’-directed and ‘easterly’-retreating subduction zone. Contraction occurs in their eastern margin where the accretionary prism involves the shallow layers of the Adriatic plate. The axial part of the belt rather pertains to the backarc undergoing extension at 3–5 mm/yr rates due to the ‘eastward’ retreat of the slab hinge13,14. The accretion and the following extension affected the sedimentary succession of the Tethyan Mesozoic passive continental margin and the overlying active margin foredeep deposits15,16,17. The 2016 Amatrice-Norcia seismic sequence fits the extensional tectonics affecting the central Apennines fold-thrust belt since at least Pliocene time18,19 that generated a system of active NW-trending normal faults20,21,22. The seismic sequence activated progressively a crustal volume 70–90 km long, 10–15 km wide and about 8–10 km deep. The volume of the hangingwall prism affected by coseismic slip amounts to 5500–6700 km3. The wealth of good quality strong motion, seismological11,12, geodetic3,23 and geological data24,25,26,27,28,29 allows an unprecedented complete analysis of the boundary conditions in which the seismic sequence evolved.

The rupture model for the Mw 6.0 August 24th event is characterized by three factors: (1) bilateral rupture30, (2) fast rupture velocity (3.1 km/s), and (3) pronounced heterogeneities of the slip distribution. At depth, the slip is characterized by two main patches, the southern one being smaller and characterized by maximum slip of ~100 cm, and the northern one with an average slip of ~60 cm31,32. The October 26th Mw 5.9 earthquake is actually a double event and the two hypocenters are located at a distance of ~4 km. The rupture history of the October 30th Mw 6.5 earthquake is characterized by rupture velocity of 2.7 km/s and by a large slip patch located ~5 km up-dip from the hypocenter with average slip of 130 cm and maximum slip of 260 cm12. The rupture reached the surface close to the mapped location of the Mt. Vettore–Mt. Bove fault system with further displacement along the ‘nastrino’ of ~50 cm (in places up to ~200 cm)33. No coseismic slip was observed along the Mt. Gorzano fault during the entire seismic sequence.

Paleoseismological studies focused on the Mt. Vettore Fault System and on the Mt. Gorzano Fault showed that medium-high magnitude earthquakes (Mw ≥ 6.0) struck these zones over the past centuries34. In particular, since the 17th century, several moderate-to-large earthquakes affected the Amatrice-Accumoli area, one occurred in 1627 near the town of Accumoli (Mw ~5.3) and one that struck the town of Amatrice in 1639 (Mw ~6.2), provoking numerous casualties and damage35.

The Norcia area was also affected by the 1730 (Mw ~6) and 1979 (Mw 5.8) earthquakes, which generated surface faulting34. This area was also affected and shaken by several earthquakes that occurred in nearby regions, such as the 1703 Valnerina-L’Aquila seismic sequence (Mw ~6.8, 33), the 1997 Colfiorito earthquake (Mw 6.0)36 and the 2009 L’Aquila earthquake (Mw 6.3)37,38. The 2016 seismic sequence filled the seismic gap separating the 1997–1998 Colfiorito sequence (Mw 5.4 and Mw 6.0 earthquakes) and the Mw 6.3 2009 L’Aquila earthquake. The hypocentre of the first mainshock (Mw 6.0 August 24th, 2016) was located about 10 km north of Amatrice12. One hour later an Mw 5.4 earthquake in the Norcia area followed this event. The earthquake occurred along a 50° SW-dipping and ~ 20–25 km long extensional fault31,39. On October 26th, a Mw 5.9 earthquake nucleated 25 km to the north, near the village of Visso, activating another segment of the normal fault. Four days later, on October 30th, the largest mainshock of the sequence (Mw 6.5) hit the area in between the two previous events. The hypocentre was located at about 7 km along a 55° SW dipping fault12.

The distribution of aftershocks (Fig. 2) suggests the activation, during this seismic sequence, of several secondary antithetic NE-dipping extensional faults below the Norcia basin at shallow depth (<4 km). The Mw 5.4 event following the August 24th 2016 Mw 6.0 event, nucleated at the intersection between an antithetic structure and the main fault and was probably located on the first one11. The whole normal fault system, confined within the first 10 km of the upper crust, is detached and floored by a shallow, gently 10°–15° easterly-dipping and 2–3 km-thick layer in which small events plus a series of large extensional aftershocks (≈Mw 4.0) occurred, possibly located in the Triassic evaporitic layers26,40.

According to the seismological data, the entire sequence activated a SW-dipping normal fault system, striking about N150°–160° and dipping ~45°–55°, locally with listric shape. Possible reactivation and inversion of an inherited W-dipping thrust has been advocated41. These principal faults were recognized as the Mt. Gorzano Fault and the Mt. Vettore fault systems31,39,42, both characterized by extensional/transtensional kinematics and dissecting the heterogeneous clayey/marly to carbonatic sedimentary succession of the central Apennines40. The Mt. Gorzano extensional fault is ~ 30 km long, dips ~ 60° to the SW and accommodates a maximum down-dip displacement of ~2.3 km42. Where exposed, the fault juxtaposes Early-Middle Miocene marly limestones (Marne con Cerrogna Fm) in the footwall with Messinian siliciclastic deposits (Laga Fm) in the hangingwall.

The coaxial Mt. Vettore fault system is ~18 km long and consists of a series of SW-dipping (34°–75°) extensional faults, cutting through the flanks and the foothills of Mt. Vettore, Mt. Porche, and Mt. Bove; a maximum total vertical displacement of ~1.2 m was reconstructed along the Mt. Vettore Fault segment34,43. The antithetic conjugate NE-dipping normal fault is not always illuminated by seismicity, and coseismic deformation of the graben or half graben continuously varies moving along strike (Fig. 2), describing a prismatic volume with clouds of earthquakes along the main fault planes (Figs 3 and 4).

## Space Geodesy Results

Figure 5 shows the cumulative vertical displacement from August 24th until November 2016 in the area affected by the seismic sequence. These motions sum up the effects of the Amatrice-Norcia 2016 part of the seismic sequence. The coseismic uplift of the hangingwall is marginal, both in amplitude and spatial extent, with respect to the dominant subsidence. The DInSAR-related vertical deformation map (Fig. 5) shows a subsidence peak of almost 100 cm in the central part (blue), and the average amount of subsidence is about 24 cm. On the contrary, uplift does not exceed 14 cm. Note that we masked out the areas characterized by values ranging between −3 and 3 cm, with 3 cm corresponding to about 1/8 of the exploited ALOS2 SAR system wavelength and representing a realistic error range for the estimated co-seismic displacement. Moreover, the horizontal coseismic motion equals to the cosine of the fault dip, whereas the vertical motion represents the relative sine. The coseismic horizontal motion is smaller than the vertical component, confirming that subsidence is constrained by the vertical maximum stress, i.e., the lithostatic load. The fault dip is the vector sum of the vertical and horizontal components (Fig. 6).

DInSAR vertical displacement data allowed also the computation of the rock volumes displaced during the whole seismic sequence. We used two different methods (see method section) for such computation to crosscheck the validity of results. As expected, we found that subsided and uplifted volumes are largely different: the volumes amount to 0.12 km3 and 0.016 km3, for subsidence and uplift, respectively. This unbalance is clearly highlighted in Fig. 5, where a 3D view of the deformed surface is showed. The difference between subsided and uplifted volumes implies the presence at depth of a crustal zone able to accommodate the hangingwall settlement (Fig. 7). In particular, this missing volume occurs at the coseismic phase, hence it can be considered instantaneous, and responsible for permanent, i.e., inelastic, deformation within the involved rocks. We infer that this inelastic deformation should take place at depth allowing the rock volume to recover a previously dilated zone. Two models have been advocated to explain the occurrence of this pre-existing dilated zone and the coseismic phenomenology, i.e., the horizontal interseismic elastic stretching and the fault motion (associated with elastic rebound) generating the earthquake, or the interseismic stretching associated with the generation of a population of microfractures in the upper crust, eventually determining the gravitational collapse of the hangingwall and normal fault motion with the related double couple.

## Elastic Rebound Versus Gravitational Collapse

It is commonly stated that earthquakes represent the sudden elastic rebound dissipating the pressure gradient accumulated during the interseismic period. This model fits most of the data related to strike-slip and contractional earthquakes. However, the phenomenology associated with normal fault earthquakes shows a number of misfits with respect to the elastic rebound model. Although faults are not straight planes, but rather undulated surfaces and their motion may affect a number of sub-parallel faults bounding a volume rather a single planar fault, the simplified Okada model44 correlates quite correctly the surface motion when fault dip and slip generated at depth by an earthquake are imposed. However, the Okada model does not analyse the mechanism generating earthquakes, but only reproduces the displacement associated with slip on a discrete fault plane within a half-space in an infinite medium. We discuss here whether, in an extensional tectonic setting, the surface deformation described by the Okada45 model and fitting coseismic observations is more consistent with a model in which the energy accumulated during the interseismic period is elastic or gravitational. At the coseismic stage, both models generate fault motion, double-couple mechanism, elastic waves generation, deformation of the surrounding volume, but they differ in a number of further constraints, such as interseismic fracturing e fluids motion, coseismic shear heating, volume folding, hangingwall motion, etc.

As summarized in Fig. 7, during the Amatrice-Norcia sequence the collapsed volume (A) has been about 7.5 times larger than the uplifted volume (B). This unbalance has been explained as a temporary setting, gradually compensated during the post-seismic deformation by the footwall uplift of the viscous-plastic deformation in the lower crust5. However, in the Apennines, there are several examples of coseismic surface rupture that formed at the mainshock and since then are crystallized with no further significant movement between footwall and hangingwall25, although other studies with newer techniques suggest that some post-seismic relaxation and footwall uplift may occur5.

In spite of the crustal-lithospheric extensional setting, at depth deeper than about 1 km, dilation occurs under a compressional horizontal stress due to lateral confinement of rocks. Therefore, horizontal σ3 is contractional at depth even in extensional tectonic environments. Horizontal stretching decreases progressively σ3 during the interseismic stage, whereas σ1 remains almost constant; thus, differential stress increases in time during the interseismic period, eventually leading to rupture, fracturing rocks under dilatancy. The question is whether this pre-earthquake dilated volume during the interseismic period was elastically stretched or it was permeated by a population of thousands of mm-scale microfractures as those that are routinely visible in fractured outcrops or in industrial boreholes. However, once rocks are stressed above their yield stress during the interseismic stage, fractures occur, decreasing or eliminating rocks elasticity.

In nature, along dip-slip faults deformation is highly asymmetric, being mostly confined in the hangingwall. This implies a specular volume asymmetry at depth in order to accommodate the surface variation. In other words, the section should be balanced in terms of involved volumes. However, at the bottom of the brittle upper crust, there occurs the largest differential stress required to deform rocks at the brittle-ductile transition (BDT) and the ductile crust cannot absorb instantaneously such deformation (Fig. 8). Moreover, due to the higher strength, the BDT cannot represent a decoupling layer. This favours the hypothesis of the occurrence of microfractures in the ‘missing’ volume in the brittle crust itself. In addition, the larger movement recorded by GPS and DInSAR analyses is along the vertical3,4,5, following the lithostatic load that tends to match the maximum stress (σ1) in extensional tectonic setting, although the horizontal components (σ2 and σ3) are not negligible. Eventually, once rocks are stressed above their yield stress during the interseismic stage, fractures occur, decreasing rocks elasticity. The horizontal coseismic motion does better fit the gravitational model because the main hangingwall displacement is downward and not horizontal, as testified by SAR and GPS data. Coherently as well known in the literature, normal fault earthquakes increase their magnitude with the dip of the normal fault8.

We propose a scenario in which the upper crust is permeated by millimetric fractures, similar to those that are commonly detected by hydrocarbon wells46. The microfractures that form during the interseismic period might be partly filled by cement and partly by fluids as shown in hydrocarbon exploration boreholes, as also predicted by analogue models47,48 and suggested by multi-temporal SAR measurements49 as well. The interseismic dilatancy is documented both by well logs and was reproduced with numerical modeling50. Coseismic dilatancy and fracturing is also documented, particularly at fault tips of strike slip faults51. Dilatancy varies as a function of the tectonic setting and the interseismic, coseismic and postseismic period50,51.

Different fluids behaviour has been documented as a function of the extensional or contractional tectonic setting52,53. The fluids expulsion during the late pre-seismic and coseismic stage of the Amatrice-Norcia sequence54 supports the presence (at late interseismic stages) and the disappearance (during the earthquake) of a diffuse permeability, compatible with the occurrence and the partial closure during the coseismic stage of a multitude of microfractures. A similar behaviour of fluids expulsion was observed during the 2009 L’Aquila earthquake and is typical of normal fault-related earthquakes53,55,56. Fluids react at the coseismic stage57, being squeezed out of fractures while the hangingwall collapses, i.e., shrinking a previously dilated volume at depth53.

Figure 8 shows a model characterized by the interseismic generation of a dilated wedge permeated by microfractures in the brittle layer, above the ductile steady-state shearing layer. The BDT controls the strain partitioning and the switch between portions of the fault characterized by stick-slip behaviour in the upper brittle crust and continuous creep in the viscous-plastic lower crust. When the strength of the wedge and of the fault will not be any more able to sustain the weight of the wedge overlying the dilated volume, the hangingwall will collapse, generating the double couple related to the shear along the master fault plane, releasing the elastic waves of the earthquake. The slip along the fault allows the downward motion of the hangingwall that will close open fractures in the dilated wedge, generating the expulsion of fluids permeating the hangingwall. Based on rock-mechanics arguments, we interpret this pre-earthquake dilation as associated with microfractures that close catastrophically during the coseismic stage. Support to the occurrence of fractures is further provided by the discrepancy between the larger coseismic slip at the hypocenter (around 260 cm) and the coseismic surface fault displacement (90 cm). This difference implies a vertical coseismic stretching of the hangingwall, which can gradually recover the sudden dilation during the post-seismic gradual gravitational adjustment, being responsible for the more than 100,000 aftershocks up to early December 2018.

According to the model and to numerical simulations8,50,58, the fault hangingwall can collapse, favoured by gravitational energy stored during the interseismic period (Fig. 8), slipping along the fault plane. When the stresses related to gravitational energy exceed the strength of the faults and of the dilated zone, the crustal prism slips down along the normal fault system.

## Discussion and Conclusions

The August 24th 2016, Mw 6.0 extensional earthquake started the Amatrice-Norcia (Central Italy) seismic sequence, reaching its mainshock the Mw 6.5 October 30th at about 8–10 km depth. Based on geologic, seismologic and DInSAR data, a crustal volume of about 6000 km3, confined by a 45°–55° WSW-dipping fault system and its conjugate antithetic faults, subsided about 100 cm in the depocentre of the asymmetric graben. GPS data of the mainshocks constrain smaller horizontal displacements relative to the vertical coseismic motion, consistent with the normal fault dip.

We compare the elastic and gravitational models to explain the asymmetry and the volume unbalance. However, these aforementioned observations are consistent with a preparatory phase during the interseismic period in which a dilated volume accommodates the strain partitioning between the brittle and the viscous-plastic portions of the crust, characterized by stick-slip and steady state creep, respectively50. The entire sequence appears more coherent with the gravitational adjustment of the hangingwall of the fault system. The double-couple visible in the moment tensor is required and implicit with the downward motion of the hangingwall along the main normal fault surface. As interpreted in sections 1–6 of Fig. 2, the seismicity seems to depict the ‘extensional allochthon’59 where a combination of listric and rotating “book-shelf” faults accommodate horizontal extension above a low-angle detachment. However, the family of WSW-directed normal faults across the Apennines does not show any appreciable rotational evolution. In the example discussed in the article, the decoupling does not occur at the BDT, but within a shallower evaporitic layer. This layer acts as a boundary limiting both interseismic and coseismic evolution. This stratigraphic setting prevents the activation of larger upper crustal volumes, hence lowering the expected maximum earthquake magnitude. In fact, in the graviquake model8 it was pointed out that the ratio between the seismic volume depth and the activated volume and related fault length is about 1/3. Therefore, the occurrence of a bounding decoupling layer at about 8–10 km depth limits the volumes length that can be mobilized at each time at no more than 24–30 km, inhibiting a single fault 80–90 km long rupture, hence decreasing the maximum potential earthquake magnitude.

What can be observed during the 2016 Central Italy seismic sequence is that rupture propagated along strike of the volume axis and of the normal faults; different volumes collapsed activating different segments of the normal faults system, moving back and forth from south to north, and then south again. This evolution is compatible with the gravitational coseismic subsidence, although the pre-requisite is the occurrence at depth of an interseismically dilated zone able to be contracted and absorbing the volume downward motion.

Therefore, the analysis of the 2016 Amatrice-Norcia seismic sequence supports the following statements:

• Space geodesy (DInSAR) data show that the volume characterized by coseismic hangingwall subsidence is at least 7.5 times bigger than that coseismic uplift both in the hangingwall and in the footwall.

• The volume unbalance can be interpreted as the evidence in the brittle upper crust of a dilated wedge with a population of microfractures generated during the interseismic period.

• The gravitational collapse of the normal fault hangingwall could be constrained by the loss of strength of the dilated wedge and the normal fault, closing pre-existing microfractures, as postulated by the graviquake model8.

• In order to accommodate the coseismic displacement, the elastic rebound model would rather require a larger horizontal coseismic component and at the lower tip of the normal fault a volume unbalance that cannot be absorbed instantaneously due the higher strength at the BDT.

The larger collapsed volume confirms the asymmetric displacement and larger hangingwall motion60. We infer how this observation can be explained by an equivalent dilation generated at depth during the interseismic period, able to accommodate the fall of the hangingwall at the coseismic stage. All these data could rather be satisfied by the existence of a pre-existing dilated wedge in the upper brittle crust formed during the interseismic period, which will eventually loose strength allowing the hangingwall to collapse gravitationally. Moreover, in spite of the extensional setting, the crust is in a contractional state of stress, while the elastic rebound model requires horizontal stretching. This phenomenology suggests that earthquakes dissipate energy interseismically accumulated not only along the fault but rather stored within the volume that is eventually mobilized and deformed at the coseismic stage; the fault plane is the passive mechanical discontinuity where part of the gravitational energy is transformed into channelized elastic waves.

There are fundamental differences from a landslide as those analysed by61,62 and the proposed graviquakes model. First of all, the basal detachment plane of a landslide is emerging at the Earth’s surface (regardless it is submarine or subaerial), whereas in normal faulting is not, being the lower segment of the normal fault tipping and confined in the lower upper crust. Secondly, in a landslide the hangingwall is unconstrained and free to move relative to the atmosphere, allowing the volume to partial or full disaggregation, whereas a gravity driven normal fault hangingwall is fully confined by the neighbouring crustal volume. Therefore, even if landslides and normal faults are fuelled by gravity, they show very different geometry, kinematics and general phenomenology; consequently, the seismic record must be different (e.g., two-lobe vs. four-lobe seismic radiation pattern from a double couple source).

This research shows how elastic and anelastic deformation is partitioned during the seismic cycle of normal faults and could provide a framework for further investigations. The search for dilated wedges in the upper crust through magnetotelluric techniques, Vp/Vs etc. could illuminate fluid-rich, low-resistivity volumes, which may help to recognize more seismically-prone active volumes.

## Methods

### DInSAR data

Using data obtained by the interferometric processing of the acquired SAR images (Supplementary Information Table S1), we computed the rock volumes coseismically affected by uplift and subsidence. All the SAR images were processed by means of classical DInSAR technique63, and we took the advantage of the SRTM 1-arc second DEM to remove phase topography. As typically performed from the combination of ascending and descending SAR dataset6, we can obtain the vertical and the east-west displacements of the ground deformations caused by the entire sequence.

In detail, we used two approaches in order to crosscheck the validity of the obtained volume estimates. The dataset consists of a pair of ALOS-2 SAR images acquired on ascending orbits on September 9th, 2015 and November 2nd, 2016, together with a pair of images on descending path, dated May 25th, 2016 and November 9th, 2016. The two ground deformation maps were then combined to obtain the vertical displacement map (Fig. 5).

The estimation of uplifted and subsided volumes requires the discrimination of positive and negative values of vertical deformation. Such discrimination was performed by defining a threshold to separate positive and negative values of deformation. The threshold was calculated by setting a range of values through the estimation of the error of the deformation map. The latter can be evaluated looking at the interferometric coherence of the used image pairs64, and such error was estimated (conservatively) around 3 cm. Therefore, after unwrapping interferometric data, we masked out the pixels ranging between −3 and 3 cm, setting to NaN deformation the data within these thresholds. All the negative values appear well separated in the central part of the map in Fig. 5. Such data were used for the rock volume of subsidence. As far as the uplifted volume, the selection of the footwall part is a little bit more difficult. Indeed, as showed in Fig. 5, there are several pixels that overcome the 3 cm threshold, and the identification of those pixels belonging only to the footwall uplift is not very easy. In order to overcome this point, we exploited the information reported in Supplementary Information Table S1, and a polygon that roughly separate pixels in the footwall was drawn (see Fig. 5).

Once the areas for subsided and uplifted volumes are selected, we can calculate the rock volume mobilized during the seismic sequence. It is worth noticing that data were also interpolated to fill-in the no data areas due to interferometric coherence loss.

The first adopted approach is an automatic one, implemented in Surfer® software. It uses a numerical integration algorithms proposed in65, the Extended Simpson’s 3/8 Rule, represented by the following formula:

$${\rm{Volume}}\approx \frac{3{\rm{\Delta }}y}{8}[{{\rm{A}}}_{1}+3{{\rm{A}}}_{2}+3{{\rm{A}}}_{3}+2{{\rm{A}}}_{4}\ldots +3{{\rm{A}}}_{{\rm{nCol}}-1}+{{\rm{A}}}_{{\rm{nCol}}}]$$
(1)

where Δy is the grid row spacing and $${\rm{A}}$$ is the area derived from the following equation:

$${{\rm{A}}}_{{\rm{i}}}\approx \frac{3{\rm{\Delta }}x}{8}[{{\rm{G}}}_{{\rm{i}},1}+3{{\rm{G}}}_{{\rm{i}},2}+3{{\rm{G}}}_{{\rm{i}},3}+2{{\rm{G}}}_{{\rm{i}},4}\ldots +3{{\rm{G}}}_{{\rm{i}},{\rm{nCol}}-1}+{{\rm{G}}}_{{\rm{i}},{\rm{nCol}}}]$$
(2)

where ∆x is the grid column spacing and Gi,j is the grid node value in row i and column j.

A second, manual and simpler method was also adopted to estimate the involved volume. Such a method is based on the extraction of pixels from the vertical deformation map, outside the −3 cm ÷ 3 cm range, and summing the values of volumes for each pixel taking into account the area of the pixel itself, i.e., 900 m2 that corresponds to pixel size of the interferometric product. By easily summing all the selected pixels in a GIS environment (again considering the uplifted and subsided areas in the polygons), we can estimate the rock volumes involved during the seismic sequence. The results of the volume estimates are reported in Supplementary Information Table S2.

The collapsed volumes we computed with the two approaches are identical, therefore, the final estimate is set to 0.12 km3. The uplifted volumes are equal, too, and the final estimation is set to 0.016 km3, hence the final ratio between subsidence and uplift volumes mobilization is 7.5. Therefore, regardless the mechanism (elastic or inelastic) this observation requires at the coseismic stage the closure, at depth, of a dilated volume, equal to the difference between collapsed and uplifted volumes, able to absorb the fall of the hangingwall.

### GPS data

GPS data have a greater accuracy on the horizontal motion with respect to the vertical motion and for this reason they perfectly integrate with DInSAR data that have better and widely distributed vertical accuracy. The dense GPS network of the area allowed to record coseismic deformation quite in detail3: near Accumoli (Fig. 5), the 24th August subsidence and SW-motion has been 17 cm and 5 cm respectively, whereas the 30th October, the recorded subsidence and horizontal motions have been about 40 cm and 25 cm toward the SW, respectively3. Footwall uplift has been of 2–5 cm.

During the October 30th Mw 6.5 Norcia mainshock, at the Mt. Vettore Fault, ~90 cm of hangingwall coseismic vertical component and ~70 cm of westward horizontal component were recorded4. These movements demonstrate that the vertical component is larger than the westerly directed horizontal motion, being their value constrained by the ~50° fault dip plane.

In order to figure out any possible early post seismic deformation, we collected GPS time series from the measurement network in our study area66. Indeed, it is well known that DInSAR displacement maps are static pictures of all the deformation occurred between the master and slave images used to perform the interferometric processing. In particular, the map depicted in Fig. 5 accounts for all the displacements occurred from September 2015 and November 9, 2016. Therefore (assuming that no pre-seismic signals are present), any post-seismic deformation has occurred after the main events (i.e., August 24th, October 26th, and October 30th, 2016) should be embedded in the DInSAR map. Unfortunately, most of the GPS stations in the affected area, and overlapping the SAR map, have been installed after the seismic sequence, hence we are not able to discriminate between co- and post-event displacements because GPS time series start since November 10th–14th 2016 (Supplementary Information Fig. S1).


text:
# High performance screenshots in LWRP

I'm trying to capture some screenshots for my game. They need to be saved as jpgs to a folder, latency is not an issue, I don't care if it happens over 10 seconds. My number one priority is to keep the game at a steady framerate.

Some things I've tried:

Some metrics from my testing:

• ScreenCapture.CaptureScreenshot is ~200ms.
• Texture.Apply() is ~5ms.
• EncodeToJPG() is 35-50ms.
• File.WriteAllBytes() is <1ms.

Also posted this question here and here:

There's two separate parts to this question. First is how to record screenshots without hitting your framerate too much, and second is how to capture screenshots at all in the new render pipelines. The first part is way easier, so let's get that out of the way first.

## Capturing screenshots/GIFs during gameplay

You said you wanted these screenshots for bug testing, and that it would be even better to have video. Luckily, there's already a plugin for exactly this! I found Moments Recorder and have used it in my own project already and the quality is great. Key features:

• Runs a constant buffer so hitting a button exports the last x seconds, which is ideal for catching hard-to-reproduce bugs
• Encoding runs in a separate thread, so it shouldn't affect your framerate much
• Customizable resolution/quality, so you can reduce resolution or thread priority if it's slowing things down
• Well-commented source code makes it easy to modify

My project was very poorly coded at the time and barely made 15fps, with randomized colors that are terrible for GIF encoding, but I saw no major additional slowdown when exporting a GIF. I should note the comments in the code for GIF encoding do say it could tank the framerate for high resolution, but if you find that's the case, then it gives plenty of options to play with to speed things up. Otherwise you can try to modify it to just export jpgs.

Here's an example of it in my editor:

The moments recorder uses System.Threading, but you could also look into the Unity Jobs system for multithreading your own solution, which could potentially be safer/faster/easier. I haven't tried it, and it's still in preview, so it may still be slower. Either way, it's a good example of how to separate out the capturing/saving code if you write your own solution.

Also, if you want to record video clips while in the editor, Unity has an official Asset Store plugin for that.

## Capturing screenshots in LWRP

This is a huge pain in the ass and I've been looking through solutions for a while. I'm still learning this stuff so I may have missed an obvious or easier solution. Also, all my testing has been very haphazard so I may be mixing up solutions and results, and I've crashed Unity a few times. Follow at your own risk.

Option 1 You said ScreenCapture.CaptureScreenshot() was taking 200ms, but have you tried CaptureScreenshotAsTexture()? It seems like that should be a lot faster and you could split off the file conversion/writing into a separate thread. I tried testing this both by modifying the Moments Recorder.cs and in a separate simple script, but I'm not getting any screenshot output at all and no errors, so I'm not sure what's going on there. If that method is working for you, that could be the fastest/easiest solution.

Option 2: This thread shows a way to capture an image from a camera in the new render pipelines, but the script linked doesn't show where/how it's called. Another post in the replies uses RenderPipeline.beginCameraRendering, so I modified the Moments recorder to use this callback and replaced the OnRenderImage method, but calling it at the beginning of camera rendering gives inconsistent/unhelpful results. It looks like it's moved out of experimental and a endCameraRendering event is added in 2019.1, but I don't have time to upgrade and test it. That might be the ideal solution. To do that with Moments, change the OnRenderImage() method in Recorder.cs to the following:

void CaptureCamera(Camera _camera)
{
if (State != RecorderState.Recording)
{
return;
}

m_Time += Time.unscaledDeltaTime;

if (m_Time >= m_TimePerFrame)
{
// Limit the amount of frames stored in memory
if (m_Frames.Count >= m_MaxFrameCount)
m_RecycledRenderTexture = m_Frames.Dequeue();

m_Time -= m_TimePerFrame;

// Frame data
RenderTexture rt = m_RecycledRenderTexture;
m_RecycledRenderTexture = null;

if (rt == null)
{
rt = new RenderTexture(m_Width, m_Height, 0, RenderTextureFormat.ARGB32);
rt.wrapMode = TextureWrapMode.Clamp;
rt.filterMode = FilterMode.Bilinear;
rt.anisoLevel = 0;
}

_camera.targetTexture = rt;
_camera.Render();
_camera.targetTexture = null;

m_Frames.Enqueue(rt);
}
}

Then add this in Init()

cam = GetComponent<Camera>(); //don't forget to create the cam var somewhere
RenderPipeline.EndCameraRendering(GetComponent<Camera>());
RenderPipeline.endCameraRendering += CaptureCamera;

Option 3: works in 2018.3, easy but weird results If you can't upgrade to 2019.x then this might work. I got this version working, but the resulting gif is washed out for some reason. Possibly shaders aren't being applied, not sure.

Modifying Recorder.cs in Moments, rename OnRenderImage to Update() or LateUpdate() and get rid of all the Graphics.Blit calls. Then at the end just throw this in:

Graphics.Blit(ScreenCapture.CaptureScreenshotAsTexture(), rt);
m_Frames.Enqueue(rt);

• That looks perfect! This solves the issue I was having with the ffmpeg project I found. That is: a constant buffer that can be written to a file on demand. Just one thing tho, does it support LWRP? Also any chance of exporting as MP4 instead of gif? – mr-matt Mar 26 '19 at 7:07
• You'd have to find an encoder script and I don't think mp4 would be quite as easy as a gif due to the way video compression works, but I don't know, I've never tried! It should definitely work with LWRP, I'm in the process of upgrading my project right now and I needed similar code for my own issue. – Appleguysnake Mar 26 '19 at 11:03
• It looks like I may have misled you. This list says OnRenderImage is "Not Supported" in LWRP, but is in the new built-in render pipeline (which is what was giving me issues, so I got them mixed up, sorry) github.com/Unity-Technologies/ScriptableRenderPipeline/blob/… – Appleguysnake Mar 26 '19 at 11:53
• I have just tested it, I can confirm it does not work with LWRP. The FFmpeg one I found does work with LWRP though. Any ideas on how to make ffmpeg use a constant buffer like moments? – mr-matt Mar 26 '19 at 18:46
• That depends, how does ffmpeg grab the image? That's really the source of the problem here since the rest can be done asynchronously in a separate thread. I found this guide to writing post-processing effects with Command Buffers instead of OnRenderImage, but it seems a lot more complicated so I haven't been able to go through it yet github.com/Unity-Technologies/PostProcessing/wiki/… – Appleguysnake Mar 27 '19 at 2:42

I found a github repo that can export mp4s using ffmpeg at runtime: https://github.com/keijiro/FFmpegOut

I had to make some modifications to make it save the last few seconds on demand, instead of a continuous recording. Specifically:

• Don't send each frame to the FFmpeg binaries as they come. Instead, save them in memory until further notice.
• Have a max number of frames to be saved in memory. When this number is exceeded, remove the oldest saved frame. (I actually calculated the approximate memory usage per frame and used this to dynamically set the max number of frames based on the max amount of ram I can budget to the recorder)
• When it's time to export the last few seconds of gameplay, send the entire queue to FFmpeg all at once. By this time, all the data is in a byte array already and so it can be multithreaded - important to ensure the main thread isn't blocked.

The final result of this was a steady 150 fps while recording at 1080p.

• I was pushing frames to ffmpeg using a bg thread as soon as I had them and that was causing me having horrible framerates and huge files, making me think my computer was not powerful enough. Doing what @mr-matt said, sending several frames to ffmpeg in one go, made recording the gameplay possible and super cheap. I'm now using a double buffer of 250MB each, one gets filled by frames from the main thread and the other gets written to ffmpeg from a bg thread. When the main thread fills its buffer I wait for the bg thread (that is always instant), swap both buffers and signal the bg thread. – Forestrf Mar 5 at 0:30
• For someone reading this, ffmpeg wasn't enough quality in realtime for my underpowered computer. Using libjpeg-turbo to export frames in jpg to later be compressed by ffmpeg resulted in faster encoding times during gameplay and videos with better quality in expense of temporary disk space. – Forestrf Jul 16 at 3:34
• Can you post the code you have, i would actually pay you – bluejayke 11 hours ago

You should look into https://docs.unity3d.com/ScriptReference/Graphics.Blit.html.

Graphics.Blit is unity's API for copying from one texture to another. If you render your scene into a render texture (Which I assume the lightweight pipeline can do, correct me if I'm wrong), then blit that render texture using the scriptable pipeline API. Then render the render texture to the screen. And as crueltear has said save processing for another thread.

• The problem is, to get data out of a render texture and into a jpg, I have to call ReadPixels() and EncodeToJpg(), both of which are ludicrously slow. To make things worse, none of unity is thread safe. So the only thing I can put on another thread is File.WriteAllBytes(), but that was always pretty fast anyway... – mr-matt Mar 25 '19 at 16:41
• @mr-matt remember you're not limited to Unity's methods here. You could use an external image compression library offered as source code, linked as a plugin, or sold as an Asset Store download, and run that on a thread of your choosing. – DMGregory Mar 25 '19 at 17:41
• @DMGregory Something to consider for sure, however, have a look at the performance metrics I took, I added them to the original question. ReadPixels was by far the slowest part, so even if I could shave the encoding down to 15ms, I would still be stuck with 40-70ms for reading the pixels from the screen. From what I could see, there is no way around ReadPixels. Even if I could asynchronously read the screen from the GPU with ASyncGpuReadback, command buffers or some SRP magic, I would still have to convert the RenderTexture to a Texture2D. – mr-matt Mar 25 '19 at 18:23
• The timing with which you call ReadPixels can be a factor, since part of the time taken could be waiting for a pipeline flush. Waiting until a moment when the GPU isn't busy may reduce this. Also, have you looked at reading just part of the render texture at a time? I'd be interested to see how much of the time is data transfer vs how much is waiting to sync. – DMGregory Mar 25 '19 at 18:26
• I just tested it with different resolutions. It's pretty clear that it scales with resolution. 50x50px was 2ms, 720p was 20ms, 1080p was 50ms, 2880x1800 (MBP) was 110ms, and 4k was 170ms. – mr-matt Mar 25 '19 at 18:41

My response is based on taking screenshots in pure C++/OpenGL - I have no experience with Unity.

Most of the time needed for screenshots is for compression and saving the image.

Reducing the quality of saved image should decrease the time. Another option is to grab the screen pixels, and let another thread do the compression and saving.

If we're not speaking about 4K resolution, saving raw (BMP) images should be faster than JPEG/PNG (unless you're writing to a floppy).

Update: I took a look into Unity's API. If I were to add screenshot feature to Unity game, it would probably look like that:

2. Launch separate thread (is it possible?)

Screenshots in C++ (SFML):

// Create texture
sf::Texture texture;
texture.create(windowSize.x, windowSize.y);
// Move window's pixels to texture
texture.update(window);
// VRAM -> RAM
sf::Image screenshot=texture.copyToImage();
// Encode+save to HDD
screenshot.saveToFile(ss.str().c_str());

• What platforms would this support? And can you provide any examples? I have very little experience in cpp so I wouldn't really know where to start. – mr-matt Mar 25 '19 at 16:44
• On another note, if I did this, can I target a specific window and only that window? I would be a bit concerned about the players privacy if it captures the whole screen even when the game is in windowed mode. – mr-matt Mar 25 '19 at 16:46

format: plain


text:
48 Answered Questions for the topic Help On Homework

#### Write an equation (a) in slope-intercept form and (b) in standard form for the line passing through (−3,6) and parallel to x+2y=5.

I need help finding them in slope - intercept form and standard form. I am lost and I do not understand how to do this problem.
Help On Homework

09/21/18

#### how to convert a decimal that is more than 10 in front of decimal

Convert 99.5% into a fraction or mixed number.
Help On Homework

09/18/18

#### 0.215278 inches to the nearest tenth

how to find 0.215278 inches to the nearest tenth
Help On Homework

09/13/18

#### At the assembly line joe is able to pack 150 of books in one hour. At this rate how many complete boxes can joe pack per minute

At the assembly line joe is able to pack 150 of books in one hour. At this rate how many complete boxes can joe pack per minute
Help On Homework Algebra 1 Algebra Word Problem

09/11/18

#### Write an absolute value equation that has these minimum and maximum lengths as its solutions.

in a songwriting competitio, the minimum length of a song is 2.5 minutes. The maximum length of a song is 5.5 minutes. Write an absolute value equation that has these minimum and maximum lengths as... more
Help On Homework

08/30/18

#### what is y=8x-3 simplified

can i get it in slope intercept form
Help On Homework

08/22/18

#### Prime numbers

The final four digits consist of three primes in ascending order surrounding a composite number in the second to last position. These four digits have a product of 336

#### Exponential Functions help

Radon-222 decays at a continuous rate of 17.3% per day. How much will 500 mg of Radon-222 decay to in 10 days?   So____?_____ mg of Radon-222 will remain. (Round answer to 5 decimal places)
Help On Homework

07/30/18

#### The consecutive integers is l, and the greatest is g.what is the value of l+g/2 in terms of l?

I'm not sure on how to solve this question. Can I please get help!?!
Help On Homework

07/07/18

#### A rectangular room is 7 meters longer than it is wide, and its perimeter is 46 meters.

A rectangular room is 7 meters longer than it is wide, and its perimeter is 46 meters.

#### how do you put y=-4/6x-2 in standard form?

would the negative sign go with the numerator or denominator when you multiply all the terms by the denominator
Help On Homework

04/25/18

#### The orca whale is one of the few species of whales that actually comes on shore.

The orca whale is one of the few species of whales that actually comes on shore.

04/13/18

Help On Homework

04/11/18

#### A rectangular garden is 12 meters by 20 meters.

A rectangular garden is 12 meters by 20 meters. Ts is to be doubled in area by adding a strip of uniform width to the top, right side and left side only. Find the width of the strip.
Help On Homework

04/04/18

#### Original length=7 inches, scale factor=225%

I need help with it
Help On Homework

03/16/18

#### word problem,

A dog trainer has 92 ft of fencing that will be used to create a rectangular work area for dogs. If the trainer wants to enclose an area of 304 ft2, what will be the dimensions of the work area?

03/01/18

Carlo wants to use a rain gauge to measure the amount of water his lawn is receiving from the sprinklers.Which rate is appropriate for describing the amount of water in this context? millimeters... more
Help On Homework

01/25/18

#### what messege was washington trying to convey when he warned against the spirit of political parties

i need help please its a test help
Help On Homework Math Math Help Helping Others

01/18/18

#### What is the function notation and the meaning behind this equation

Tevin‘s total cost for his party is calculated by the following equation :                         T = 35p + 250      where T is the total cost and p is the amount of people attending.   A.... more
Help On Homework

01/18/18

#### What is Twelve more than negative three times a number is equal to eight times the number minus ten

I don't know and need your help
Help On Homework

01/03/18

#### Perform the following operation and express the answer in scientific notation.

3.60x10^-12 + 3.60x10^-11
Help On Homework

12/17/17


text:
# 11. For Loops¶

In the last chapter, we added the if statement to our skill set, enabling the computer to choose which set of code to run. In this chapter we learn how to loop. Rather than have our programs run straight though, we can run a section of code however many times we like.

This chapter covers for loops which allow us to loop a certain number of times. The next chapter covers while loops which will loop until a certain condition (such as game over) occurs.

## 11.1. Introduction to Looping¶

Most games loop. Most programs of any kind loop. Take for example a simple number guessing game. The computer thinks of a number from 1 to 100, and the player tries to guess it.

This is an easy game to program on the computer using loops. Start with code that will take in a guess from the user, and then tell the user if they are too high, too low, or correct using the if statements we learned about in the last chapter. Then, we just need to loop that code until the user guess correctly, or runs out of guesses.

Here’s an example run of just such a program:

Hi! I'm thinking of a random number between 1 and 100.
--- Attempt 1
Guess what number I am thinking of: 50
Too high.
--- Attempt 2
Guess what number I am thinking of: 25
Too high.
--- Attempt 3
Guess what number I am thinking of: 17
Too high.
--- Attempt 4
Guess what number I am thinking of: 9
Too low.
--- Attempt 5
Guess what number I am thinking of: 14
Too high.
--- Attempt 6
Guess what number I am thinking of: 12
Too high.
--- Attempt 7
Guess what number I am thinking of: 10
Too low.
Aw, you ran out of tries. The number was 11.

(The code for this program: Number Guessing Game Example)

Wait, what does this simple text game have to do with advanced graphical games? A lot. You may be familiar with the frames-per-second (FPS) statistic that games show. The FPS represents the number of times the computer updates the screen each second. Each frame in a video game is one time through a loop. The higher the rate, the smoother the game. (Although an FPS rate past 60 is faster than most screens can update, so there’s not much point to go faster.) The figure below shows the game Eve Online and a graph showing how many frames per second the computer displaying.

FPS in video games

The loop in these games works like the flowchart this figure:

Game loop

The inside of these loops have three common steps:

1. Get user input.

2. Perform calculations.

3. Output the result.

Then we loop this 60 times per second until the user asks to close the program.

There can even be loops inside of loops. Take a look at the “Draw Everything Loop” flowchart below. This set of code loops through and draws each object in the game. You can put this loop inside the larger loop that draws each frame of the game.

Draw Everything Loop

There are two major types of loops in Python, for loops and while loops. If you want to repeat a certain number of times, use a for loop. If you want to repeat until something happens (like the user hits the quit button) then use a while loop.

For example, a for loop can be used to print all student records, since the computer knows how many students there are. We could wait for the user to click the mouse button with a while loop, because we don’t know how many times we’ll have to loop before that happens.

## 11.2. For Loops¶

This for loop example runs the print statement five times. It could just as easily run 100 or 1,000,000 times by changing the 5 to the desired number. Note the similarities of how the for loop is written to the if statement. Both end in a colon, and both use indentation to specify which lines are affected by the statement.

Loop to print five times
1for i in range(5):
2    print("I will not chew gum in class.")

Go ahead and enter it into the computer. You should get output like this. Try adjusting the number of times that it loops.

I will not chew gum in class.
I will not chew gum in class.
I will not chew gum in class.
I will not chew gum in class.
I will not chew gum in class.

The i on line 1 is a variable that keeps track of how many times the program has looped, sometimes called the counter variable. It is a regular variable, and can be named any legal variable name. Programmers sometimes use i as for the variable name, because the i is short for increment and that’s often what the variable does. This variable helps track when the loop should end.

The range function controls how many times the code in the loop is run. In this case, five times.

The next example code will print “Please,” five times and “Can I go to the mall?” only once. “Can I go to the mall?” is not indented so it is not part of the for loop and will not print until the for loop completes.

1for i in range(5):
3print("Can I go to the mall?")

Go ahead and enter the code and verify its output.

Please,
Can I go to the mall?

This next code example takes the prior example and indents line 3. This change will cause the program to print both “Please,” and “Can I go to the mall?” five times. Since the statement has been indented “Can I go to the mall?” is now part of the for loop and will repeat five times just like the word “Please,”.

1for i in range(5):
3    print("Can I go to the mall?")

Here’s the output of that program:

Please,
Can I go to the mall?
Can I go to the mall?
Can I go to the mall?
Can I go to the mall?
Can I go to the mall?

You aren’t stuck using a specific number with the range function. This next example asks the user how many times to print using the input function we talked about last chapter in The input Function. Go ahead and try the program out.

Loop according to the user input
1# Ask the user how many times to print
2repetitions = int(input("How many times should I repeat? "))
3
4# Loop that many times
5for i in range(repetitions):
6    print("I will not chew gum in class.")

You could also use what we learned about functions, and take in the value by a parameter as shown in this example:

Loop according to a function parameter
 1def print_about_gum(repetitions):
2
3    # Loop that many times
4    for i in range(repetitions):
5        print("I will not chew gum in class.")
6
7
8def main():
10
11
12main()

### 11.2.1. Using the Counter Variable¶

You can use the counter variable in the for loop to track your loop. Try running this code, which prints the value stored in i.

Print the numbers 0 to 9
1for i in range(10):
2    print(i)

With a range of 10, you might expect that the code prints the numbers 1 to 10. It doesn’t. It prints the numbers 0 to 9. It is natural to assume that range(10) would include 10, but it doesn’t.

0
1
2
3
4
5
6
7
8
9

In computer programming, we typically start counting at zero rather than one. Most computer languages use this convention. An old computer joke is to get your friend a mug that says “World’s #1 programmer.” Then get yourself a mug that says “World’s #0 programmer.”

If a programmer wants to go from 1 to 10 instead of 0 to 9, there are a couple ways to do it. The first way is to send the range function two numbers instead of one. The first number is the starting value, the second value we’ll count up to, but not equal to. Here’s an example:

Print the numbers 1 to 10, version 1
1for i in range(1, 11):
2    print(i)

Give it a try. It should print the numbers 1 to 10 like so.

1
2
3
4
5
6
7
8
9
10

It does take some practice to get used to the idea that the for loop will include the first number, but will not include the second. The example specifies a range of (1, 11), and the numbers 1 to 10 are printed. The starting number 1 is included, but not the ending number of 11.

Another way to print the numbers 1 to 10 is to still use range(10) and have the variable i go from 0 to 9. But just before printing out the variable, add one to it. This also works to print the numbers 1 to 10, as shown in our next example.

Print the numbers 1 to 10, version 2
1# Print the numbers 1 to 10.
2for i in range(10):
3    # Add one to i, just before printing
4    print(i + 1)

### 11.2.2. Counting By Numbers Other Than One¶

If the program needs to count by 2’s or use some other increment, that is easy. Just like before there are two ways to do it. The easiest is to supply a third number to the range function that tells it to count by 2’s. See this code example:

1# One way to print the even numbers 2 to 10
2for i in range(2, 12, 2):
3    print(i)

The second way to do it is to go ahead and count by 1’s, but multiply the variable by 2 as shown in the next example.

1# Another way to print the numbers 2 to 10
2for i in range(5):
3    print((i + 1) * 2)

Both examples will output the numbers 2 to 10:

2
4
6
8
10

It is also possible to count backwards–for example 10 down to zero. This is done by giving the range function a negative step. In the example below we start at 10 and go down to, but not including, zero. (To include zero, the second number would need to be a -1.) We do this by an increment of -1.

Count down from 10 to 1
1for i in range(10, 0, -1):
2    print(i)

The hardest part of creating these backwards-counting loops is to accidentally switch the start and end numbers. Normal for loops that count up start with the smallest value. When you count down the program starts at the largest value.

Output:

10
9
8
7
6
5
4
3
2
1

If the numbers that a program needs to iterate through don’t form an easy pattern, it is possible to pull numbers out of a list as shown in the next example. A full discussion of lists will be covered in the Introduction to Lists chapter.

Print numbers out of a list
1for item in [2, 6, 4, 2, 4, 6, 7, 4]:
2    print(item)

This prints:

2
6
4
2
4
6
7
4

## 11.3. Nesting Loops¶

By nesting one loop inside another loop, we can expand our processing beyond one dimension.

Try to predict what the following code, which is not nested, will print. Then enter the code and see if you are correct.

1# What does this print? Why?
2for i in range(3):
3    print("a")
4for j in range(3):
5    print("b")

Did you guess right? It will print three a’s and 3 b’s.

This next block of code is almost identical to the one above. The second for loop has been indented one tab stop so that it is now nested inside of the first for loop. It is a nested loop. This changes how the code runs significantly. Look at it and see if you can guess how the output will change.

1# What does this print? Why?
2for i in range(3):
3    print("a")
4    for j in range(3):
5        print("b")
6
7print("Done")

Did you guess right? We still get three a’s, but now we get nine b’s. For each a, we get three b’s. The outside for loop causes the inside code to be run three times. The inside for loop causes its code to be run three times, so three times three is a total of nine times to run the innermost code.

Complicated? Not really. You’ve already lived a loop like this. This is how a clock works. The 1-12 hour is the outside loop, and the 0-59 minute is the inside loop. Try this next example and see now it prints all the times between 1:00 and 12:59. (Later on in Clock Example with Leading Zeros we’ll show how to format the output and make it look good.)

1# Loop from 1:00 to 12:59
2for hour in range(1, 13):
3    for minute in range(60):
4        print(hour, minute)

## 11.4. Keep a Running Total¶

A common operation in working with loops is to keep a running total. This “running total” code pattern is used a lot in this book. Keep a running total of a score, total a person’s account transactions, use a total to find an average, etc. You might want to bookmark this code listing because we’ll refer back to it several times. In the code below, the user enters five numbers and the code totals up their values.

Keep a Running Total
1total = 0
2for i in range(5):
3    new_number = int(input("Enter a number: " ))
4    total = total + new_number
5print("The total is: ", total)

Note that line 1 creates the variable total, and sets it to an initial amount of zero. It is easy to forget the need to create and initialize the variable to zero. Without it the computer will complain when it hits line 4. It doesn’t know how to add new_number to total because total hasn’t been given a value yet.

A common mistake is to use i to total instead of new_number. Remember, we are keeping a running total of the values entered by the user, not a running total of the current loop count.

Speaking of the current loop count, we can use the loop count value to solve some mathematical operations. For example check out this summation equation:

$s=\sum\limits_{n=1}^{100}n$

If you aren’t familiar with this type of formula, it is just a fancy way of stating this addition problem:

$s=1+2+3+4+5 \ldots 98+99+100$

The code below finds the answer to this equation by adding all the numbers from 1 to 100. It is another demonstration of a running total is kept inside of a loop.

Sum all numbers 1 to 100
1# What is the value of sum?
2total = 0
3for i in range(1, 101):
4    total = total + i
5print(total)

Here’s yet another example of keeping a running total. In this case we add in an if statement. We take five numbers from the user and count the number of times the user enters a zero:

1total = 0
2for i in range(5):
3    new_number = int(input( "Enter a number: "))
4    if new_number == 0:
5        total += 1
6print("You entered a total of", total, "zeros")

## 11.5. Review¶

In this chapter we talked about looping and how to use for loops to count up or down by any number. We learned how loops can be nested. We learned how we can use a loop to keep a running total.

### 11.5.1. Review Questions¶

Open up an empty file and practice writing code that use for loops to:

1. Print “Hi” 10 times.

2. Print ‘Hello’ 5 times and ‘There’ once

3. Print ‘Hello’ and ‘There’ 5 times, on different lines

4. Print the numbers 0 to 9

5. Two ways to print the numbers 1 to 10

6. Two ways to print the even numbers 2 to 10

7. Count down from 10 down to 1 (not zero)

8. Print numbers out of a list

1. What does this print? Why?

for i in range(3):
print("a")
for j in range(3):
print("b")

1. What is the value of a?

a = 0
for i in range(10):
a = a + 1
print(a)

1. What is the value of a?

a = 0
for i in range(10):
a = a + 1
for j in range(10):
a = a + 1
print(a)

1. What is the value of a?

a = 0
for i in range(10):
a = a + 1
for j in range(10):
a = a + 1
print(a)

1. What is the value of sum?

total = 0
for i in range(1, 101):
total = total + i

### 11.5.2. On-line Review Problems¶

Practice on-line by completing the for loop problems starting with 04 available here:

https://repl.it/community/classrooms/174286


text:
# by default, the normal style places ____ points of blank space after each paragraph.

S
9.9k points

<

table class="table table-hover">

On the works cited page, list works by each authors last name and _____ the title of the workitalicize or underlineWhen using the MLA style, position explanatory notes either at the _____,bottom of the page as footnotes or at the end of the paper as endnotesA note reference mark signals that an explanatory note exists at the bottom of the page as a ____.footnoteThe shortcut keys for the _____ character formatting are CTRL+SHIFT+PLUS SIGN.superscriptTo increase a paragraph indent, use the _____ shortcut keys.CTRL+MEach time the _____ key is pressed, the paragraph formatting in the previous paragraph is carried forward to the next paragraph.ENTERWord has a list of predefined typing, spelling, capitalization, and grammar errors that _____ can detect and correct.AutoCorrectTo select a block of text, click at the beginning of the selection, scroll to the end of the selection, position the mouse pointer at the end of the selection, hold down the ____SHIFTWhen the same word is used in multiple locations or a word is used that was not quite appropriate, a thesaurus can be used to look up a(n) _____, or a word similar in meaning.synonymBy default, the Normal style places ____ points of blank space after each paragraph.10By default, the Normal style inserts a vertical space equal to ____ line(s) between each line of text.1.15The shortcut keys used to left-align a paragraph are ____.CTRL+LThe shortcut keys used to center a paragraph are ____.CTRL+ETo decrease a font size, use the ____ shortcut keys.CTRL+SHIFT+
by default
studybud

Surround your text in *italics* or **bold**, to write a math equation use, for example, $x^2+2x+1=0$ or $$\beta^2-1=0$$

Use LaTeX to type formulas and markdown to format text. See example.


text:
# http://colinraffel.com/wiki/

### Site Tools

columbia_ee_dqe_practice_exams

# Columbia EE DQE Practice Exams

This page contains possible answers for the 2008-2010 DQEs, which were sent out for practice for the 2012 exam. Please note that these answers may be incorrect and/or incomplete; no answer key was provided.

## 2008

### Signals, Systems, and Communications

#### Problem 1

a) The difference equation is $y[n] = x[n] - x[n - 4]$ with impulse response $h[n] = \delta[n] - \delta[n-4]$. This corresponds to a transfer function of $H(z) = 1 - z^{-4}$. The magnitude will approach zero when $1 = z^{-4}$ (the zeros). This will occur at $z = e^0, e^{\pm 2\pi/4}, e^{\pm \pi}, e^{\pm 6\pi/4}, \ldots$. The transfer function will approach infinity as $z \rightarrow 0$, so there is a fourth-order pole at $z = 0$. When $z = e^{\pm (2n + 1) \pi/4}, n = 0, 1, 2, \ldots$, $z^{-4} = j$. So, $|H(e^{j\omega})|$ will be 1 at these points and 0 at the zeros. The frequency response will look like a full-wave rectified sine wave with period $\pi$.

b) The phase will jump from $-\pi$ to $\pi$ at each zero. At $z = e^{\pm (2n + 1) \pi/4}, n = 0, 1, 2, \ldots$, $H(z) = 1 - e^{\pm(2n + 1)} \rightarrow \angle H(z) = 0$. So, the phase will look like a sawtooth wave with period $\pi/2$, starting at $\pi$ and sloping linearly to $-\pi$ at $\pi/2$.

c) Any signals which are 4-sample periodic, i.e., $x[n] = x[n-4]$.

d) The difference equation is $y[n] = x[n] + \frac{4}{5}x[n - 4]$ with impulse response $h[n] = \delta[n] + \frac{4}{5}\delta[n-4]$. This corresponds to a transfer function of $H(z) = 1 + \frac{4}{5}z^{-4} = (z^2 + \frac{2i}{\sqrt{5}})(z^2 - \frac{2i}{\sqrt{5}})$$= (z - \frac{1-i}{\sqrt[4]{5}})(z + \frac{1-i}{\sqrt[4]{5}})(z - \frac{i-1}{\sqrt[4]{5}})(z - \frac{i-1}{\sqrt[4]{5}})$. These four zeros will have magnitude $\frac{\sqrt{2}}{\sqrt[4]{5}}$ and phase $\pi/4, 3\pi/4, 5\pi/4, 7\pi/4$. This system will be zero for signals where $x[n] = -\frac{4}{5}x[n-4]$. These signals will oscillate with a period of 4 samples and exponentially decay by a factor of $4/5$ each period.

#### Problem 3

(1) $\phi(t) = f_1(t)\cos(\omega_c t) + f_2(t)\sin(\omega_c t)$. If the communications channel has an impulse response $h(t)$, then we have $g_1(t) = (h(t)\ast\phi(t))\cos(\omega_ct) = h(t)\ast f_1(t)\cos^2(\omega_c t) + h(t)\ast f_2(t)\sin(\omega_c t)\cos(\omega_c t)$. Similarly, $g_2(t) = h(t)\ast f_2(t)\sin^2(\omega_c t) + h(t)\ast f_1(t)\cos(\omega_c t)\sin(\omega_c t)$

(2) Taking Fourier transforms:

$\mathcal{F}$f_1(t)$ = F_1(t)$, $\mathcal{F}$f_2(t)$ = F_2(t)$

$\mathcal{F}$\cos(\omega_c t)$ = \sqrt{\frac{\pi}{2}}(\delta(\omega - \omega_c) + \delta(\omega + \omega_c))$

$\mathcal{F}$\cos(\omega_c t)\cos(\omega_c t)$ = \mathcal{F}$\cos(\omega_c t)$\ast\mathcal{F}$\cos(\omega_c t)$$$= \frac{\pi}{2}(2\delta(\omega) + \delta(\omega + 2\omega_c) + \delta(\omega - 2\omega_c))$

$\mathcal{F}$\sin(\omega_c t)$ = j\sqrt{\frac{\pi}{2}}(\delta(\omega - \omega_c) - \delta(\omega + \omega_c))$

$\mathcal{F}$\sin(\omega_c t)\sin(\omega_c t)$ = \mathcal{F}$\sin(\omega_c t)$\ast\mathcal{F}$\sin(\omega_c t)$$$= \frac{-\pi}{2}(2\delta(\omega) - \delta(\omega + 2\omega_c) - \delta(\omega - 2\omega_c))$

$\mathcal{F}$\sin(\omega_c t)\cos(\omega_c t)$ = \mathcal{F}$\sin(\omega_c t)$\ast\mathcal{F}$\cos(\omega_c t)$$$= \frac{\pi j}{2}(- \delta(\omega + 2\omega_c) + \delta(\omega - 2\omega_c))$

Given this derivation, the equations derived above (for example $g_2(t) = h(t)\ast f_2(t)\sin^2(\omega_c t) + h(t)\ast f_1(t)\cos(\omega_c t)\sin(\omega_c t)$) indicate that the input to each filter will be the corresponding system input, convolved in the frequency domain by either $\sin^2$ or $\cos^2$ and $\sin\cos$. The former frequency-domain convolutions will result in a baseband signal in the filter input (due to the $\delta(\omega)$ term in the $\cos^2$ and $\sin^2$ Fourier transforms), while the latter will not. As a result, because $\omega_c \gg \omega_0$ (the signal bandwidth), the baseband signal will be isolated. The resulting outputs, then, will be proportional to $h(t)\ast f_1(t)$ and $h(t)\ast f_2(t)$.

(3) I don't know the terms “constellation and decision diagrams” or “symbol error probability expression”.

### Digital Computing Systems

#### Problem 1

1. (a) $11\bar{1}0.\bar{1}\bar{1} = 27 + 9 - 3 + 0 - \frac{1}{3} - \frac{1}{9} = 32 \frac{5}{9}$

(b) $\bar{1}\bar{1}10.11 = -27 - 9 + 3 + 0 + \frac{1}{3} + \frac{1}{9} = -32 \frac{5}{9}$

© $\bar{1}\bar{1}10 = -27 - 9 + 3 + 0 = -33$

(d) $0.1111\ldots = \frac{1}{3} + \frac{1}{9} + \frac{1}{27} + \ldots = \sum_{n=1}^{\infty}\left(\frac{1}{3}\right)^n = \frac{1}{3}\frac{1}{1 - \frac{1}{3}} = \frac{1}{2}$

(e) $10\bar{1}\bar{1}01.10\bar{1}010\bar{1}010\bar{1}0\ldots =$$243 + 0 - 27 - 9 + 0 + 1 + \frac{1}{3} + 0 - \frac{1}{27} + 0 + \frac{1}{243} + 0 + \ldots =$$208 + \frac{1}{3}\sum_{n=1}^{\infty}\left(\frac{1}{9}\right)^n = 208 \frac{3}{8}$

2. (a) $1\bar{1}0\bar{1} + 1\bar{1}0\bar{1} = (27 - 9 + 0 - 1) + (27 - 9 + 0 - 1) = 34 = 11\bar{1}1$

(b) $1\bar{1}0\bar{1} - \bar{1}110 = (27 - 9 + 0 - 1) - (-27 + 9 + 3 + 0) = 17 - (-15) = 32 = 11\bar{1}\bar{1}$

© $1\bar{1}0\bar{1} \ctimes 1\bar{1}0\bar{1} = (27 - 9 + 0 - 1)\ctimes(27 - 9 + 0 - 1) = 289 = 11\bar{1}\bar{1}01$

3. If the leftmost nonzero digit is 1, it's positive, otherwise, it's negative, because $3^n > \sum_{m = 0}^{n-1} 3^m$

4. All nonzero digits should switch sign - this corresponds to flipping all of the signs in the nonzero terms of the sum corresponding to its base-10 representation, thereby negating it.

#### Problem 3

##### Part 1

a) Truth table:

A B C D Y
0 0 0 0 1
0 0 0 1 1
0 0 1 0 1
0 0 1 1 1
0 1 0 0 0
0 1 0 1 1
0 1 1 0 0
0 1 1 1 1
1 0 0 0 1
1 0 0 1 0
1 0 1 0 1
1 0 1 1 1
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0

$(A + \bar{B} + C + D)(A + \bar{B} + \bar{C} + D)(\bar{A} + B + C + \bar{D})(\bar{A} + \bar{B} + C + D)$$(\bar{A} + \bar{B} + C + \bar{D})(\bar{A} + \bar{B} + \bar{C} + D)(\bar{A} + \bar{B} + \bar{C} + \bar{D})$ This is not minimal form…

b) 2-input NOR gate truth table:

A B Y
0 0 1
0 1 1
1 0 1
1 1 0

An inverter can be made by tying the two inputs of the NAND gate together. An AND can be made by putting a NAND inverter at the output of a NAND. An OR can be made out of three NAND gates; gates A and B have their inputs tied together and take input, their outputs go to another NAND gate. Using these basic rules the function can be realized with 19 NAND gates (and maybe reduced some with some care).

c) Using the B, C, and D inputs as the input selection bits, the A input can be wired to every input optionally through an inverter. When the the output should be the opposite of A for some B, C, and D according to the truth table, an inverter should be used. Otherwise A should be connected directly to the corresponding multiplexer input.

##### Part 2

a) For each of the three levels of one input, there are three possible levels for the other input, resulting in nine possible input combinations.

b) For each pair of input levels, there are three possible output levels. There are nine possible input level pairings. This results in $3^9$ possible functions.

c) For each pair of input levels, there are two possible output levels. There are four possible input combinations, so there are $2^4$ possible functions.

## 2009

### Circuits and Electronics

#### Problem 2

* The op amp will work to make its inputs equal - in this case, this corresponds to setting the negative input to zero volts. Since $V_p = 0$, $V_{out} = A(0-V_m) = -999V_m$. Note that $V_1 = V_m$ because they are at the same node in the circuit. The current through the capacitor is expressed by $I_0 = C\frac{d(V_1-1V)}{dt}$ because it is connected to the 1V power supply. I'm stuck at this point.

#### Problem 3

(a) The first pair of pFET and nFET transistors serve as an inverter because when $V_{in}$ is low, the pFET will have 2.5V on its drain and the nFET will be high-impedance; when $V_{in}$is high, the nFET will have 0V on its drain and the pFET will be high-impedance. Similarly, for the second pair of FETs, when $V_{out}$ is low, the pFET will have 2.5V on its drain and the nFET will be low impedance, and when $V_{out}$ is high, the nFET will have 0V on its drain and the pFET will be high impedance. So, when $V_{in}$ is low, the output of the first pair of FETs will be high, and the inverter will set $V_{out}$ to low, which will cause the second pFET to also send 2.5V to the inverter input. Assuming the inverter switches from high to low at exactly 1.25V, as $V_{in}$ increases,

The Schmitt trigger is useful for signals which are to be used as logic signals but are not always exactly “high” or “low”. In other words, if a signal which is meant to be treated as a logic “low” actually has some fluctuation, the Schmitt trigger will “ignore” spurious high signals caused by fluctuations as long as they are less than the “on” threshold - and this threshold can be more forgiving in either direction. It essentially requires a more affirmative “high” or “low” to make the corresponding change on the output.

(b) If $V_T$ is 0.5V and -0.5V for the nFETs and pFETs respectively, then $I_{dst} = \frac{\beta}{2}(V_{gs} - 0.5V)$ and $I_{dst} = \frac{\beta}{2}(V_{sg} - 0.5V)$, respectively.

### Signals, Systems, and Communications

#### Problem 1

(a) The Nyquist frequency is twice the highest frequency present in $x(t)$, which corresponds to $250(2) = 500$ Hz.

(b) If the signal is sampled at $T = 1/f$, then sampling will be equivalent to convolving the frequency domain representation with an impulse train with period $2\pi f$. If $f$ is above the Nyquist limit (500 Hz), the convolution of each impulse with the spectrum doesn't overlap, and we can achieve perfect reconstruction for general signals with a lowpass filter at the Nyquist frequency. Because we are using a bandpass filter here, we can allow for aliasing that would cause non-perfect reconstruction with a lowpass filter. However, we must avoid having the copies of the bandlimited spectral slices overlap, or else we will not be able to reconstruct them from their sum. So, we seek a frequency $f$ such that the spectrum from $\pm 400\pi$ to $\pm 500\pi$ is maintained - the aliased terms cannot overlap in this range. The lowest sampling frequency for which this is true is 125 Hz. At this frequency, there is no overlap between convolutions of each of the impulses, although there is aliasing in the baseband (between $-500\pi$ and $500\pi$). However, if the bandpass filter is set with $\omega_1 = 400\pi$ and $\omega_2 = 500\pi$, then only the uncorrupted original signal will be maintained. The amplitude $A$ can be set to 1 because the spectral magnitude will be maintained.

#### Problem 3

(a) Assuming (without loss of generality) that $t$ is a discrete variable and $T$ is an even integer, we can compute the DTFT to determine the sun-of-sinusoid representation of $x(t)$: $X(\omega) = \sum_{n = -\infty}^{\infty}x(n)e^{-j\omega n}$. Defining $u_M(t) = 1, 0 \le t \le M; 0 \mathrm{\;otherwise}$, $U_M(\omega) = \sum_{n = -\infty}^{\infty}u_M(n)e^{-j\omega n} = \sum_{n=0}^M e^{-j\omega n}$. This is the sum of a geometric series, so we have $U_M(\omega) = \frac{1 - e^{-j\omega(M+1)}}{1 - e^{-j\omega}}$. Then $x(t) = \delta(t)\ast u_{T/2}(t) - \delta(t+T/2)\ast u_{T/2}(t) + \delta(t+T)\ast$$u_{T/2}(t) - \delta(t - T/2)\ast u_{T/2}(t) + \delta(t-T)\ast u_{T/2}(t) - \delta(t + 3T/2)\ast u_{T/2}(t) + …$$= u_{T/2}(t) + u_{T/2}(t) \ast \sum_{n=1}^{\infty} (-1)^n(\delta(t + nT/2) + \delta(t - nT/2))$ which has a Fourier transform $X(\omega) = U_{T/2}(\omega) + U_{T/2}(\omega)\sum_{n=1}^{\infty}(-1)^n (e^{j\omega nT/2} + e^{-j\omega nT/2})$.

I know, from memory, that the harmonic series of a square wave is proportional to the sum of a sinusoid at the fundamental frequency (here $1/T$) and scaled odd harmonics.

(b) When the delay corresponds to an integer multiple of the period of one of the harmonics, that harmonic will be canceled out. As a result, for very short delays, the energy will be close to the full signal energy, as only very high harmonics (low energy) will be canceled out. As the delay approaches the square wave period, the energy cancellation corresponding to this delay-period match up will become more drastic, until a period of $T$ is reached, at which point the signal will be fully cancelled out. After this point, the energy signal will be periodic, as the addition of a delay of one period will not affect the energy.

© Rather than having many “dips” in the energy plot corresponding to nulled harmonics, it would have dips were the delay was an integer multiple of each of the three harmonics (including the fundamental as the “zeroth” harmonic).

## 2010

### Circuits and Electronics

#### Problem 1

(Making all of the assumptions listed) As the input signal goes negative, $C_1$ will be charged. When the signal goes positive, $D_1$ will be reverse biased so $C_1$ will not be able ti discharge. $D_2$ then sees the input voltage in series with the voltage on $C_1$. This series voltage will charge $C_2$ towards twice the input voltage. After a few cycles, $C_2$ will be fully charged. The load on $V_{out}$ will discharge $C_2$ while $C_1$ is charging.

#### Problem 3

(a) The four-resistor ladder on the left is creating a series of nodes where the voltages are $3V_{dd}/4$, $2V_{dd}/4$, and $V_{dd}/4$. So, when $V_{in}$ is between $V_{dd}/4$ and $2V_{dd}/4$ (for example), the top two comparators will output a logical 0 because $V_{in} < 2V_{dd}/4 < 3V_{dd}/4$, but the bottom comparator will output a logical 1. This will cause the upper OR gate to output 0 and the lower OR gate to output a 1. This behavior is summarized (for $V_{dd} > 0$) for all input levels below ($C_1, C_2, C_3$ correspond to the output of the bottom, middle, and top comparators respectively).

$V_{in}$ $C_1$ $C_2$ $C_3$ $B_1$ $B_0$
$V_{in} < V_{dd}/4$ 0 0 0 0 0
$V_{dd}/4 < V_{in} < 2V_{dd}/4$ 1 0 0 0 1
$2V_{dd}/4 < V_{in} < 3V_{dd}/4$ 1 1 0 1 1
$3V_{dd}/4 < V_{in}$ 1 1 1 1 1

Note that because $C_3$ is only high when both $C_2$ and $C_1$ are high, $B_0$ and $B_1$ will already be high, so the output will not change once $V_{in} > 2V_{dd}/4$. However, when $V_{dd}$ is negative (which is in some ways a misnomer as $V_{dd}$ is normally used to denote the positive supply rail), the interpretation of the circuit changes as follows:

$V_{in}$ $C_1$ $C_2$ $C_3$ $B_1$ $B_0$
$V_{in} < 3V_{dd}/4$ 0 0 0 0 0
$3V_{dd}/4 < V_{in} < 2V_{dd}/4$ 0 0 1 1 1
$2V_{dd}/4 < V_{in} < V_{dd}/4$ 0 1 1 1 1
$V_{dd}/4 < V_{in}$ 1 1 1 1 1

The resistor ladder and comparators is pretty clearly a linear voltage level quantizer.

(b) I'm not sure why the outputs are connected to the OR gates in the way they are.

### Signals, Systems and Communications

#### Problem 1

1. If the system is causal, then $h[n] = 0, n < 0$. If it's stable, $\sum_{n=-\infty}^{\infty}|h[n]| < \infty$. Note that $C_{hh}[l] = C_{hh}[-l]$ because $C_{hh}[l] = \sum_{k=-\infty}^{\infty}h[k]h[k+l] = \sum_{m=-\infty}^{\infty}h[m-l]h[m] = C_{hh}[-l]$. For a simple case, say that we know that $h[0] = a, h[1] = b$ (this could be deduced when $C_{hh}[l] = 0, |l| > 1$). Then $C_{hh}[0] = a^2 + b^2, C_{hh}[1] = ab, C_{hh}[-1] = ba$. Substituting, we have $C_{hh}[0] = a^2 + \frac{C_hh[1]^2}{a^2} \rightarrow 0 = a^4 - C_{hh}[0]a^2 + C_hh[1]^2$. Note that this is a quadratic equation in which the variable itself is quadratic, so there will be four solutions. This serves as a counterexample - in general we cannot recover $h[n]$ from $C_{hh}$.

As another example, note that the inverse z-transform of the magnitude frequency response of the filter is $C_{hh}$ because $a\star a \rightarrow \bar{A}A$. In other words, only the magnitude response is specified. Given a filter with a certain magnitude response, it is possible to create another filter with the same magnitude response by cascading the original filter with an all-pass filter. As a result, the filter cannot be unique given only this information.

2. A system of this form is characterized by the difference equation $y[n] = x[n] + \sum_{k=1}^{N}a_k y[n-k]$ and has an infinite impulse response $h[k]$. Note that the system being stable implies that $|a_k| < 1$. For a simple case, assume $a_1 = b; a_k = 0, k > 1$. Then $h[n] = b^n$ and $C_{hh}[0] = \sum_{k=\infty}^{\infty}h[k]h[k] = \sum_{k=0}^{\infty}b^{2k} = \frac{1}{1 - b^2}$. This gives us an explicit formula for $a_1$ and thus all of $a_k$. If $a_1 = b; a_2 = c; a_k = 0, k > 2$, then $h[n] = 1, b, b^2 + c, b^3 + 2bc, b^4 + 3b^2c + c^2, b^5 + 4b^3c + 3bc^2, …$

#### Problem 3

a) For a simple first-pass, assume that $0 < \Delta < T$. If $\Delta = T/N$, then this sampling is equivalent to sampling the signal $x(t/N) = y(t)$ (in the figure, the signal is sampled with $\Delta = T/7$, which results in a signal with period $7T$). As proof, note that the samples will occur at $y(0) = x(0), y(1) = x(T + T/N) = x(T/N), y(2)$$= x(2T + 2T/N) = x(2T/N), \ldots$, and $y(N) = x(NT + NT/N) = x(T) = x(0)$. $y(t)$ repeats itself with a period of $N$. In other words, when $\Delta = T/N$, $a = 1/N =$


text:
## Thinking Mathematically (6th Edition)

The number of possible combinations if r items are taken from n items is nCr =$\frac{n!}{r!(n-r)!}$ The number of ways that six jokes can be ordered is: = 6C6 x 6! =$\frac{6!}{(6-6)!6!}$ x 6! =$\frac{6!}{6!}$ x 6! =1 x 6! = 720 ways


text:
# Revision history [back]

 sage: g=libgap.Group(map(lambda s: libgap.PermList(s.get_perm()), Gautgens))

will give you the underlying permutation group. It has 1 orbit in its natural action (on 8 points):

 sage: g.Orbits()
[ [ 1, 2, 5, 3, 6, 4, 7, 8 ] ]

You can convert it into a matrix group acting on GF(4)^8.

 sage: mg=libgap.Group(map(lambda s: libgap.PermutationMat(s,8,libgap.GF(4)), g.GeneratorsOfGroup()))

Now you can compute orbits on vectors (see e.g. code in graphs/generators/classical_geometries.py for details); however, you might want to make sure that GAP's GF(4) is created in a compatible way.


text:
## anonymous one year ago An equation and the steps to solve it are shown below: 3x 1/2 (8x - 2) = 4 Step 1: 3x - 4x + 1 = 4 Step 2: x + 1 = 4 Step 3: x + 1 - 1 = 4 - 1 Step 4: x = 3 Which step was the error made and why? (1 point) Question 19 options: 1) Step 1, because incorrect signs have been used 2) Step 2, because the terms have been added incorrectly 3) Step 3, because numbers have been added to both sides of the equation 4) No error was made

1. anonymous

Fan and medal

2. Jack1

3. anonymous

1 right 2 worng

4. Jack1

$$\huge 3x + 1/2 (8x - 2) = 4$$ is this ur original equation...?

5. Jack1

or is it $$\huge 3x \frac{(8x - 2)}2 = 4$$

6. Jack1

anyway i think step 1, as incorrecet signs (the -2 changed to a +1)

7. anonymous

ops then I got it wrong on my quiz i just entered it

8. anonymous

2 people say its 1 wrong and 1 person 2 is wrong. I will agree with you


text:
# How can I automatically highlight SuperCollider symbols and environment variables?

This question led to a new package: sclang-prettifier

I've been poring over the listings manual, trying to figure out how to get some very specific types of formatting for the SuperCollider language.

I need to highlight words where the opening delimiter is \ and the closing delimiter is any non-alphanumeric character. Background: SC has a normal string type, delimited by double quotes -- that's easy. It also has a Symbol type, in single quotes (also easy) -- but Symbols that consist only of alphanumeric characters (and underscore) may also be written with a preceding backslash: 'symbol' and \symbol are equivalent.

Note that the answer to How to highlight all identifiers starting by '@'? does not apply because the closing delimiter may be any non-alphanum (frequently a comma or closing paren, in which case it would be ugly to force a space before it).

If listings won't do it, what alternatives do I have? I also looked at the minted manual, but that was even more confusing.

Some sample SuperCollider code:

p.clear;

~grains.addSpec(\pos, [0, b.duration]);  // 3.43 is nice!
~grains = { |tfreq = 25, overlap = 6, pan = 0, amp = 0.2, pos = 3.43,
rate = 1|
var trig = Impulse.ar(tfreq);
TGrains.ar(2, trig, b, rate, pos, overlap / tfreq, pan, amp)
};
~grains.play;

\exp, \tfreq, \overlap, \pos and \rate need to be highlighted as Symbols. Ideally, environment variables (e.g. ~grains) would also be highlighted in a different color (same rule but with a different opening delimiter).

I have another question, which I will ask separately...

• I don’t think minted supports SuperCollider; at least, it’s not in the list of lexers I get from pygmentize -L lexers. – alexwlchan Mar 22 '14 at 18:30

listings can do that, but you have to whisper in its ear :)

First, tell listings to treat backslash and tilde as "letters", thereby allowing them in identifiers. Then, before each identifier gets printed, check the first character of that identifier and apply a different style depending on that character.

For convenience, I've defined keys to easily specify the styles for SuperCollider classes (starting by A-Z), symbols (starting by \), and global variables (starting by ~).

Update: For convenience to SuperCollider users, I've put together a little package called sclang-prettifier, now available on CTAN and, soon, in popular TeX distributions.

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[framed,numbered]{sclang-prettifier}

% --- write source code to external file (for this example) ---
\usepackage{filecontents}
\begin{filecontents*}{sample.scd}
p.clear;

~grains.addSpec(\pos, [0, b.duration]);  // 3.43 is nice!
~grains = { |tfreq = 25, overlap = 6, pan = 0, amp = 0.2, pos = 3.43,
rate = 1|
var trig = Impulse.ar(tfreq);
TGrains.ar(2, trig, b, rate, pos, overlap / tfreq, pan, amp)
};
~grains.play;
\end{filecontents*}

\begin{document}
\lstinputlisting
[
style      = SuperCollider-IDE,
basicstyle = \scttfamily\small,
caption    = {SuperCollider sample}
]{sample.scd}

\begin{lstlisting}[
frame   = single,
caption = Some code unrelated to SuperCollider,
]
c = a
a = b
b = c
\end{lstlisting}
\end{document}

• Thank you for this! It looks great. Sorry I didn't reply quickly; I was busy writing content. Question: There seems to be a bug, though. It works correctly for the first listing, but all subsequent listings have a large number of extra "a" characters sprinkled throughout, e.g. "// aProxySpace asyntaxa" with 3 extra "a"s. If I comment out the first listing and recompile, then the next listing is correct and all subsequent ones fail. I suspect some state variables are not being reset properly. I also suspect it's an easy fix :) and I'm really grateful for your work on this. – James Mar 22 '14 at 10:15
• @James There is indeed a bug and it probably is an easy fix, but I won't have time to look into it until late today. Stay tuned. In the meantime, please also have a look at my answer to your other question. – jub0bs Mar 22 '14 at 10:49
• @James The bug has been corrected in the latest version of supercollider.sty. Grab it from bitbucket.org/Jubobs/supercollider and test it on the code posted in my answer. Let me know if you notice anything else that looks like a bug. If you're happy, please upvote/accept my answer(s). Also, please let me know whether you think I should make this an official package and submit it to CTAN. Would SuperCollider users in general be interested in it? – jub0bs Mar 22 '14 at 18:17
• I have tested it on my own code (just made a small reproducer here: github.com/jamshark70/scweek2014/blob/master/shows/full-article/…). It passed that test, and also rendered an entire chapter correctly as a test. It doesn't work with beamer, though: chokes on {\lst@FontAdjust. I can live without that for now, but that should be fixed before making an official package. So now it's just: tweak the colors, remove the border and run the whole thing. – James Mar 23 '14 at 8:43
• I will accept this answer now, but I've also logged an issue at bitbucket for the Beamer problem. – James Mar 23 '14 at 9:16


text:
Learning Machine Learning 3 - Some matrix calculus, least squares and Lagrange multipliers

From vector calculus we're familiar with the notion of the gradient of a function $$f:\RR^n\to\RR$$, $$\nabla f$$. Assuming cartesian coordinates it is the vector of partial derivatives, $$(\partial f/\partial x_1,\partial f/\partial x_2,\dots,\partial f/\partial x_n)^\top$$, and points in the direction of the greatest rate of change of $$f$$. If we think of $$f$$ as a real-valued function of real $$m\times n$$ matrices, $$f:\text{Mat}_{m,n}(\RR)\to\RR$$, then $$\nabla f$$ is an $$m\times n$$ matrix,\begin{equation*}\nabla f=\begin{pmatrix}\frac{\partial f}{\partial x_{11}}&\frac{\partial f}{\partial x_{12}}&\cdots&\frac{\partial f}{\partial x_{1n}}\\\frac{\partial f}{\partial x_{21}}&\frac{\partial f}{\partial x_{22}}&\cdots&\frac{\partial f}{\partial x_{2n}}\\\vdots&\vdots&\ddots&\vdots\\\frac{\partial f}{\partial x_{m1}}&\frac{\partial f}{\partial x_{m2}}&\cdots&\frac{\partial f}{\partial x_{mn}}\end{pmatrix}.\end{equation*}

Andrew Jacobs
Learning Machine Learning 2 - The multivariate Gaussian

If a $$N$$-dimensional random vector $$\mathbf{X}=(X_1,X_2,\dots,X_N)^\top$$ is distributed according to a multivariate Gaussian distribution with mean vector \begin{equation*}\boldsymbol{\mu}=(\Exp[X_1],\Exp[X_2],\dots,\Exp[X_N])^\top\end{equation*} and covariance matrix $$\mathbf{\Sigma}$$ such that $$\Sigma_{ij}=\cov(X_i,X_j)$$ we write $$\mathbf{X}\sim\mathcal{N}(\boldsymbol{\mu},\mathbf{\Sigma})$$ and the probability density function is given by \begin{equation*}p(\mathbf{x}|\boldsymbol{\mu},\mathbf{\Sigma})=\frac{1}{(2\pi)^{N/2}\sqrt{\det\mathbf{\Sigma}}}\exp\left(-\frac{1}{2}(\mathbf{x}-\boldsymbol{\mu})^\top\mathbf{\Sigma}^{-1}(\mathbf{x}-\boldsymbol{\mu})\right).\end{equation*}

Andrew Jacobs
Learning Machine Learning 1 - Some probability and stats

By way of "warming up", in this and the next two posts we'll review some of the foundational material (mostly from probability and stats) we'll need. This review is in no way comprehensive. On the contrary it is highly selective and brief.

Bayes' theorem

Bayes' theorem is absolutely critical so let's kick off by recalling it, \begin{equation*}P(A|B)=\frac{P(B|A)P(A)}{P(B)}.\end{equation*}

Learning Machine Learning 0 - Why?

Driving the huge demand  for maths skills at the moment is data, big data. The rate of increase in the production of data over the last 20-30 years defies hyperbole. By 2020, it is estimated that our data production will be equivalent to every one of the 7.5 billion or so people on earth each producing 1.7 MB of data every second! Reassuringly, less than 1% of that data is currently being analysed, but given the scale of information being recorded it's no surprise that the "sexiest job of the 21st century", across a broad range of industries, is data scientist, a job that simply didn't exist when I was an undergraduate. Data science is a broad and, frankly, pretty dull term covering a host of sub-disciplines with super-cool, borderline dystopian sounding names such as artificial intelligence, machine learning, deep learning and neural networks.

Andrew Jacobs
Is maths a victim of its own success?

40-50 years ago, if you knew enough maths to be able to teach, say, calculus and basic probability theory, and you weren't considering an academic pathway, then becoming a teacher was a pretty attractive prospect. Essentially, the alternative was to become an actuary. So plenty of people who really knew maths became maths teachers. More recently, first the finance industry, quickly followed by tech, have become veritable sponges of graduate maths talent. The result? Fewer people who really know maths becoming maths teachers. So just as demand for higher maths skills is escalating, the talent going into teaching the crucial foundations for those skills is declining!