text:
I just proved that $\lvert \sin(nx)\rvert \leq n \cdot \lvert \sin(x) \rvert$ for $n \geq 1$, but it's not true…what went wrong?

I was trying to prove that for $n \geq 1$ and $n = 0$, $$\lvert \sin(nx)\rvert \leq n \cdot \lvert \sin(x) \rvert$$

Turns out it's actually not true...but I don't know why. My proof seems reasonable to me, please help me find the problem(s).

EDIT: This is for real numbers $n$

$\\$

Proof:

Since we're interested in the absolute value of $\sin(nx)$ we only have to consider $nx$ over the interval $[0, \frac{\pi}{2}]$, because any angle $kz \gt \frac{\pi}{2}$ can be expressed as $nx$ such that $\lvert \sin(nx) \rvert = \lvert \sin(kz) \rvert$.

We know that the rate of change of $\sin(x)$ with respect to $x$ decreases continuously as $x$ increases, for $x$ over $[0, \frac{\pi}{2}]$.

We also know that any angle $nx$ can be broken into the sum of $x$ and $(nx - x)$.

Therefore we know that $$\frac{\sin(x)}{x} \geq \frac{\sin(nx) - \sin(x)}{nx - x}$$

In other words, since $\frac{\mathrm{d}}{\mathrm{d}x} \sin(x)$ is continuously decreasing over the interval $[0, \frac{\pi}{2}]$, the slope over the interval $[0,x]$ is always greater than or equal to the slope over $[x, nx]$.

From this, we get

$$nx \cdot \sin(x) - x \cdot \sin(x) \geq x \cdot \sin(nx) - x \cdot \sin(x)$$

$$nx \cdot \sin(x) \geq x \cdot \sin(nx)$$

$$n \cdot \sin(x) \geq \sin(nx)$$

$\\$

I'm pretty sure what's wrong is my first assumption that: Since we're interested in the absolute value of $\sin(nx)$ we only have to consider $nx$ over the interval $[0, \frac{\pi}{2}]$, because any angle $kz \gt (\frac{\pi}{2})$ can be expressed as $nx$ such that $\lvert \sin(nx) \rvert = \lvert \sin(kz) \rvert$.

But I'm not sure exactly why. I'd really appreciate an explanation of why this part or others of my proof are wrong.

EDIT: A second question I have is whether my proof would actually work if we did indeed constain $nx$ to $[0, \frac{\pi}{2}]$. What about constraining just $x$ to $[0, \frac{\pi}{2}]$

• @MattSamuel, thank you but that was just a typo, though. I meant $pi/2$ as in the rest of the proof. – jeremy radcliff Oct 9 '15 at 22:22
• $\lvert \sin(nx)\rvert \leq n \cdot \lvert \sin(x) \rvert$ is true (for nonnegative integers $n$ and real numbers $x$). I cannot see from your question why you think that it is false. – Martin R Oct 9 '15 at 22:25
• @MartinR Well, if we let $n$ be a non-integer it's definitely false, and nowhere does the OP specify that $n$ has to be an integer . . . – Noah Schweber Oct 9 '15 at 22:57
• Th line starting "Therefore we know that..." Um, how? – Thomas Andrews Oct 9 '15 at 22:58
• If $n$ is not an integer, you can't restrict yourself to $[0,\pi/2]$ because $|\sin n(x+\pi)|\neq |\sin nx|$. – Thomas Andrews Oct 9 '15 at 22:59

1 Answer

$\lvert \sin(nx)\rvert \leq n \cdot \lvert \sin(x) \rvert$ holds for all non-negative integers $n$ and all real numbers $x$. It can be proven easily using induction since $$\lvert \sin((n+1)x)\rvert = \lvert \sin(nx + x)\rvert = \lvert \sin(nx) \cos(x) + \cos(nx) \sin(x) \rvert \\ \le \lvert \sin(nx) \cos(x) \rvert + \lvert \cos(nx)\sin(x) \rvert \le \lvert \sin(nx) \rvert + \lvert \sin(x) \rvert \, .$$

If $n$ is not an integer then the inequality cannot hold for all $x \in \mathbb R$, it is false e.g. for $x = \pi$.

• Thank you but $n$ is not supposed to be an integer, that was the problem. I can find a counter example for when $n$ is not an integer, but I don't understand what is wrong with my assumption... – jeremy radcliff Oct 9 '15 at 23:41
• @jeremyradcliff: If $n$ is not an integer then $x=\pi$ is a counter example, and your inequality $\frac{\sin(x)}{x} \geq \frac{\sin(nx) - \sin(x)}{nx - x}$ already fails for $x=\pi$ because the lhs is zero. – Martin R Oct 9 '15 at 23:50
• @jeremyradcliff: There already seems to be a flaw in your initial argument that you only have to consider $nx$ over the interval $[0, \frac{\pi}{2}]$. From $\lvert \sin(nx) \rvert = \lvert \sin(kz) \rvert$ and $\lvert \sin(nx)\rvert \leq n \cdot \lvert \sin(x) \rvert$ it does not follow that $\lvert \sin(kz)\rvert \leq k \cdot \lvert \sin(z) \rvert$. – Martin R Oct 10 '15 at 0:15
• Thank you for following up. I had a hunch that was the problem. I can see it now algebraically, but I'm not sure I have the intuition as to why it isn't true. I just have to think about it until it clicks. – jeremy radcliff Oct 10 '15 at 1:13


text:
# How to replace variable with power?

I would like to replace variable with power. For example,

x^6 /. x^4 -> a + b

which I supposed to get $x^2(a+b)$ but I get $x^6$ and I can't use

x^6 /. x -> Sqrt[Sqrt[a + b]]

because I want to replace $x^4$ only.

• Last@PolynomialReduce[x^6, {x^4 - a - b}, x] seems to work on this very specific problem. It's unlikely you will get a replacement rule to work, since they don't break things down algebraically (into x^4 * x^2, for example). They work on literal matches to patterns. Nov 17 '16 at 3:53
• @MichaelE2 If this question is more complicate, for example, we change $x^4->a+b$ to $x^4->x^2+a+b$, how to deal with this one?
– NaC
Nov 17 '16 at 4:11
• I don't understand: if you want to "replace $x^4$ only," as you state, then x^6 doesn't match what you want, and the answer you get is correct (no replacement happens).
– Jens
Nov 17 '16 at 4:37
• x^6 /. x^n_ :> (a+b)^Quotient[n,4]* x^Mod[n,4] gives you x^2* (a+b)
– Bill
Nov 17 '16 at 4:59
• My 5 cents to this beautiful question: rule = x^n_ /; n >= 4 && n \[Element] Integers -> x^(n - 4)*(a + b); and then x^6 /. rule gives (a + b) x^2. But what would you like to do with x^8 /. rule giving (a + b) x^4? Nov 17 '16 at 7:56

Based on Bill's comment above the following use of TagSetDelayed ensures that multiples of exponent 4 are properly substituted all the time:
f[x_] := a + b + x^2;

If we Expand, the substitution works as well:
Expand[x^3 (a + b + x^2)] (* a x^3 + b x^3 + x^5 *)

format: plain


text:
# Linear Discriminant Analysis

Linear Discriminant Analysis was originally developed by R.A. Fisher to classify subjects into one of the two clearly defined groups. It was later expanded to classify subjects inoto more than two groups. It helps to find linear combination of original variables that provide the best possible separation between the groups.
Linear Discriminant Analysis is focused on maximizing the separability among known categories. The problem is when 2 features are not sufficient to capture the most of variation. In PCA, we solve this problem reducing the dimensionality by focusing on the feature with the most variation. LDA is like PCA, but is focused to maximize the separability between the two groups. PCA is unsupervised, but LDA is supervised.

data(iris)

library(psych)
pairs.panels(iris[1:4],
gap = 0,
bg = c("red", "green", "blue")[iris$Species], pch = 21) We are using the iris dataset with 4 numerical variables and 1 factor which has 3 levels as described above. We can also see that the numerical variables have different ranges, it is a good pratice to normalize the data. From the graph above we have scatterplots of each combination of variabels. In the upper triangle we have correlation coefficients. We can see that Sepal.Length and Petal.Length are good to separate between thr three Species. In other cases, there is a overlapping and not a clear separation between the three Species. # Data Partitioning set.seed(123) ind <- sample(2, nrow(iris), replace = TRUE, prob = c(0.6, 0.4)) training <- iris[ind==1,] testing <- iris[ind==2,] # Linear Discriminant Analysis library(MASS) linear <- lda(Species~., data=training) linear Call: lda(Species ~ ., data = training) Prior probabilities of groups: setosa versicolor virginica 0.3370787 0.3370787 0.3258427 Group means: Sepal.Length Sepal.Width Petal.Length Petal.Width setosa 4.946667 3.380000 1.443333 0.250000 versicolor 5.943333 2.803333 4.240000 1.316667 virginica 6.527586 2.920690 5.489655 2.048276 Coefficients of linear discriminants: LD1 LD2 Sepal.Length 0.3629008 0.05215114 Sepal.Width 2.2276982 1.47580354 Petal.Length -1.7854533 -1.60918547 Petal.Width -3.9745504 4.10534268 Proportion of trace: LD1 LD2 0.9932 0.0068  From the resul above we have the Coefficients of linear discriminants for each of the four variables. The first discriminant function LD1 is a linear combination of the four variables: (0.3629008 x Sepal.Length) + (2.2276982 x Sepal.Width) + (-1.7854533 x Petal.Length) + (-3.9745504 x Petal.Width). Note that Discriminant functions are scaled. We have aslo the Proportion of trace, the percentage separations archived by the first discriminant function LD1 is 99.32%. Now we can create a Stacked Histogram of Discriminant Function values. # Histogram p <- predict(linear, training) ldahist(data = p$x[,1], g = training$Species) # p$x[,1] give data from LD1

From the graph above, we have histogram from LD1, and w can see that the separatin between setosa and the oder two Species is quite large with no overlap. On the contrary, there is a certan amont of overlapping between versicolor and virginica. We already said that the percentage of separation archived by LD1 is 99.32%, that is we he can see a very clear separation from the histogram above. Now, we can try to do the same for LD2.

# Histogram
p <- predict(linear, training)
ldahist(data = p$x[,2], g = training$Species) # p$x[,1] give data from LD1 As we can see from the histogram here above LD2 we have a lot of overlap, which is not great. Now we can try to create the Bi-Plot. # # Bi-Plot library(ggord) ggord(linear, training$Species, ylim = c(-10, 10))

From the Bi-Plot above, we have in the x-axis the LD1 and is able to separate the three Species quite well. There is some amount of overlap between versicolor in green and virginica in blue. We can also see that Sepal.Width and Sepal.Length are both in a positive direction. The contrary is for Petal.Width and Petal.Length.

Now we can build the Partition Plot.

# # Bi-Plot with Linear Discriminant Analysis Model
library(klaR)
partimat(Species~., data=training, method="lda")

From the Partition Plot above, we can see classification for eachof observation in the training dataset based on the Linear Discriminant Analysis Model, and for every combination of two variables. From the right bottom graph, we can see that setosa s is quite far away from the other two Species, and bewtween versicolor and virginica there is some amount of overlap. The graph above is for a Linear Discriminant, we can also use a Quadratic Discriminant Analysis Model.

# Bi-Plot with Quadratic Discriminant Analysis Model
partimat(Species~., data=training, method="qda")

# Confusion Matrix and Accuracy
p1 <- predict(linear, testing)$class tab1 <- table(Predicted = p1, Actual = testing$Species)
tab1
            Actual
Predicted    setosa versicolor virginica
setosa         20          0         0
versicolor      0         19         1
virginica       0          1        20
accuracy1 <- sum(diag(tab1))/sum(tab1)
accuracy1
[1] 0.9672131
# Quadratic Discriminant Analysis
p2 <- predict(quadratic, testing)$class tab2 <- table(Predicted = p2, Actual = testing$Species)
tab2
            Actual
virginica       0          4        19
accuracy2 <- sum(diag(tab2))/sum(tab2)
accuracy2
[1] 0.9016393


text:
# Electromagnetism

Electromagnetism is a branch of physics involving the study of the electromagnetic force, a type of physical interaction that occurs between electrically charged particles. The electromagnetic force is carried by electromagnetic fields composed of electric fields and magnetic fields, is responsible for electromagnetic radiation such as light, and is one of the four fundamental interactions (commonly called forces) in nature. The other three fundamental interactions are the strong interaction, the weak interaction, and gravitation.[1] At high energy the weak force and electromagnetic force are unified as a single electroweak force.

Lightning is an electrostatic discharge that travels between two charged regions.

Electromagnetic phenomena are defined in terms of the electromagnetic force, sometimes called the Lorentz force, which includes both electricity and magnetism as different manifestations of the same phenomenon. The electromagnetic force plays a major role in determining the internal properties of most objects encountered in daily life. The electromagnetic attraction between atomic nuclei and their orbital electrons holds atoms together. Electromagnetic forces are responsible for the chemical bonds between atoms which create molecules, and intermolecular forces. The electromagnetic force governs all chemical processes, which arise from interactions between the electrons of neighboring atoms.

There are numerous mathematical descriptions of the electromagnetic field. In classical electrodynamics, electric fields are described as electric potential and electric current. In Faraday's law, magnetic fields are associated with electromagnetic induction and magnetism, and Maxwell's equations describe how electric and magnetic fields are generated and altered by each other and by charges and currents.

The theoretical implications of electromagnetism, particularly the establishment of the speed of light based on properties of the "medium" of propagation (permeability and permittivity), led to the development of special relativity by Albert Einstein in 1905.

## History of the theory

Originally, electricity and magnetism were considered to be two separate forces. This view changed, however, with the publication of James Clerk Maxwell's 1873 A Treatise on Electricity and Magnetism in which the interactions of positive and negative charges were shown to be mediated by one force. There are four main effects resulting from these interactions, all of which have been clearly demonstrated by experiments:

1. Electric charges attract or repel one another with a force inversely proportional to the square of the distance between them: unlike charges attract, like ones repel.
2. Magnetic poles (or states of polarization at individual points) attract or repel one another in a manner similar to positive and negative charges and always exist as pairs: every north pole is yoked to a south pole.
3. An electric current inside a wire creates a corresponding circumferential magnetic field outside the wire. Its direction (clockwise or counter-clockwise) depends on the direction of the current in the wire.
4. A current is induced in a loop of wire when it is moved toward or away from a magnetic field, or a magnet is moved towards or away from it; the direction of current depends on that of the movement.

While preparing for an evening lecture on 21 April 1820, Hans Christian Ørsted made a surprising observation. As he was setting up his materials, he noticed a compass needle deflected away from magnetic north when the electric current from the battery he was using was switched on and off. This deflection convinced him that magnetic fields radiate from all sides of a wire carrying an electric current, just as light and heat do, and that it confirmed a direct relationship between electricity and magnetism.

At the time of discovery, Ørsted did not suggest any satisfactory explanation of the phenomenon, nor did he try to represent the phenomenon in a mathematical framework. However, three months later he began more intensive investigations. Soon thereafter he published his findings, proving that an electric current produces a magnetic field as it flows through a wire. The CGS unit of magnetic induction (oersted) is named in honor of his contributions to the field of electromagnetism.

His findings resulted in intensive research throughout the scientific community in electrodynamics. They influenced French physicist André-Marie Ampère's developments of a single mathematical form to represent the magnetic forces between current-carrying conductors. Ørsted's discovery also represented a major step toward a unified concept of energy.

This unification, which was observed by Michael Faraday, extended by James Clerk Maxwell, and partially reformulated by Oliver Heaviside and Heinrich Hertz, is one of the key accomplishments of 19th century mathematical physics.[2] It has had far-reaching consequences, one of which was the understanding of the nature of light. Unlike what was proposed by the electromagnetic theory of that time, light and other electromagnetic waves are at present seen as taking the form of quantized, self-propagating oscillatory electromagnetic field disturbances called photons. Different frequencies of oscillation give rise to the different forms of electromagnetic radiation, from radio waves at the lowest frequencies, to visible light at intermediate frequencies, to gamma rays at the highest frequencies.

Ørsted was not the only person to examine the relationship between electricity and magnetism. In 1802, Gian Domenico Romagnosi, an Italian legal scholar, deflected a magnetic needle using a Voltaic pile. The factual setup of the experiment is not completely clear, so if current flowed across the needle or not. An account of the discovery was published in 1802 in an Italian newspaper, but it was largely overlooked by the contemporary scientific community, because Romagnosi seemingly did not belong to this community.[3]

An earlier (1735), and often neglected, connection between electricity and magnetism was reported by a Dr. Cookson.[4] The account stated, "A tradesman at Wakefield in Yorkshire, having put up a great number of knives and forks in a large box ... and having placed the box in the corner of a large room, there happened a sudden storm of thunder, lightning, &c. ... The owner emptying the box on a counter where some nails lay, the persons who took up the knives, that lay on the nails, observed that the knives took up the nails. On this the whole number was tried, and found to do the same, and that, to such a degree as to take up large nails, packing needles, and other iron things of considerable weight ..." E. T. Whittaker suggested in 1910 that this particular event was responsible for lightning to be "credited with the power of magnetizing steel; and it was doubtless this which led Franklin in 1751 to attempt to magnetize a sewing-needle by means of the discharge of Leyden jars." [5]

## Fundamental forces

Representation of the electric field vector of a wave of circularly polarized electromagnetic radiation.

The electromagnetic force is one of the four known fundamental forces. The other fundamental forces are:

All other forces (e.g., friction, contact forces) are derived from these four fundamental forces (including momentum which is carried by the movement of particles).[6]

The electromagnetic force is responsible for practically all phenomena one encounters in daily life above the nuclear scale, with the exception of gravity. Roughly speaking, all the forces involved in interactions between atoms can be explained by the electromagnetic force acting between the electrically charged atomic nuclei and electrons of the atoms. Electromagnetic forces also explain how these particles carry momentum by their movement. This includes the forces we experience in "pushing" or "pulling" ordinary material objects, which result from the intermolecular forces that act between the individual molecules in our bodies and those in the objects. The electromagnetic force is also involved in all forms of chemical phenomena.

A necessary part of understanding the intra-atomic and intermolecular forces is the effective force generated by the momentum of the electrons' movement, such that as electrons move between interacting atoms they carry momentum with them. As a collection of electrons becomes more confined, their minimum momentum necessarily increases due to the Pauli exclusion principle. The behaviour of matter at the molecular scale including its density is determined by the balance between the electromagnetic force and the force generated by the exchange of momentum carried by the electrons themselves.[7]

## Classical electrodynamics

In 1600, William Gilbert proposed, in his De Magnete, that electricity and magnetism, while both capable of causing attraction and repulsion of objects, were distinct effects. Mariners had noticed that lightning strikes had the ability to disturb a compass needle. The link between lightning and electricity was not confirmed until Benjamin Franklin's proposed experiments in 1752. One of the first to discover and publish a link between man-made electric current and magnetism was Romagnosi, who in 1802 noticed that connecting a wire across a voltaic pile deflected a nearby compass needle. However, the effect did not become widely known until 1820, when Ørsted performed a similar experiment.[8] Ørsted's work influenced Ampère to produce a theory of electromagnetism that set the subject on a mathematical foundation.

A theory of electromagnetism, known as classical electromagnetism, was developed by various physicists during the period between 1820 and 1873 when it culminated in the publication of a treatise by James Clerk Maxwell, which unified the preceding developments into a single theory and discovered the electromagnetic nature of light.[9] In classical electromagnetism, the behavior of the electromagnetic field is described by a set of equations known as Maxwell's equations, and the electromagnetic force is given by the Lorentz force law.[10]

One of the peculiarities of classical electromagnetism is that it is difficult to reconcile with classical mechanics, but it is compatible with special relativity. According to Maxwell's equations, the speed of light in a vacuum is a universal constant that is dependent only on the electrical permittivity and magnetic permeability of free space. This violates Galilean invariance, a long-standing cornerstone of classical mechanics. One way to reconcile the two theories (electromagnetism and classical mechanics) is to assume the existence of a luminiferous aether through which the light propagates. However, subsequent experimental efforts failed to detect the presence of the aether. After important contributions of Hendrik Lorentz and Henri Poincaré, in 1905, Albert Einstein solved the problem with the introduction of special relativity, which replaced classical kinematics with a new theory of kinematics compatible with classical electromagnetism. (For more information, see History of special relativity.)

In addition, relativity theory implies that in moving frames of reference, a magnetic field transforms to a field with a nonzero electric component and conversely, a moving electric field transforms to a nonzero magnetic component, thus firmly showing that the phenomena are two sides of the same coin. Hence the term "electromagnetism". (For more information, see Classical electromagnetism and special relativity and Covariant formulation of classical electromagnetism.)

## Extension to nonlinear phenomena

Magnetic reconnection in the solar plasma gives rise to solar flares, a complex magnetohydrodynamical phenomenon.

The Maxwell equations are linear, in that a change in the sources (the charges and currents) results in a proportional change of the fields. Nonlinear dynamics can occur when electromagnetic fields couple to matter that follows nonlinear dynamical laws. This is studied, for example, in the subject of magnetohydrodynamics, which combines Maxwell theory with the Navier–Stokes equations.

## Quantities and units

Electromagnetic units are part of a system of electrical units based primarily upon the magnetic properties of electric currents, the fundamental SI unit being the ampere. The units are:

In the electromagnetic cgs system, electric current is a fundamental quantity defined via Ampère's law and takes the permeability as a dimensionless quantity (relative permeability) whose value in a vacuum is unity. As a consequence, the square of the speed of light appears explicitly in some of the equations interrelating quantities in this system.

SI electromagnetism units
Symbol[11] Name of quantity Unit name Symbol Base units
Q electric charge coulomb C A⋅s
I electric current ampere A A (= W/V = C/s)
J electric current density ampere per square metre A/m2 A⋅m−2
U, ΔV, Δφ; E potential difference; electromotive force volt V J/C = kg⋅m2⋅s−3⋅A−1
R; Z; X electric resistance; impedance; reactance ohm Ω V/A = kg⋅m2⋅s−3⋅A−2
ρ resistivity ohm metre Ω⋅m kg⋅m3⋅s−3⋅A−2
P electric power watt W V⋅A = kg⋅m2⋅s−3
C capacitance farad F C/V = kg−1⋅m−2⋅A2⋅s4
ΦE electric flux volt metre V⋅m kg⋅m3⋅s−3⋅A−1
E electric field strength volt per metre V/m N/C = kg⋅m⋅A−1⋅s−3
D electric displacement field coulomb per square metre C/m2 A⋅s⋅m−2
ε permittivity farad per metre F/m kg−1⋅m−3⋅A2⋅s4
χe electric susceptibility (dimensionless) 1 1
G; Y; B conductance; admittance; susceptance siemens S Ω−1 = kg−1⋅m−2⋅s3⋅A2
κ, γ, σ conductivity siemens per metre S/m kg−1⋅m−3⋅s3⋅A2
B magnetic flux density, magnetic induction tesla T Wb/m2 = kg⋅s−2⋅A−1 = N⋅A−1⋅m−1
Φ, ΦM, ΦB magnetic flux weber Wb V⋅s = kg⋅m2⋅s−2⋅A−1
H magnetic field strength ampere per metre A/m A⋅m−1
L, M inductance henry H Wb/A = V⋅s/A = kg⋅m2⋅s−2⋅A−2
μ permeability henry per metre H/m kg⋅m⋅s−2⋅A−2
χ magnetic susceptibility (dimensionless) 1 1

Formulas for physical laws of electromagnetism (such as Maxwell's equations) need to be adjusted depending on what system of units one uses. This is because there is no one-to-one correspondence between electromagnetic units in SI and those in CGS, as is the case for mechanical units. Furthermore, within CGS, there are several plausible choices of electromagnetic units, leading to different unit "sub-systems", including Gaussian, "ESU", "EMU", and Heaviside–Lorentz. Among these choices, Gaussian units are the most common today, and in fact the phrase "CGS units" is often used to refer specifically to CGS-Gaussian units.

## References

1. ^ Ravaioli, Fawwaz T. Ulaby, Eric Michielssen, Umberto (2010). Fundamentals of applied electromagnetics (6th ed.). Boston: Prentice Hall. p. 13. ISBN 978-0-13-213931-1.
2. ^ Darrigol, Olivier (2000). Electrodynamics from Ampère to Einstein. New York: Oxford University Press. ISBN 0198505949.
3. ^ Martins, Roberto de Andrade. "Romagnosi and Volta's Pile: Early Difficulties in the Interpretation of Voltaic Electricity" (PDF). In Fabio Bevilacqua and Lucio Fregonese (eds) (eds.). Nuova Voltiana: Studies on Volta and his Times. vol. 3. Università degli Studi di Pavia. pp. 81–102. Archived from the original (PDF) on 2013-05-30. Retrieved 2010-12-02.CS1 maint: Uses editors parameter (link)
4. ^ VIII. An account of an extraordinary effect of lightning in communicating magnetism. Communicated by Pierce Dod, M.D. F.R.S. from Dr. Cookson of Wakefield in Yorkshire. Phil. Trans. 1735 39, 74-75, published 1 January 1735
5. ^ Whittaker, E.T. (1910). A History of the Theories of Aether and Electricity from the Age of Descartes to the Close of the Nineteenth Century. Longmans, Green and Company.
6. ^ Browne, "Physics for Engineering and Science," p. 160: "Gravity is one of the fundamental forces of nature. The other forces such as friction, tension, and the normal force are derived from the electric force, another of the fundamental forces. Gravity is a rather weak force... The electric force between two protons is much stronger than the gravitational force between them."
7. ^ Purcell, "Electricity and Magnetism, 3rd Edition," p. 546: Ch 11 Section 6, "Electron Spin and Magnetic Moment."
8. ^ Stern, Dr. David P.; Peredo, Mauricio (2001-11-25). "Magnetic Fields – History". NASA Goddard Space Flight Center. Retrieved 2009-11-27.
9. ^ Purcell, p. 436. Chapter 9.3, "Maxwell's description of the electromagnetic field was essentially complete."
10. ^ Purcell: p. 278: Chapter 6.1, "Definition of the Magnetic Field." Lorentz force and force equation.
11. ^ International Union of Pure and Applied Chemistry (1993). Quantities, Units and Symbols in Physical Chemistry, 2nd edition, Oxford: Blackwell Science. ISBN 0-632-03583-8. pp. 14–15. Electronic version.

### Textbooks

• G.A.G. Bennet (1974). Electricity and Modern Physics (2nd ed.). Edward Arnold (UK). ISBN 978-0-7131-2459-0.
• Browne, Michael (2008). Physics for Engineering and Science (2nd ed.). McGraw-Hill/Schaum. ISBN 978-0-07-161399-6.
• Dibner, Bern (2012). Oersted and the discovery of electromagnetism. Literary Licensing, LLC. ISBN 978-1-258-33555-7.
• Durney, Carl H.; Johnson, Curtis C. (1969). Introduction to modern electromagnetics. McGraw-Hil]. ISBN 978-0-07-018388-9.
• Feynman, Richard P. (1970). The Feynman Lectures on Physics Vol II. Addison Wesley Longman. ISBN 978-0-201-02115-8.
• Fleisch, Daniel (2008). A Student's Guide to Maxwell's Equations. Cambridge, UK: Cambridge University Press. ISBN 978-0-521-70147-1.
• I.S. Grant; W.R. Phillips; Manchester Physics (2008). Electromagnetism (2nd ed.). John Wiley & Sons. ISBN 978-0-471-92712-9.
• Griffiths, David J. (1998). Introduction to Electrodynamics (3rd ed.). Prentice Hall. ISBN 978-0-13-805326-0.
• Jackson, John D. (1998). Classical Electrodynamics (3rd ed.). Wiley. ISBN 978-0-471-30932-1.
• Moliton, André (2007). Basic electromagnetism and materials. 430 pages. New York City: Springer-Verlag New York, LLC. ISBN 978-0-387-30284-3.
• Purcell, Edward M. (1985). Electricity and Magnetism Berkeley, Physics Course Volume 2 (2nd ed.). McGraw-Hill. ISBN 978-0-07-004908-6.
• Purcell, Edward M and Morin, David. (2013). Electricity and Magnetism, 820p (3rd ed.). Cambridge University Press, New York. ISBN 978-1-107-01402-2.CS1 maint: Multiple names: authors list (link)
• Rao, Nannapaneni N. (1994). Elements of engineering electromagnetics (4th ed.). Prentice Hall. ISBN 978-0-13-948746-0.
• Rothwell, Edward J.; Cloud, Michael J. (2001). Electromagnetics. CRC Press. ISBN 978-0-8493-1397-4.
• Tipler, Paul (1998). Physics for Scientists and Engineers: Vol. 2: Light, Electricity and Magnetism (4th ed.). W.H. Freeman. ISBN 978-1-57259-492-0.
• Wangsness, Roald K.; Cloud, Michael J. (1986). Electromagnetic Fields (2nd Edition). Wiley. ISBN 978-0-471-81186-2.

### General references

• A. Beiser (1987). Concepts of Modern Physics (4th ed.). McGraw-Hill (International). ISBN 978-0-07-100144-1.
• L.H. Greenberg (1978). Physics with Modern Applications. Holt-Saunders International W.B. Saunders and Co. ISBN 978-0-7216-4247-5.
• R.G. Lerner; G.L. Trigg (2005). Encyclopaedia of Physics (2nd ed.). VHC Publishers, Hans Warlimont, Springer. pp. 12–13. ISBN 978-0-07-025734-4.
• J.B. Marion; W.F. Hornyak (1984). Principles of Physics. Holt-Saunders International Saunders College. ISBN 978-4-8337-0195-2.
• H.J. Pain (1983). The Physics of Vibrations and Waves (3rd ed.). John Wiley & Sons. ISBN 978-0-471-90182-2.
• C.B. Parker (1994). McGraw Hill Encyclopaedia of Physics (2nd ed.). McGraw Hill. ISBN 978-0-07-051400-3.
• R. Penrose (2007). The Road to Reality. Vintage books. ISBN 978-0-679-77631-4.
• P.A. Tipler; G. Mosca (2008). Physics for Scientists and Engineers: With Modern Physics (6th ed.). W.H. Freeman and Co. ISBN 978-1-4292-0265-7.
• P.M. Whelan; M.J. Hodgeson (1978). Essential Principles of Physics (2nd ed.). John Murray. ISBN 978-0-7195-3382-2.


text:
Easy composition of configuration files

Project description

Layer-loader is a Python library designed to allow easy composition of configuration files.

This project was inspired by hiera, though intends to be somewhat simpler.

Usage

The primary interface is a Python API:

import json

['dev.json', 'main.json'],
)

This will load the data from dev.json and main.json, interpreting it as JSON, combine it into a single object and then any placeholders are expanded.

For convenience you can also run layer_loader as a module:

$cat dev.json { "url": "http://localhost:8000" }$ cat main.json
{
"endpoints": [
"{url}/abc",
"{url}/def",
"{url}/ghi"
],
"url": "https://production.system"
}
{
"endpoints": [
"http://localhost:8000/abc",
"http://localhost:8000/def",
"http://localhost:8000/ghi"
],
"url": "http://localhost:8000"
}

Layers

Layers are specified in order from most important (top) to least important (bottom). When combining layers, layer-loader uses the following rules:

• Mappings can be merged, combining the entries from several layers
• Scalar values and lists replace entries in the lower layers
• Keys in more important layers override those in lower layers
• Where keys are present in multiple layers, it is an error for those keys to have values of different types. The exception to this is that keys can explicitly be set to null in a higher layer in order to remove a value set in a lower layer.

Placeholders

Placeholders are specified similarly to python format strings and may appear anywhere inside a string value, for example 'foo {place.holder} bar'. Placeholders should not appear in keys -- they will not be found there.

Placeholders are expanded by walking the flattened data structure, using dots in the placeholder to separate names at each level of nesting.

There is no mechanism to specify which layer a placeholder should be looked up within -- all placeholder expansion happens after the layers have been flattened.

Project details

Source Distribution

Uploaded source

Built Distribution

Uploaded py3


text:
## Chemistry: The Central Science (13th Edition)

$4Li(s)+O_2(g)\longrightarrow 2Li_2O(s)$
$4Li(s)+O_2(g)\longrightarrow 2Li_2O(s)$ is balanced with four moles $Li$ and two moles $Li_2O$.


text:
# CHARGE ASYMMETRY IN ${{\boldsymbol e}^{+}}$ ${{\boldsymbol e}^{-}}$ $\rightarrow$ ${{\boldsymbol q}}{{\overline{\boldsymbol q}}}$ INSPIRE search

Summed over five lighter flavors.

Experimental and Standard Model values are somewhat event-selection dependent. Standard Model expectations contain some assumptions on ${{\mathit B}^{0}}-{{\overline{\mathit B}}^{0}}$ mixing and on other electroweak parameters.
ASYMMETRY ${\mathrm {(\%)}}$ STD. MODEL $\sqrt {\mathit s }$ ${\mathrm {(GeV)}}$ DOCUMENT ID TECN
• • • We do not use the following data for averages, fits, limits, etc. • • •
$-0.76 \pm0.12 \pm0.15$ 91.2 1
 1992 I
DLPH
$4.0 \pm0.4 \pm0.63$ $4.0$ 91.3 2
 1992 L
OPAL
$9.1 \pm1.4 \pm1.6$ $9.0$ 57.9
 1991
TOPZ
$-0.84 \pm0.15 \pm0.04$ 91
 1991 B
ALEP
$8.3 \pm2.9 \pm1.9$ $8.7$ 56.6
 1990
AMY
$11.4 \pm2.2 \pm2.1$ $8.7$ 57.6
 1989 L
VNS
$6.0 \pm1.3$ $5.0$ 34.8
 1989
$8.2 \pm2.9$ $8.5$ 43.6
 1989
1  ABREU 1992I has $0.14$ systematic error due to uncertainty of quark fragmentation.
2  ACTON 1992L use the weight function method on 259k selected ${{\mathit Z}}$ $\rightarrow$ hadrons events. The systematic error includes a contribution of $0.2$ due to ${{\mathit B}^{0}}-{{\overline{\mathit B}}^{0}}$ mixing effect, $0.4$ due to Monte Carlo (MC) fragmentation uncertainties and $0.3$ due to MC statistics. ACTON 1992L derive a value of sin$^2\theta {}^{{\mathrm {eff}}}_{{{\mathit W}}}$ to be $0.2321$ $\pm0.0017$ $\pm0.0028$.
References:
 ABREU 1992I
PL B277 371 A Measurement of sin$^2\theta _{W}$ from the Charge Asymmetry of Hadronic Events at the ${{\mathit Z}^{0}}$ Peak
 ACTON 1992L
PL B294 436 A Measurement of the Forward-Backward Charge Asymmetry in Hadronic Decays of the${{\mathit Z}^{0}}$
PL B255 613 Charge Asymmetry of Hadronic Events in ${{\mathit e}^{+}}{{\mathit e}^{-}}$ Annihilation at $\sqrt {s }$ = 57.9 GeV
PL B259 377 Measurement of Charge Asymmetry in Hadronic ${{\mathit Z}^{0}}$ Decays
PRL 64 983 Forward Backward Charge Asymmetry in ${{\mathit e}^{+}}$ ${{\mathit e}^{-}}$ $\rightarrow$ jets
PL B232 425 Charge Asymmetry of Hadron Jets and Limits on the Compositeness Scales in ${{\mathit e}^{+}}$ ${{\mathit e}^{-}}$ $\rightarrow$ ${\mathit {\mathit q}}$ ${\mathit {\overline{\mathit q}}}$ Reaction at $\sqrt {s }$ = 57.6 GeV


text:
# There are 24 students in Juan's class. The ratio of girls to boys is 1:2. How many girls and boys are in Juan's class?

Mar 31, 2017

There are $8$ girls and $16$ boys in the class

#### Explanation:

The total number of students is $24$. From the ratio of girls to boys, we have $1 : 2$. Add the numbers in the ratio together. Take $24$ and divide by that number.

$1 + 2 = 3$
then, $\frac{24}{3}$ equals $8$ per part

number of girls $8 \times 1 = 8$
number of boys $8 \times 2 = 16$


text:
# Efficiency of Angular Momentum Transport Essay examples

Decent Essays
Observations indicate that at present time stars born in magnetized rotating cores of molecular clouds~\citep{shu87, dudorov91, dudorov95, mckee07}. Centrifugal and electromagnetic forces lead to the formation of a disk-like structure during the gravitational collapse of the molecular cloud. Evolution of accretion disks depends on efficiency of angular momentum escape. Turbulence \citep{ss73}, magnetic braking and outflows are the most important mechanisms of angular momentum transport in accretion disks of young stars. Turbulence in accretion disks comes probably from magnetorotational instability \citep[MRI, ][]{balbus91}. Magnetic braking mechanism is based on the process of transfer of angular momentum by torsional Alfven waves…show more content…
\cite{chapman13} detected a correlation between core magnetic field direction and protostellar disk symmetry axis in a few low-mass protostellar cores using the SHARP polarimeter at Caltech Submillimeter Observatory at 350 $\mu$m dust continuum emission. \cite{donati05} probably detected magnetic field with azimuthal component of order of 1 kGs in the FU Orionis accretion disk. In absence of sufficient number of observational data, theoretical calculations of magnetic field of accretion disks of young stars become an important task.

Dragging of an external magnetic field in the accretion disks has been investigated in several works. \cite{lubow94} and \cite{agapitou96} considered bending of an initially vertical weak magnetic field in the infinitesimally thin viscous disk. They pointed out that inclination of poloidal magnetic fields lines and wind launching possibility depend on magnetic diffusion efficiency which is characterized by the magnetic Prandtl number $\mathcal{P}$. \cite{RRS96} investigate analogous problem in two-dimensional approach and showed that, in addition to radial magnetic field component, strong toroidal component of the magnetic field is also generated in the case of weak magnetic diffusion, $\mathcal{P}\gg 1$. \cite{shalybkov00} considered steady-state structure of the accretion disk in the presence of dynamically important magnetic field. They found that sufficient


text:
# Really Terrible Precedent: It's still libel even if it's true?

Universal Hub points out an analysis of Noonan vs. Staples, in which an employee terminated for violating the travel and reimbursement policy is trying to get grounds to sue for libel and access to his stock options.

The 1st Circuit Federal Appeals court had ruled that he had no grounds but has now reversed that ruling.

In the opinion they do state that in order to be libel a statement must, among other things, be false:
Under Massachusetts law, a plaintiff alleging libel must ordinarily establish five elements: (1) that the defendant published a written statement; (2) of and concerning the plaintiff; that was both (3) defamatory, and (4) false; and (5) either caused economic loss, or is actionable without proof of economic loss.
but they claim that there is an exception:
Massachusetts law, however, recognizes a narrow exception to this defense: the truth or falsity of the statement is immaterial, and the libel action may proceed, if the plaintiff can show that the defendant acted with “actual malice” in publishing the statement. White, 809 N.E.2d at 1036 n.4 (citing Mass. Gen. Laws ch. 231, § 92).

The court goes on to disregard a 1964 precedent defining “actual malice”, and use a 1903 definition instead:

A 1903 case from the Massachusetts Supreme Judicial Court explains that the term meant “malicious intention.” Conner v. Standard Publ’g Co., 67 N.E. 596, 598 (Mass. 1903). Since 1964, however, the term “actual malice” has taken on a new meaning in defamation cases involving public figures; in this context, a person acts with “‘actual malice’” when he acts “‘with knowledge that [a defamatory statement] was false or with reckless disregard of whether it was false or not.’” Cantrell v. Forest City Publ’g Co., 419 U.S. 245, 251 (1974) (alteration in original) (quoting New York Times v. Sullivan, 376 U.S. 254, 280 (1964)). But, the Supreme Court has explained that actual malice in the public-figure context is different than “common-law malice” or “ill will,” which is sometimes required under state law. Id. at 251-52.

     Though the Massachusetts statute at issue in this case also uses the term "actual malice," we are persuaded that we should not read that term as having the specialized meaning later developed by the Supreme Court.

The plaintiff claims (and the court agrees) that using the plaintiff’s name in an email to the company explaining why he was terminated might be understood by a jury to be malicious. This is the email, according to the opinion:

The e-mail stated as follows:

It is with sincere regret that I must inform you of the termination of Alan Noonan’s employment with Staples. A thorough investigation determined that Alan was not in compliance with our [travel and expenses] policies. As always, our policies are consistently applied to everyone and compliance is mandatory on everyone’s part. It is incumbent on all managers to understand Staples[’s] policies and to consistently communicate, educate and monitor compliance every single day. Compliance with company policies is not subject to personal discretion and is not optional. In addition to ensuring compliance, the approver’s responsibility to monitor and question is a critical factor in effective management of this and all policies.

If you have any questions about Staples[’s] policies or Code of Ethics, call the Ethics Hotline . . . or ask your human resources manager.
Media Law summarizes the precedent:
The Supreme Court’s decision in New York Times v. Sullivan defined actual malice as requiring knowledge that a statement was false or reckless disregard for its truth or falsity. The first time the 1st Circuit decided this case, it applied that standard to dismiss Noonan’s appeal. This time, it leapfrogged back in time over 40 years of Supreme Court precedent to apply a 1903 SJC ruling that defined actual malice as “malicious intention,” which Torruella recasts as “ill will.”

Setting aside the question of whether it’s malicious to make an example of someone, this is a scary disregard of precedent and an ominous blow against freedom of speech. I can’t see the sense in this—it seems like an obvious violation of the 1st Amendment to claim that Staples did not have the right to send a message to their employees about events happening in the company, if that message contained true statements. Would the court prevent a news article from being published about Noonan’s termination? I really hope not.

law


text:
# Kerodon

$\Newextarrow{\xRightarrow}{5,5}{0x21D2}$ $\newcommand\empty{}$

Remark 2.5.6.18. Let $f: A_{\bullet } \rightarrow B_{\bullet }$ be a morphism of simplicial abelian groups. By virtue of Lemma 2.5.6.17, the following assertions are equivalent:

• For every integer $n \geq 0$, the map of abelian groups $A_{n} \rightarrow B_ n$ is surjective (respectively split surjective, injective, split injective).

• For every integer $n \geq 0$, the map of abelian groups $\mathrm{N}_{n}(A) \rightarrow \mathrm{N}_{n}(B)$ is surjective (respectively split surjective, injective, split injective).


text:
## Neural Ordinary Differential Equations 🐰🦊

Presented by Christabella Irwanto

## Neural ODE

• A new model class chen18_neural_ode, can be used as
• Continuous-depth residual networks
• Continuous-time latent variable models
• Propose continuous normalizing flows, generative model
• Scalable backpropagation through ODE solver
• Paper shows various proofs of concept

## ODE? 😕

“In the 300 years since Newton, mankind has come to realize that the laws of physics are always expressed in the language of differential equations.”

• Steven Strogatz
• An ODE is an equation involving an unknown function $$y=f(t)$$ and at least one of its derivatives $$y’, y''$$ etc.
• Univariate functions (“time”) vs partial DE’s with multivariate input
• Solve ODE by finding satisfying function $$f$$
• Useful whenever it’s easier to describe change than absolute quantity, e.g. in many dynamical systems (☢, 🏀, 💊)

### Bunny example 🐇

• Model system of dynamics with first-order ODE, $$B'(t) = \frac{dB}{dt} = rB$$
• $$B(t)$$: bunny population at time $$t$$
• $$r$$: growth rate of new bunnies for every bunny, per $$\Delta t$$

### Visualize ODE

Slope field of derivative for each $$(B, t)$$

### Solve ODE

• Analytical solution via integration is $$B(t) = B(t_0)e^{rt}$$
• Known initial value $$B(t_0)$$

### Numerical ODE solver

• Not all ODE’s have a closed form function satisfying it
• Even if so, it’s very hard finding solutions
• We have to numerically solve the ODE
• Euler’s method, Runge-Kutta methods

## Enter neural networks

• Regular neural networks transform input with a series of functions $$f$$,

$$\mathbf{h}_{t+1} = f(\mathbf{h}_t)$$

• Each layer introduces error that compounds
• Mitigate this by adding more layers, and limit the complexity of each step
• Infinite layers, with infinitesimal step-changes?

### Resnet

• Instead of $$\mathbf{h}_{t+1} = f(\mathbf{h}_t)$$, learn $$\mathbf{h}_{t+1} = \mathbf{h}_t + f(\mathbf{h}_t, \theta_t)$$
• Similarly, RNN decoders and normalizing flows build complicated transformations by chaining sequences
• Looks like Euler discretization of continuous transformation

## Neural ODE

• $$\mathbf{h}_{t+1} = \mathbf{h}_t + f(\mathbf{h}_t, \theta_t)$$
• In the continuous limit w.r.t. depth $$t$$, parameterize hidden state dynamics with an ODE specified by a neural network:
• $$\frac{d\mathbf{h}(t)}{dt} = f(\mathbf{h}(t), t, \theta)$$, where neural network $$f$$ has parameters $$\theta$$
• Function approximation now over a continuous hidden state dynamic

### Forward pass

• 🐰 Evaluate $$\mathbf{h}(t_1)$$ by solving the integral
• $$\mathbf{h}(t) = \int f(t, \mathbf{h}(t), \theta_t)dt$$
• If we use Euler’s method, we get exactly the residual state update!

### Numerical ODE solver

• Paper solves ODE initial value problems numerically with implicit Adams method
• Not unconditionally stable
• Current set of PyTorch ODE solvers only applicable to (some) non-stiff ODEs
• Without a reversible integrator (implicit Adams is not reversible), method drifts from the true solution doing a backwards integration

• Use existing efficient solvers to integrate neural network dynamics
• Memory cost is $$O(1)$$ due to reversibility of ODE net
• Tuning ODE solver tolerance gives trade-off between accuracy and speed
• More fine-grained tuning,versus using lower precision floating point numbers

### Backward pass

• Output (hidden state at final depth) is used to compute loss
$$L(\mathbf{z}(t_1)) = L\left( \mathbf{z}(t_0) + \int_{t_0}^{t_1} f(\mathbf{z}(t), t, \theta)dt \right) = L(\textrm{ODESolve}(\mathbf{z}(t_0), f, t_0, t_1, \theta))$$
• Scalable backpropagation through ODE solver with adjoint method
• Vectorization to compute multiple derivatives in single call

### How to train?

• Standard reverse mode chain rule equations in backprop
• Take continuous time limit of chain rule to recover the adjoint sensitivity equations

• Reverse-mode differentiation of an ODE solution
• Solving for adjoint state with same ODE solver used in forward pass

### Results of ODE-Net vs Resnet

• Fewer parameters with same accuracy
• However, harder to train, tricky to implement mini-batching
• Can't control the training time cost, computational complexity increases

## Generative latent time-series model

• Continuous-time approach to modeling time series

### Results of experiments

• Spiral dataset at irregular time intervals, with Gaussian noise

• For supervised learning, its main benefit is extra flexibility in the speed/precision tradeoff.
• For time-series problems, allow handling of data at irregular intervals

## Normalizing flows

• Normalizing flows define a parametric density by iteratively transforming Gaussian sample:
\begin{align} z_0 &\sim Normal(0, I) \\ z_1 &= f_0(z_0) \\ … \\ x &= f_t(z_t) \end{align}
• Use the change of variables formula to compute p(x): $$log p(z_{t+1}) = log p(z_t) - log | det \frac{df(z_t)}{dz_t} |$$
• Paper proposes continuous-time version, Continuous NF
• Derived continuous-time analogue of change of variables formula:

### Results

• Compare Continuous NF to NF family of models on density estimation, image generation, and variational inference
• Achieve state-of-the-art among exact likelihood methods with efficient sampling, in follow-up paper grathwohl18

### Pros and cons

• 4-5x slower than other methods (Glow, Real-NVP)

## Summary

• New and novel application of differential equation solvers as part of a neural net
• Idea of Resnet/RNN as an Euler discretization is a neat solution
• Much work can be done on both numerical differential equation and ML side


text:
# Weber problem

In geometry, the Weber problem, named after Alfred Weber, is one of the most famous problems in location theory. It requires finding a point in the plane that minimizes the sum of the transportation costs from this point to n destination points, where different destination points are associated with different costs per unit distance.

The Weber problem generalizes the geometric median, which assumes transportation costs per unit distance are the same for all destination points, and the problem of computing the Fermat point, the geometric median of three points. For this reason it is sometimes called the Fermat–Weber problem, although the same name has also been used for the unweighted geometric median problem. The Weber problem is in turn generalized by the attraction–repulsion problem, which allows some of the costs to be negative, so that greater distance from some points is better.

## Definition and history of the Fermat, Weber, and attraction-repulsion problems

The Fermat problem The Weber problem The attraction-repulsion problem
First formulated by Fermat (before 1640) Simpson (1750) Tellier (1985)
Geometrical solution of the triangle problem Torricelli (1645) Simpson (1750) Tellier (2013)
Direct numerical solution of the triangle problem Tellier (1972) Tellier (1972) Tellier (1985)
Iterative numerical solution of the problem Kuhn and Kuenne (1962) Kuhn and Kuenne (1962) Chen, Hansen, Jaumard and Tuy (1992)

In the triangle case, the Fermat problem consists in locating a point D with respect to three points A, B, and C in such a way that the sum of the distances between D and each of the three other points is minimized. It was formulated by the famous French mathematician Pierre de Fermat before 1640, and it can be seen as the true beginning of both location theory, and space-economy. Torricelli found a geometrical solution to this problem around 1645, but it still had no direct numerical solution more than 325 years later. Kuhn and Kuenne[1] found an iterative solution for the general Fermat problem in 1962, and, in 1972, Tellier[2] found a direct numerical solution to the Fermat triangle problem, which is trigonometric. Kuhn and Kuenne’s solution applies to the case of polygons having more than three sides, which is not the case with Tellier’s solution for reasons explained further on.

The Weber problem consists, in the triangle case, in locating a point D with respect to three points A, B, and C in such a way that the sum of the transportation costs between D and each of the three other points is minimized. The Weber problem is a generalization of the Fermat problem since it involves both equal and unequal attractive forces (see below), while the Fermat problem only deals with equal attractive forces. It was first formulated, and solved geometrically in the triangle case, by Thomas Simpson in 1750.[3] It was later popularized by Alfred Weber in 1909.[4] Kuhn and Kuenne’s iterative solution found in 1962, and Tellier’s solution found in 1972 apply to the Weber triangle problem as well as to the Fermat one. Kuhn and Kuenne’s solution applies also to the case of polygons having more than three sides.

In its simplest version, the attraction-repulsion problem consists in locating a point D with respect to three points A1, A2 and R in such a way that the attractive forces exerted by points A1 and A2, and the repulsive force exerted by point R cancel each other out as it must do at the optimum. It constitutes a generalization of both the Fermat and Weber problems. It was first formulated and solved, in the triangle case, in 1985 by Luc-Normand Tellier.[5] In 1992, Chen, Hansen, Jaumard and Tuy found a solution to the Tellier problem for the case of polygons having more than three sides.

## Torricelli’s geometrical solution of the Fermat triangle problem

Torricelli's geometrical solution of the Fermat triangle problem.

Evangelista Torricelli’s geometrical solution of the Fermat triangle problem stems from two observations:

1– point D is at its optimal location when any significant move out of that location induces a net increase of the total distance to reference points A, B, and C, which means that the optimal point is the only point where an infinitesimal movement towards one of the three reference points induces a reduction of the distance to that point that is equal to the sum of the induced changes in the distances to the two other points; in fact, in the Fermat problem, the advantage to reduce the distance from A by one kilometer is equal to the advantage to reduce the distance from B by one kilometer or the distance from C by the same length; in other words, the activity to be located at D is equally attracted by A, B, and C;

2– according to an important theorem of Euclidian geometry, in a convex quadrilateral inscribed in a circle, the opposite angles are supplementary (that is their sum is equal to 180°); that theorem can also take the following form: if we cut a circle with a chord AB, we get two circle arcs, let us say AiB and AjB; on arc AiB, any ∠AiB angle is the same for any chosen point i, and, on arc AjB, all the ∠AjB angles are also equal for any chosen point j; moreover, the ∠AiB and ∠AjB angles are supplementary.

It can be proved that the first observation implies that, at the optimum, the angles between the AD, BD, and CD straight lines must be equal to 360° / 3 = 120°. Torricelli deduced from that conclusion that:

1– if any triangle ABD, whose ∠ADB angle is equal to 120°, generates an ABDE convex quadrilateral inscribed in a circle, the ∠ABE angle of the ABE triangle must be equal to (180° − 120°)= 60°;

2– one way to determine the set of locations of D for which the ∠ADB angle is equal to 120° is to draw an equilateral ABE triangle (because each angle of an equilateral triangle is equal to 60°), where E is located outside the ABC triangle, and draw a circle round that triangle; then all the D’ points of the circumference of that circle that lie within the ABC circle are such that the ∠AD’B angle is equal to 120°;

3– the same reasoning can be made with respect to triangles ACD, and BCD;

4– this leads to draw two other equilateral triangles ACF and BCG, where F and G are located outside the ABC triangle, as well as two other circles round these equilateral triangles, and to determine the location where the three circles intersect; at that location, the angles between the AD, BD, and CD straight lines is necessarily equal to 120°, which proves that it is the optimal location.

## Simpson’s geometrical solution of the Weber triangle problem

Simpson's geometrical solution of the Weber triangle problem.

Simpson’s geometrical solution of the so-called “Weber triangle problem” (which was first formulated by Thomas Simpson in 1750) directly derives from Torricelli’s solution. Simpson and Weber stressed the fact that, in a total transportation minimization problem, the advantage to get closer to each attraction point A, B or C depends on what is carried and on its transportation cost. Consequently, the advantage of getting one kilometer closer to A, B or C varies, and the ∠ADB, ∠ADC and ∠BDC angles no more need to be equal to 120°.

Simpson demonstrated that, in the same way as, in the Fermat triangle problem case, the constructed triangles ABE, ACF and BCG were equilateral because the three attractive forces were equal, in the Weber triangle problem case, the constructed triangles ABE, ACF and BCG, where E, F and G are located outside the ABC triangle, must be proportional to the attractive forces of the location system.

The solution is such that:

1– in the constructed triangle ABE, the AB side is proportional to the attractive force Cw pointing towards C, the AE side is proportional to the attractive force Bw pointing towards B, and the BE side is proportional to the attractive force Aw pointing towards A;

2– in the constructed triangle BCG, the BC side is proportional to the attractive force Aw pointing towards A, the BG side is proportional to the attractive force Bw pointing towards B, and the CG side is proportional to the attractive force Cw pointing towards C;

3– the optimal point D is located at the intersection of the two circumferences drawn round the ABE and BCG constructed triangles.

A third triangle of forces ACF, where F is located outside the ABC triangle, can be drawn based on the AC side, and a third circumference can be traced round that triangle. That third circumference crosses the two previous ones at the same point D.

## Tellier’s geometrical solution of the attraction-repulsion triangle problem

Tellier's geometrical solution of the attraction-repulsion triangle problem.

A geometrical solution exists for the attraction-repulsion triangle problem. Its discovery is very recent.[6] That geometrical solution differs from the two previous ones since, in this case, the two constructed force triangles overlap the A1A2R location triangle (where A1 and A2 are attraction points, and R, a repulsion one), while, in the preceding cases, they never did.

This solution is such that:

1– in the constructed triangle RA2H, which partly overlaps the A1A2R location triangle, the RA2 side is proportional to the attractive force A1w pointing towards A1, the RH side is proportional to the attractive force A2w pointing towards A2, and the A2H side is proportional to the repulsive force Rw pushing away from point R;

2– in the constructed triangle RA1I, which partly overlaps the A1A2R location triangle, the RA1 side is proportional to the attractive force A2w pointing towards A2, the RI side is proportional to the attractive force A1w pointing towards A1, and the A1I side is proportional to the repulsive force Rw pushing away from point R;

3– the optimal point D is located at the intersection of the two circumferences drawn round the RA2H and RA1I constructed triangles. This solution is useless if one of the forces is greater than the sum of the two other ones or if the angles are not compatible. In some cases, no force is larger than the two other ones, and the angles are not compatible; then, the optimal location lies at the point that exerts the greater attractive force.

## Tellier’s trigonometric solution of the Fermat and Weber triangle problems

The angles of the Weber problem.
The case of non-coincidence of the vertices of the α angles.

More than 332 years separate the first formulation of the Fermat triangle problem and the discovery of its non-iterative numerical solution, while a geometrical solution existed for almost all that period of time. Is there an explanation for that? That explanation lies in the possibility of the origins of the three vectors oriented towards the three attraction points not coinciding. If those origins do coincide and lie at the optimum location P, the vectors oriented towards A, B and C, and the sides of the ABC location triangle form the six angles ∠1, ∠2, ∠3, ∠4, ∠5, and ∠6, and the three vectors form the ∠αA, ∠αB and ∠αC angles. It is easy to write the following six equations linking six unknowns (the angles ∠1, ∠2, ∠3, ∠4, ∠5, and ∠6) with six known values (angles ∠A, ∠B, and ∠C, whose values are given, and angles ∠αA, ∠αB and ∠αC, whose values depend only on the relative magnitude of the three attractive forces pointing towards the A, B and C attraction points):

∠1 + ∠2 = ∠C ;
∠3 + ∠4 = ∠A ;
∠5 + ∠6 = ∠B ;
∠1 + ∠6 + ∠αA = 180° ;
∠2 + ∠3 + ∠αB = 180° ;
∠4 + ∠5 + ∠αC = 180°.

Unfortunately, this system of six simultaneous equations with six unknowns is undetermined, and the possibility of the origins of the three vectors oriented towards the three attraction points not coinciding explains why. In the case of non-coincidence, we observe that all the six equations are still valid. However, the optimal location P has disappeared because of the triangular hole that exists inside the triangle. In fact, as Tellier (1972)[7] has shown, that triangular hole had exactly the same proportions as the “forces triangles” we drew in Simpson’s geometrical solution.

In order to solve the problem, we must add to the six simultaneous equations a seventh requirement, which states that there should be no triangular hole in the middle of the location triangle. In other words, the origins of the three vectors must coincide.

Tellier’s solution of the Fermat and Weber triangle problems involves three steps:

1– Determine the angles ∠αA, ∠αB and ∠αC that are such that the three attractives forces Aw, Bw and Cw cancel each other to ensure equilibrium. This is done by means of the following independent equations:

cos ∠αA = −( Bw2 + Cw2 − Aw2) / (2 Bw Cw)  ;
cos ∠αB = −( Aw2 + Cw2 − Bw2) / (2 Aw Cw)  ;
cos ∠αC = −( Aw2 + Bw2 − Cw2) / (2 Aw Bw)  ;

2– Determine the value of angle ∠3 (this equation derives from the requirement that point D must coincide with point E):

tan ∠3 = (k sin k’) / (1 + k cos k’) ;

where k = (CB/CA) (sin ∠αB / sin ∠αA), and k’ = (∠A +∠B + ∠αC) − 180° ;

3– Solve the following system of simultaneous equations where ∠3 is now known:

∠1 + ∠2 = ∠C ;
∠3 + ∠4 = ∠A ;
∠5 + ∠6 = ∠B ;
∠1 + ∠6 + ∠αA = 180° ;
∠2 + ∠3 + ∠αB = 180° ;
∠4 + ∠5 + ∠αC = 180°.

## Tellier’s trigonometric solution of the triangle attraction-repulsion problem

The angles of the attraction-repulsion triangle problem.
The case of non-coincidence of points D and E.

Tellier (1985)[8] extended the Fermat–Weber problem to the case of repulsive forces. Let us examine the triangle case where there are two attractive forces A1w and A2w, and one repulsive force Rw. Here as in the previous case, the possibility exists for the origins of the three vectors not to coincide. So the solution must require their coinciding. Tellier’s trigonometric solution of this problem is the following:

1– Determine angle ∠e :

cos ∠e = -( A1w2 + A2w2 − Rw2) / (2 A1w A2w)  ;

2– Determine angle ∠p :

cos ∠p = -( A1w2 + Rw2 − A2w2) / (2 A1w Rw)  ;

3– Determine angle ∠c :

∠c = 180° − ∠p ;

4– Determine angle ∠d :

∠d = ∠e − ∠c ;

5– Determine the value of angle ∠3 (this equation derives from the requirement that point D must coincide with point E):

tan ∠3 = x / y ;

where x = sin ∠f – (RA1/RA2)(sin ∠d sin [∠e − ∠b] / sin ∠c) ; and y = (RA1/RA2)(sin ∠d cos [∠e − ∠b] / sin ∠c) − cos ∠f ;

6– Determine ∠1 :

∠1 = 180° − ∠e − ∠3 ;

7– Determine ∠5 :

∠5 = 180° − ∠b − ∠c − ∠1 ;

8– Determine ∠2 :

∠2 = ∠a − ∠5 .

## Iterative solutions of the Fermat, Weber and attraction-repulsion problems

When the number of forces is larger than three, it is no longer possible to determine the angles separating the various forces without taking into account the geometry of the location polygon. Geometric and trigonometric methods are then powerless. Iterative optimizing methods are used in such cases. Kuhn and Kuenne (1962)[9] suggested an algorithm based on iteratively reweighted least squares generalizing Weiszfeld's algorithm for the unweighted problem. Their method is valid for the Fermat and Weber problems involving many forces, but not for the attraction–repulsion problem. In this method, to find an approximation to the point y minimizing the weighted sum of distances

$\sum_{i=1}^n w_i\, \|x_i-y\|,$

an initial approximation to the solution y0 is found, and then at each stage of the algorithm is moved closer to the optimal solution by setting yj + 1 to be the point minimizing the sum of weighted squared distances

$\sum_{i=1}^n \frac{w_i}{\|x_i-y_j\|} \|x_i-y\|^2$

where the initial weights wi of the input points are divided by the distances from each point to the approximation from the previous stage. As the unique optimal solution to a weighted least squares problem, each successive approximation may be found as a weighted average:

$\left. y_{j+1}=\left( \sum_{i=1}^n \frac{w_ix_i}{\| x_i - y_j \|} \right) \right/ \left( \sum_{i=1}^n \frac{w_i}{\| x_i - y_j \|} \right).$

For the attraction–repulsion problem one has instead to resort to the algorithm proposed by Chen, Hansen, Jaumard and Tuy (1992).[10]

## Interpretation of the land rent theory in the light of the attraction–repulsion problem

In the world of spatial economics, repulsive forces are omnipresent. Land values are the main illustration of them. In fact a substantial portion of land value theory, both rural and urban, can be summed up in the following way.

In the case where everybody is attracted by a single attraction point (the rural market or the urban central business district), competition between the various bidders who all want to locate at the center will generate land values that will transform the unique attraction point of the system into a repulsion point from the land value point of view, and, at the equilibrium, each inhabitant and activity will be located at the point where the attractive and the repulsive forces exerted by the center on them will cancel out.

## The attraction–repulsion problem and the New Economic Geography

The Tellier problem preceded the emergence of the New Economic Geography. It is seen by Ottaviano and Thisse (2005)[11] as a prelude to the New Economic Geography (NEG) that developed in the 1990s, and earned Paul Krugman a Nobel Memorial Prize in Economic Sciences in 2008. The concept of attractive force is akin to the NEG concept of agglomeration or centripetal force, and the concept of repulsive force is akin to the NEG concept of dispersal or centrifugal force.

## Notes

1. ^ Kuhn, Harold W. and Robert E. Kuenne, 1962, "An Efficient Algorithm for the Numerical Solution of the Generalized Weber Problem in Spatial Economics." Journal of Regional Science 4, 21–34.
2. ^ Tellier, Luc-Normand, 1972, “The Weber Problem: Solution and Interpretation”, Geographical Analysis, vol. 4, no. 3, pp. 215–233.
3. ^ Simpson, Thomas, 1750, The Doctrine and Application of Fluxions, London.
4. ^ Weber, Alfred, 1909, Über den Standort der Industrien, Tübingen, J.C.B. Mohr) — English translation: The Theory of the Location of Industries, Chicago, Chicago University Press, 1929, 256 pages.
5. ^ Tellier, Luc-Normand, 1985, Économie spatiale: rationalité économique de l'espace habité, Chicoutimi, Gaëtan Morin éditeur, 280 pages.
6. ^ Tellier, L.-N., 2013, « Annexe 1 : Solution géométrique du cas triangulaire du problème d’attraction-répulsion », annex of the paper of Pierre Hansen, Christophe Meyer and Luc-Normand Tellier, « Modèles topodynamique et de la Nouvelle économie géographique : compatibilité, convergence et avantages comparés », in Marc-Urbain Proulx (ed.), 2013, Sciences du territoire II : méthodologies, Québec, Presses de l’Université du Québec.
7. ^ Tellier, Luc-Normand, 1972, “The Weber Problem: Solution and Interpretation”, Geographical Analysis, vol. 4, no. 3, pp. 215–233.
8. ^ Tellier, L.N., 1985, Économie spatiale: rationalité économique de l'espace habité, Chicoutimi, Gaëtan Morin éditeur, 280 pages.
9. ^ Kuhn, Harold W. and Robert E. Kuenne, 1962, "An Efficient Algorithm for the Numerical Solution of the Generalized Weber Problem in Spatial Economics." Journal of Regional Science 4, 21–34.
10. ^ Chen, Pey-Chun, Hansen, Pierre, Jaumard, Brigitte and Hoang Tuy, 1992, "Weber's Problem with Attraction and Repulsion," Journal of Regional Science 32, 467–486.
11. ^ Ottaviano, Gianmarco and Jacques-François Thisse, 2005, « New Economic Geography: what about the N? », Environment and Planning A 37, 1707–1725.

## References

• Chen, Pey-Chun, Hansen, Pierre, Jaumard, Brigitte and Hoang Tuy, 1992, "Weber's Problem with Attraction and Repulsion," Journal of Regional Science 32, 467–486.
• Kuhn, Harold W. and Robert E. Kuenne, 1962, "An Efficient Algorithm for the Numerical Solution of the Generalized Weber Problem in Spatial Economics." Journal of Regional Science 4, 21–34.
• Ottaviano, Gianmarco and Jacques-François Thisse, 2005, « New Economic Geography: what about the N? », Environment and Planning A 37, 1707–1725.
• Simpson, Thomas, 1750, The Doctrine and Application of Fluxions, London.
• Tellier, Luc-Normand and Boris Polanski, 1989, “The Weber Problem: Frequency of Different Solution Types and Extension to Repulsive Forces and Dynamic Processes”, Journal of Regional Science, vol 29, no. 3, p. 387–405.
• Tellier, Luc-Normand, 1972, “The Weber Problem: Solution and Interpretation”, Geographical Analysis, vol. 4, no. 3, pp. 215–233.
• Tellier, Luc-Normand, 1985, Économie spatiale: rationalité économique de l'espace habité, Chicoutimi, Gaëtan Morin éditeur, 280 pages.
• Tellier, L.-N., 2013, « Annexe 1: Solution géométrique du cas triangulaire du problème d’attraction–répulsion », annex of the paper of Pierre Hansen, Christophe Meyer and Luc-Normand Tellier, « Modèles topodynamique et de la Nouvelle économie géographique : compatibilité, convergence et avantages comparés », in Marc-Urbain Proulx (ed.), 2013, Sciences du territoire II : méthodologies, Québec, Presses de l’Université du Québec.
• Weber, Alfred, 1909, Über den Standort der Industrien, Tübingen, J.C.B. Mohr) — English translation: The Theory of the Location of Industries, Chicago, Chicago University Press, 1929, 256 pages.
• Wesolowski, Georges, 1993, «The Weber problem: History and perspective», Location Science, Vol. 1, p. 5–23.


text:
# HPC - MPI Datatypes

Last updated: 2022-11-08

When you need to decompose a rectangular domain of size $$R \times C$$ among $$P$$ MPI processes, you usually employ a block decomposition by rows (Block, *): the first process handles the first $$R / P$$ lines; the second handles the next $$R / P$$ lines, and so on. Indeed, in the C language matrices are stored in row-major order, and a (Block, *) decomposition has each partition as a contiguous sub-array so that data transfers are greatly simplified.

In this exercise, on the other hand, we consider a column-wise decomposition in order to use MPI derived datatypes.

Write a program where processes 0 and 1 keep a local matrix of size $$\textit{SIZE} \times (\textit{SIZE}+2)$$ that include two columns of ghost cells (also called halo). In mpi-send-col.c we set SIZE=4, but the program must work with any value.

Process 0 and 1 initialize their local matrices as follows.

Process 0 must send the rightmost column to process 1, where it is inserted into the leftmost ghost area:

Similarly, process 1 must send the leftmost column to process 0, where it is placed into the rightmost ghost area.

You should define a suitable datatype to represent a matrix column, and use two MPI_Sendrecv() operations to exchange the data.

To compile:

    mpicc -std=c99 -Wall -Wpedantic mpi-send-col.c -o mpi-send-col.c

To execute:

    mpirun -n 2 ./mpi-send-col.c


text:
# A fast, robust DropWhile

For reasons that have never been entirely clear to me, Mathematica has had a built-in TakeWhile function since version 6.0, but has no equivalent DropWhile function. This means that I find myself periodically writing my own. Since this is a function that I use fairly frequently, I'd like to have a version that is both fast and robust. It's also the kind of function that you can write in a bunch of ways; I've tested variants that depend on While loops, on using Scan and Throw, and on using Position.

Of these, a version using Position is the fastest I've found:

DropWhile[list_, test_] :=
With[{pos =
Position[list, elt_ /; ! TrueQ@test[elt], {1}, 1, Heads -> False]},
pos /. {
{} -> {},
{{fail_}} :> Drop[list, fail - 1]
}];

The TrueQ slows things down a bit, but is there to match the observed behavior of TakeWhile, which takes elements only as long as the test function returns True. Are there good ways to make this function work faster?

-
Did you try DropWhile[{2, 4, 6, 1, 2, 3}, EvenQ]? I'm getting {1,2,3} as the answer... –  Rod Jul 2 '13 at 14:55
@RodLm Yes, that's the correct behavior. The function should drop elements until it finds one that doesn't satisfy the test. –  Pillsy Jul 2 '13 at 14:57
Oh, I see... Interesting question! +1 –  Rod Jul 2 '13 at 15:01
–  Mr.Wizard Jul 2 '13 at 15:12

## Simple solution

Why not just

dropWhile[list_, test_] := Drop[list, LengthWhile[list, test]]

?

## Fast JIT-based solution with automatic type identification / dispatch

Here I will show a solution that is potentially much faster on packed arrays. The code is directly modeled after this answer, so I refer to some additional details there.

### JIT version with type memoization

Here is the first ingredient: the specialized JIT version

ClearAll[dropWhileJIT];
dropWhileJIT[pred_,listType_,target:"MVM"|"C":"MVM"]:=
dropWhileJIT[pred,Verbatim[listType],target]=
Block[{l},
With[{decl={Prepend[listType,l]}},
Compile@@
Hold[
decl,
Module[{pos=1},
While[pred[l[[pos]]],pos++];Drop[l,pos-1]
],
CompilationTarget->target
]
]
]

which can be tested as

dropWhileJIT[# < 99999 &, {_Integer, 1}, "C"][Range[100000]] // AbsoluteTiming

(*  {5.481445, {99999, 100000}} *)

The second and subsequent times this will be blazingly fast:

dropWhileJIT[# < 99999 &, {_Integer, 1}, "C"][Range[100000]] // AbsoluteTiming

(* {0.000977, {99999, 100000}} *)

Here, we also should have a function to clear the cache:

ClearAll[clearDropWhileCache];
clearDropWhileCache[]:=
DownValues[dropWhileJIT]={Last[DownValues[dropWhileJIT]]};

which can be used to remove the memoized definitions.

### Automatic type identification and dispatch

Here we will use the following functions:

Clear[getType,$useCompile]; getType[arg_List]/;$useCompile&&ArrayQ[arg,_,IntegerQ]:=
{_Integer,Length[Dimensions[arg]]};
getType[arg_List]/;$useCompile&&ArrayQ[arg,_,NumericQ]&&Re[arg]==arg:= {_Real,Length[Dimensions[arg]]}; getType[_]:= General;  and Clear[dropWhileDispatch]; dropWhileDispatch[ t:{Verbatim[_Integer]|Verbatim[_Real]|Verbatim[_Complex],n_},pred_ ]:= dropWhileJIT[pred,t,$target];

dropWhileDispatch[_,pred_]:=
dropWhileGeneric[#1,pred]&;

### Final functions

Here is our previous generic implementation (I changed the name):

ClearAll[dropWhileGeneric];
dropWhileGeneric[list_,test_]:=
Drop[list,LengthWhile[list,test]]

and here is a final function:

ClearAll[dropWhile];
Options[dropWhile]={CompileToC->False,Compiled->True};
dropWhile[lst_List,pred_,opts:OptionsPattern[]]:=
Block[
{
$target=If[TrueQ[OptionValue[CompileToC]],"C","MVM"],$useCompile=TrueQ[OptionValue[Compiled]]
},
dropWhileDispatch[getType[lst],pred][lst]
];

### Benchmarks

JIT-compilation to MVM is really fast:

clearDropWhileCache[];
dropWhile[Range[100000], # < 99999 &] // AbsoluteTiming

(* {0.007813, {99999, 100000}} *)

The second time is faster still, since we don't have to recompile:

dropWhile[Range[100000], # < 99999 &] // AbsoluteTiming

(* {0.006836, {99999, 100000}} *)

The compilation to C is quite slow:

dropWhile[Range[100000], # < 99999 &,CompileToC -> True] // AbsoluteTiming

(* {4.640625, {99999, 100000}} *)

But gives a considerable further speedup:

dropWhile[Range[100000], # < 99999 &,CompileToC -> True] // AbsoluteTiming

(* {0.001953, {99999, 100000}} *)

Here is what we get from the generic implementation:

dropWhile[Range[100000], # < 99999 &, Compiled -> False] // AbsoluteTiming

(* {0.157226, {99999, 100000}} *)

It is not as bad as it could have been, since LengthWhile by itself is optimized on packed arrays, but it does not compare with the JIT versions.

### The complete code

ClearAll[dropWhileJIT];
dropWhileJIT[pred_,listType_,target:"MVM"|"C":"MVM"]:=
dropWhileJIT[pred,Verbatim[listType],target]=
Block[{l},
With[{decl={Prepend[listType,l]}},
Compile@@
Hold[
decl,
Module[{pos=1},
While[pred[l[[pos]]],pos++];Drop[l,pos-1]
],
CompilationTarget->target
]
]
]

Clear[getType,$useCompile]; getType[arg_List]/;$useCompile&&ArrayQ[arg,_,IntegerQ]:=
{_Integer,Length[Dimensions[arg]]};
getType[arg_List]/;$useCompile&&ArrayQ[arg,_,NumericQ]&&Re[arg]==arg:= {_Real,Length[Dimensions[arg]]}; getType[_]:= General; Clear[dropWhileDispatch]; dropWhileDispatch[ t:{Verbatim[_Integer]|Verbatim[_Real]|Verbatim[_Complex],n_},pred_ ]:= dropWhileJIT[pred,t,$target];

dropWhileDispatch[_,pred_]:=
dropWhileGeneric[#1,pred]&;

ClearAll[dropWhileGeneric];
dropWhileGeneric[list_,test_]:=
Drop[list,LengthWhile[list,test]]

ClearAll[dropWhile];
Options[dropWhile]={CompileToC->False,Compiled->True};
dropWhile[lst_List,pred_,opts:OptionsPattern[]]:=
Block[
{
$target=If[TrueQ[OptionValue[CompileToC]],"C","MVM"],$useCompile=TrueQ[OptionValue[Compiled]]
},
dropWhileDispatch[getType[lst],pred][lst]
];

ClearAll[clearDropWhileCache];
clearDropWhileCache[]:=
DownValues[dropWhileJIT]={Last[DownValues[dropWhileJIT]]};

-
That's... a good question. This is somewhat faster than my version, and it's much simpler. –  Pillsy Jul 2 '13 at 15:51
@Pillsy See my edit. –  Leonid Shifrin Jul 2 '13 at 15:55
By the way, it just crossed my mind that a better design would have been to optimize LengthWhile and then always use the simple solution with that optimized lengthWhile - this way we get LengthWhile (and potentially also TakeWhile) optimizations for free. –  Leonid Shifrin Jul 2 '13 at 16:03


text:
# Find the 8th Term from the End of the A.P. 7, 10, 13, ..., 184 - Mathematics

Find the 8th term from the end of the A.P. 7, 10, 13, ..., 184

#### Solution

In the given problem, we need to find the 8th term from the end for the given A.P.

We have the A.P as 7, 10, 13 …184

Here, to find the 8th term from the end let us first find the total number of terms. Let us take the total number of terms as n.

So,

First term (a) = 7

Last term (an) = 184

Common difference (d) = 10 - 7 = 3

Now, as we know,

a_n = a + (n - 1)d

So, for the last term,

184 = 7 + (n -1)3

184 = 7 + 3n - 3

184 = 4 + 3n

184 - 4 = 3n

Further simplifying,

180 = 3n

n = 180

n = 60

So, the 8th term from the end means the 53rd term from the beginning.

So, for the 53rd term (n = 53)

a_53 = 7 + (53 - 1)3

= 7 + (52)3

= 7 + 156

= 163

Therefore, the 8th term from the end of the given A.P. is 163

Is there an error in this question or solution?

#### APPEARS IN

RD Sharma Class 10 Maths
Chapter 5 Arithmetic Progression
Exercise 5.4 | Q 33 | Page 26

Share


text:
# Local calibrations for minimizers of the Mumford-Shah functional with a regular discontinuity set

created on 14 Dec 2001
modified on 17 Mar 2003

[BibTeX]

Published Paper

Inserted: 14 dec 2001
Last Updated: 17 mar 2003

Journal: Ann. Inst. H. Poincaré Anal. Nonlin.
Volume: 18
Pages: 403-436
Year: 2001

Abstract:

Using a calibration method, we prove that, if $w$ is a function which satisfies all Euler conditions for the Mumford-Shah functional on a two-dimensional open set $\Omega$, and the discontinuity set $S_w$ of $w$ is a regular curve connecting two boundary points, then there exists a uniform neighbourhood $U$ of $S_w$ such that $w$ is a minimizer of the Mumford-Shah functional on $U$ with respect to its own boundary conditions on $\partial U$. We show that Euler conditions do not guarantee in general the minimality of $w$ in the class of functions with the same boundary value of $w$ on $\partial \Omega$ and whose extended graph is contained in a neighbourhood of the extended graph of $w$, and we give a sufficient condition in terms of the geometrical properties of $\Omega$ and $S_w$ under which this kind of minimality holds.

Credits | Cookie policy | HTML 5 | CSS 2.1


text:
Wireless Support

WPA-PSK Windows Configuration Guides

 Introduction The purpose of this document is to describe the procedure to configure DOE NextGen Wireless WPA-PSK on Windows XP, and Windows 7 laptops. WPA-PSK configuration requires that you supply a Passphrase, otherwise known as Pre-Shared Key.  You can get the Pre-Shared key that corresponds to your school from the DOE Wireless Support Site. WPA-PSK Windows XP Configuration Guide WPA-PSK Windows 7 Configuration Guide


text:
# The biggest value for sin(x)/x

Tags:
1. Aug 15, 2015

### Stephanus

Dear PF Forum,
Finally I have written a simple software to plot Sin(X)

It can also draw y = sin(x) + cos(x). But I don't know how to use this function in real life.

This software is very simple.
All you need to do is altering this short function
Code (Text):
case FDrawMode of
0: Result:=Sin(X)+Cos(X);
1: Result:=Sin(X);
2: Result:=Cos(X);
3: Result:=Sin(X)/X;
end;

Don't forget to alter this line also.
Code (Text):
LS:=edtDrawMode.Items;
LS.Clear;

If you see the last line. LS.Add('y = Sin(x)/x');.
What if X is zero?
I cheat
Put catch exception in the code.
Code (Text):
try
Y:=ScaleY*Fc*                 CalcY(X+Sh); // case of sin(x)/x; if x = 0 then CalcY(X) will cause error.
YY:=Height1-Round(Y);
CV.Pixels[XX,YY]:=PlotColor;
except
// if error then don't draw anything
end;

Funnily the computer still draw the curve as it is supposed to be.
And interesting enough. for sin(x)/x the biggest value is 1 for $\lim_{h \to 0} \frac{\sin(h)}{h}$.
But how to proof that the biggest value for sin(x)/(x) is lim h -> 0?
The graph shows that, but we just can't say. "Well the graph shows that, so the biggest value for sin(x)/(x) is 1",
Anyone interested to proof it?

2. Aug 15, 2015

### Stephanus

I think the logical tought is this:
The biggest value for F(x)/x is if x is almost zero.
It makes sense, if x is 4 pi or 8 pi, the value will almost zero, too.
But if x is almost zero then Sin(x) is also almost zero, too.
Hmm, anyone can give a bettter opinon?

3. Aug 15, 2015

### micromass

Staff Emeritus
The function $\frac{sin(x)}{x}$ is not defined in $0$. Thus it never becomes $1$. The function has no biggest value.

4. Aug 15, 2015

### micromass

Staff Emeritus
Anyway, finding the biggest value (maximum) of a function is a simple exercise with derivatives. Any calculus book should cover this in their section of derivatives.

5. Aug 15, 2015

### Stephanus

So the "proof" that $lim_{h \to 0} \frac{\sin(h)}{h}$ is not a "proof"? Thanks, I don't want to argue. Just want to know what other thinks.

6. Aug 15, 2015

### Stephanus

"Exercise", I like that.

7. Aug 15, 2015

### micromass

Staff Emeritus
I don't see how $\lim_{h\rightarrow 0} \frac{\sin(h)}{h}$ is at all relevant here.

8. Aug 15, 2015

### Stephanus

Thanks micromass, I don't even see it at the slightest either. It's just an interesting graph, I wouldn't know the answer before the computer shows it. Just want confirmation.

9. Aug 15, 2015

### HallsofIvy

Staff Emeritus
You "just want confirmation" of what?

That function does NOT HAVE a largest value. Its value, for any x, is less than 1 but comes arbitrarily close to 1.

Then you talk about the limit as x goes to 0 which is a completely different question! Yes, the limit, as x goes to 0, of sin(x)/x is 1. There are a number of different ways to show that depending on exactly which definition of sin(x) you are using. But that is NOT the value of the function at x= 0 because the function is NOT DEFINED at x= 0.
There is a "removable discontinuity" at x= 0. You could "remove" it by defining f(x)= sin(x)/x if x is not 0, f(0)= 1. But that would be a different function.

10. Aug 15, 2015

### Staff: Mentor

Sometimes that is the case, in this case though you know the sin(x) and you know that its periodic however the x increases and reduces the amplitude of the sin(x) so you should expect it to dampen out and approach zero at very large x values. For me the interesting part is where x<1 and the combination of sin(x) / x complements one another to create the curve shown.

You should try other trig functions to see how they act like cos(x)/x or tan(x)/x or (sin(x)+cos(x))/x as well as other functions you learn about and develop a skill to be able to look at a function and sketch how it will look without the computer's help.

11. Aug 15, 2015

### Stephanus

Confirmation if I'm right or wrong. First I imagine what is the biggest value for sin(x)/x? I think it might, it might not be x = 0. But one thing for sure.
$\lim_{h \to 0} \frac{\sin(h)}{h}$ is 1
And x = pi/2; sin(x)/x is 0. So if we think linearly, it seems from x = 0 to pi/2 the value should decrease right? (or wrong?)
Then I intend to write a computer software, not to find this answer, but because of this:
Then I have time this afternoon, so I wrote a simple program.
Part of the code.
Code (Text):
case FDrawMode of
0: Result:=Sin(X)+Cos(X);
1: Result:=Sin(X);
2: Result:=Cos(X);
3: Result:=Sin(X)/X; // ADDED LATER ON
end;

Then you can see the result as the graph above about sin(x)/x.
"The computer DOES NOT show error if x=0??" Don't worry I cheat , see my post above.
Okay, so I see the graph, it seems that if x close to zero sin(x)/x is the highest.
But you know about computer variable. I use a very rough calculation, loop by 0.0001*pi step. And 0.0001 is very rough for math but not for computer variable.
So there remains some question.
1. Isn't there along the line from x = 0 to pi/2 a spike where sin(x)/x is bigger than 1?
2. Sin(x)/x looks (yes, "looks", because it's shown on the screen) highest at x = 0, but x can't be zero, right?
3. Is this true that the biggest value for sin(x)/x is $\lim_{x \to 0} \frac{\sin(x)}{x}$
But:
Okay, so I'm satisfied enogh with micromass answer.

Yes.
Code (C):
double SinXPerX1(double arc)
{
return(Sin(arc)/arc);
}

double SinXPerX2(double arc)
{
if(arc==0) return(1); else return(Sin(arc)/arc);
}

Agreed, it's different functions.

12. Aug 15, 2015

### micromass

Staff Emeritus
No.

Right.

No.

13. Aug 15, 2015

### Stephanus

Come on micromass. I didn't ask that. I'm afraid I have already asked too many questions a day. But that WAS my doubt, and I'm already satisfied with this:
But, thank you very much for your answer. It removes my doubts. I'm afraid I have asked too many questions.

14. Aug 15, 2015

### Stephanus

It seems Cos(x)/x similar to (Sin(x)+Cos(x))/x

15. Aug 15, 2015

### Stephanus

Code (Text):
case FDrawMode of
0: Result:=Sin(X)+Cos(X);
1: Result:=Sin(X);
2: Result:=Cos(X);
3: Result:=Sin(X)/X;
5: Result:=Sin(X)/Cos(X)/X; // has to change tan to sin/cos, no Tan function in Delphi
6: Result:=(Sin(x)+Cos(x))/x
end;

Alter it, compile it, run it, save the graph and upload it.
Hmm.., I didn't think that tan(x)/x will look like that. Picture it without computer or paper? Well, I'm not Descartes, but I'll try.

16. Aug 15, 2015

### Staff: Mentor

IMO, the most important point here is the difference between a function's value (which might not exist) at a particular point and the limit of a function at that point. Two of your graphs are significant here: the graphs of $y = \frac{sin(x)}{x}$ and $y = \frac{tan(x)}{x}$.

Both graphs appear to show a point at (0, 1). In fact, neither function is defined when x = 0. The graphing software (the program you wrote in Delphi) plots a number of points and then connects the dots.

Even though both functions are undefined at x = 0, both functions have limits that exist as x approaches 0. In mathematical notation $\lim_{x \to 0}\frac{sin(x)}{x} = 1$ and $\lim_{x \to 0}\frac{tan(x)}{x} = 1$. It's very easy to show that the latter limit can be gotten once you know the first limit.
$\lim_{x \to 0}\frac{tan(x)}{x} = \lim_{x \to 0}\frac{sin(x)}{cos(x) \cdot x} = \lim_{x \to 0}\frac{1}{cos(x)} \cdot \lim_{x \to 0}\frac{sin(x)}{x}$.

The first limit is clearly 1, since cos(0) = 1, and we know that the second limit is 1.

17. Aug 15, 2015

### Stephanus

Hi Mark44, it's been a while since you answer my post in: https://www.physicsforums.com/threads/proof-limit-derivatave-of-sin-x.826864/page-3#post-5198643
Thanks a lot! A good point! Function value which might not exist vs the limit of that function in that point.
Yes both are undefined at x = 0.
Just plot the dots not connect it.
I put something like it in the software.
Code (Text):
try // begin catch error
Y = sin(x)/X; // calculate Y
PuPixel(X,Y); // Draw the result
except
// catch any error
// don't do anything
end;

The original code is at my first post above.
Yes, yes I know. You've given me this lecture since 2 weeks ago. Thanks
Proof why tan(x)/x = 1? Perhaps later. For now, I'm already satisfied that I can proof why $\lim_{h \to 0} \frac{\sin(h)}{h} = 1$
Ahh, that's the proof? Very simple actually.