text:
Mathematics for Chemistry/Matrices and Determinants

Simultaneous linear equations
If we have 2 equations of the form $$y = {\rm m} x + {\rm c}$$ we may have a set of simultaneous equations. Suppose two rounds of drinks are bought in a cafe, one round is 4 halves of orange juice and 4 packets of crisps. This comes to 4 pounds 20. The thirstier drinkers at another table buy 4 pints of orange juice and only 1 packet of crisps and this comes to 6 pounds 30. So we have:

$$4.20 = 2 x + 4 y$$

and

$$6.30 = 4 x + y$$

i.e. $$y = \frac {4.20}  4 - \frac 2 4 x  ~ {\rm and}   y =  6.30 - 4 x$$

If you plot these equations they will be simultaneously true at $$ x=1.5$$ and $$y = 0.30$$.

Notice that if the two rounds of drinks are 2 pints and 2 packets of crisps and 3 pints and 3 packets of crisps we cannot solve for the prices! This corresponds to two parallel straight lines which never intersect.

If we have the equations:

$$3 x + 4 y = 4$$

$$3 x + 2 y = 1$$

If these are simultaneously true we can find a unique solution for both $$x$$ and $$y$$.

By subtracting the 2 equations a new equation is created where $$x$$ has disappeared and the system is solved.

$$2y = 3$$

Substituting back $$y = 1.5$$ gives us $$x$$.

This was especially easy because $$x$$ had the same coefficient in both equations. We can always multiply one equation throughout by a constant to make the coefficients the same.

If the equations were:

$$3x + 4y = 4$$

and

$$6x + 8y = 8$$

things would go horribly wrong when you tried to solve them because they are two copies of the same equation and therefore not simultaneous. We will come to this later, but in the meantime notice that 3 times 8 = 4 times 6. If our equations were:

$$3 x + 4 y + 9 z = 4$$

$$3 x + 2 y - 4 z = 1$$

$$9 x + 2 y - 2 z = 1$$

we can still solve them but would require a lot of algebra to reduce it to three (2x2) problems which we know we can solve. This leads on to the subject of matrices and determinants.

Simultaneous equations have applications throughout the physical sciences and range in size from (2x2)s to sets of equations over 1 million by 1 million.

Practice simultaneous equations
Solve:

$$x - 2y = 1$$

$$x + 4y = 8$$

and

$$x + 5y = 10$$

$$7x - 4y =10$$

Notice that you can solve:

$$3 x + 4 y + 9 z = 4$$

$$3 x + 2 y - 4 z = 1$$

$$0 x + 0 y - 2 z = 1$$

because it breaks down into a (2x2) and is not truly a (3x3). (In the case of the benzene molecular orbitals, which are (6x6), this same scheme applies. It becomes two direct solutions and two (2x2) problems which can be solved as above.)

Matrices
The multiplication of matrices has been explained in the lecture.

$$A = \begin{pmatrix}0 & 1 & 2\\ 0 & -1 & -2\\ \end{pmatrix} B = \begin{pmatrix}3 & -3\\ 4 & -4\\ 5 & -5\\ \end{pmatrix} ~AB = \begin{pmatrix}14 & -14\\ -14 & 14\\ \end{pmatrix}$$

$$BA = \begin{pmatrix}0 & 6 & 12\\ 0 & 8 & 16\\ 0 & 10 & 20\\ \end{pmatrix}$$

$${\rm if} A = \begin{pmatrix}1 & 2 & 3\\ \end{pmatrix}  ~ {\rm and}   B = \begin{pmatrix} 4 & 5\\ 6 & 7\\ 8 & 9\\ \end{pmatrix}  ~ AB = \begin{pmatrix}40 & 60\\ \end{pmatrix}$$

but $$BA$$ cannot exist. To be multiplied two matrices must have the 1st matrix with the same number of elements in a row as the 2nd matrix has elements in its columns.

$$a_{ij} = \Sigma_k a_{ik} b_{kj}$$

where the $$a_{ij}$$s are the elements of $$A$$.

$$\begin{pmatrix} a_{11} & a_{12} & a_{13}\\ a_{21} & a_{22} & a_{23}\\ a_{31} & a_{32} & a_{33}\\ \end{pmatrix}$$

Look at our picture of $$\cos$$ and $$\sin$$ as represented by a unit vector in a circle. The rotation of the unit vector $${\hat j}$$ about the $$z$$-axis can be represented by the following mathematical construct.

$$\begin{pmatrix} \cos (\theta) & \sin (\theta) & 0  \\ -\sin (\theta) & \cos (\theta) & 0  \\ 0 & 0 & 1  \\ \end{pmatrix}$$

$$\begin{pmatrix} 0  \\ 1   \\ 0   \\ \end{pmatrix} = \begin{pmatrix} \sin (\theta)   \\ \cos (\theta)  \\ 0  \\ \end{pmatrix}$$

In two dimensions we will rotate the vector at 45 degrees between $$x$$ and $$y$$:

$$\begin{pmatrix} \cos (\theta) & \sin (\theta)   \\ -\sin (\theta) & \cos (\theta)  \\ \end{pmatrix} \begin{pmatrix} \frac r {\sqrt 2}  \\ \frac r {\sqrt 2}  \\ \end{pmatrix} = \begin{pmatrix} \frac {r \cos \theta} {\sqrt 2} + \frac {r \sin \theta} {\sqrt 2} \\ \frac {-r \sin \theta} {\sqrt 2} + \frac {r \cos \theta} {\sqrt 2} \\ \end{pmatrix} = \begin{pmatrix} r  \\ 0  \\ \end{pmatrix}$$

This is if we rotate by +45 degrees. For $$\theta = -45^o$$ $$\cos(-45) = \cos 45$$ and $$\sin(-45) = -\sin 45$$. So the rotation flips over to give $$( 0 1 )$$. The minus sign is necessary for the correct mathematics of rotation and is in the lower left element to give a right handed sense to the rotational sign convention.

As discussed earlier the solving of simultaneous equations is equivalent in some deeper sense to rotation in $$n$$-dimensions.

Matrix multiply practice
i) Multiply the following (2x2) matrices.

$$ \begin{pmatrix} 3& 5  \\ 6 & 4   \\ \end{pmatrix} $$ $$ \begin{pmatrix} 1& 2  \\ 3 & 4   \\ \end{pmatrix} $$ = $$ \begin{pmatrix} 3 {\rm x} 1 + 5 {\rm x} 3& 3 {\rm x} 2 + 5 {\rm x} 4  \\ 6 {\rm x} 1 + 4 {\rm x} 3 & 6 {\rm x} 2 + 4 {\rm x} 4  \\ \end{pmatrix} $$

ii) Multiply the following (3x3) matrices.

$$ \begin{pmatrix} 38.15 & -42.17& 4.02  \\ 4.69 & 0.76 & -5.35   \\ -9.94 & 8.20 & 2.74   \\ \end{pmatrix} $$ $$ \begin{pmatrix} 0.205 & 0.665& 1  \\ 0.181 & 0.647 & 1   \\ 0.207 & 0.476 & 1   \\ \end{pmatrix} $$

You will notice that this gives a unit matrix as its product.

$$ \begin{pmatrix} 1 & 0 & 0  \\ 0& 1 &0   \\ 0& 0 &1   \\ \end{pmatrix} $$

The first matrix is the inverse of the 2nd. Computers use the inverse of a matrix to solve simultaneous equations.

If we have $$ \begin{pmatrix} y_1 = a_{11} x_1 + a_{12} x_2 + a_{13} x_3 ..... + a_{1n} x_n \\ y_2 = a_{21} x_2 + a_{22} x_2 + a_{23} x_3 ..... + a_{2n} x_n \\ ..... \\ .....  \\ y_n = a_{n1} x_n + a_{n2} x_n + a_{n3} x_3 ..... + a_{nn} x_n\\ \end{pmatrix} $$

In matrix form this is....

$$ Y = AX $$

$$ A^{-1}Y=X $$

In terms of work this is equivalent to the elimination method you have already employed for small equations but can be performed by computers for $$10~000$$ simultaneous equations.

(Examples of large systems of equations are the fitting of reference data to 200 references molecules, dimension 200, or the calculation of the quantum mechanical gradient of the energy where there is an equation for every way of exciting 1 electron from an occupied orbital to an excited, (called virtual, orbital, (typically $$10~000$$ equations.)

Finding the inverse
How do you find the inverse... You use Maple or Matlab on your PC but if the matrix is small you can use the formula...

$$A^{-1} = \frac 1 {Det A} Adj A$$

Here Adj A is the adjoint matrix, the transposed matrix of cofactors. These strange objects are best described by example.....

$$\begin{vmatrix} 1 & -1 & 2 \\ 2 & 1 & 1  \\ 3 & -1 & 1  \\ \end{vmatrix}$$

This determinant is equal to:  1 ( 1 x 1 - 1 x (-1)) - (-1) ( 2 x 1 - 1 x 3) + 2 ( 2 x (-1) - ( 1 x 3) each of these terms is called a cofactor.

$$\begin{vmatrix} a_{11} & a_{12}  & a_{13}   \\ a_{21} & a_{22}  & a_{23}   \\ a_{31} & a_{32}  & a_{33} \\ \end{vmatrix}$$

$$ Det A = -1^{i+j-1} \begin{pmatrix} a_{11} ( a_{22}   a_{33} - a_{23}   a_{32} ) \\ + -1^{i+j-1} a_{12} ( a_{21}   a_{33} - a_{23}   a_{31} ) \\ + -1^{i+j-1} a_{13} ( a_{21}   a_{32} - a_{22}   a_{31} ) \\ \end{pmatrix}$$

This $$ -1^{i+j-1}$$ thing gives the sign alternation in a form mathematicians like even though it is incomprehensible.

Use the determinant

$$\begin{vmatrix} 1 & -1 & 2 \\ 2 & 1 & 1  \\ 3 & -1 & 1  \\ \end{vmatrix}$$

to solve the simultaneous equations on page 47 by the matrix inverse method. The matrix corresponding to the equations on p47.2 is:

1     -1      2                 6

2      1      1          =      3

3     -1      1                 6

The cofactors are

2      1     -5

-1     -5     -2

-3      3      3

You may find these 9 copies of the matrix useful for striking out rows and columns to form this inverse....

1   -1    2      1    -1    2        1    -1    2    2     1    1      2     1    1        2     1    1    3    -1    1      3    -1    1        3    -1    1

1   -1    2      1    -1    2        1    -1    2    2     1    1      2     1    1        2     1    1    3    -1    1      3    -1    1        3    -1    1

1   -1    2      1    -1    2        1    -1    2    2     1    1      2     1    1        2     1    1    3    -1    1      3    -1    1        3    -1    1

These are the little determinants with the -1 to the (n-1) factors and the value of the determinant is -9.

The transposed matrix of cofactors is

2     -1     -3

1     -5      3

-5     -2      3

So the inverse is

2     -1     -3

-1/9 X      1      -5      3

-5     -2      3

Giving a solution

2     -1     -3         6          1

-1/9 X      1      -5      3    X    3     =   -1

-5     -2      3         6          2

This takes a long time to get all the signs right. Elimination by subtracting equations is MUCH easier. However as the computer cannot make sign mistakes it is not a problem when done by computer program.

The following determinant corresponds to an equation which is repeated three times giving an unsolvable set of simultaneous equations.

$$\begin{vmatrix} 1 & 2 & 3 \\ -1 & -2 & -3  \\ 2 & 4 & 6  \\ \end{vmatrix}$$

Matrix multiplication is not necessarily commutative, which in English means $$AB$$ does not equal $$BA$$ all the time. Multiplication may not even be possible in the case of rectangular rather than square matrices.

I will put a list of the properties and definitions of matrices in an appendix for reference through the later years of the course.

Determinants and the Eigenvalue problem
In 2nd year quantum chemistry you will come across this object: $$\begin{vmatrix} \alpha - E & \beta  & 0 & 0  \\ \beta & \alpha -E & \beta &  0  \\ 0 & \beta & \alpha -E & \beta   \\ 0 & 0 & \beta & \alpha -E   \\ \end{vmatrix} = 0$$

You divide by $$\beta$$ and set $$(\alpha - E ) / \beta$$ to equal $$x$$ to get:

$$\begin{vmatrix} x & 1 & 0 & 0  \\ 1 & x & 1 &  0  \\ 0 & 1 & x & 1   \\ 0 & 0 & 1 & x   \\ \end{vmatrix} = 0$$

Expand this out and factorise it into two quadratic equations to give:

$$(x^2 +x -1)(x^2-x-1)= 0$$

which can be solved using $$x = -b \pm etc.$$

Simultaneous equations as linear algebra
The above determinant is a special case of simultaneous equations which occurs all the time in chemistry, physics and engineering which looks like this:

$$\begin{pmatrix} ( a_{11} - \lambda ) x_1 + a_{12} x_2 + a_{13} x_3 ..... + a_{1n} x_n = 0  \\ a_{21} x_2 + ( a_{22} - \lambda ) x_1 + a_{23} x_3 ..... + a_{2n} x_n = 0  \\ ..... \\ .....  \\ a_{1n} x_n + a_{2n} x_n + a_{n3} x_3 ..... + ( a_{11} - \lambda ) x_1 = 0\\ \end{pmatrix}$$

This equation in matrix form is $$({\mathbf A} - \lambda {\mathbf 1}) {\mathbf x} = 0$$ and  the solution is $${\rm Det }({\mathbf A} - \lambda {\mathbf 1}) = 0$$.

This is a polynomial equation like the quartic above. As you know polynomial equations have as many solutions as the highest power of $$x$$ i.e. in this case $$n$$. These solutions can be degenerate for example the $$\pi$$ orbitals in benzene are a degenerate pair because of the factorisation of the $$x^6$$ polynomial from the 6 Carbon-pz orbitals. In the 2nd year you may do a lab exercise where you make the benzene determinant and see that the polynomial is

$$(x^2-4) (x^2-1) (x^2-1) = 0$$

from which the 6 solutions and the orbital picture are immediately obvious.

The use of matrix equations to solve arbitrarily large problems leads to a field of mathematics called linear algebra.

Matrices with complex numbers in them
Work out the quadratic equation from the 3 determinants

$$\begin{vmatrix} x & i   \\ -i & x  \\ \end{vmatrix} ~ \begin{vmatrix} x & 1   \\ 1 & x  \\ \end{vmatrix} ~ \begin{vmatrix} x & \frac 1 {\sqrt 2} + \frac i {\sqrt 2}   \\ \frac 1 {\sqrt 2} - \frac i {\sqrt 2} & x   \\ \end{vmatrix}$$

They are all the same! This exemplifies a deeper property of matrices which we will ignore for now other than to say that complex numbers allow you to calculate the same thing in different ways as well as being the only neat way to formulate some problems.


text: Political Philosophy: Ancient to Renaissance/Maps

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Greek Mythology/Heroes/Odysseus

Odysseus (also referred to as Ulysses in later Roman myths) is the hero in the story The Odyssey.

He was the king of Ithaca, was married to a lady by the name of Penelope, and had a son, Telemachus. He fought against the Trojans in the Trojan War. He is especially noted for his cleverness throughout Homer's poem. He was favored by the goddess Athena.

He's most famous for coming up with the idea of building the Trojan Horse and constructing that particular plan of attack. This idea came to him after ten long years of war. After the destruction of Troy, he and his men left for home without paying proper respect to Poseidon. For this, Poseidon punished Odysseus with what turned out to be a ten year journey home to Ithaca. Further insults against Poseidon complicated this journey. One insult includes the blinding of the Cyclops Polyphemus, who was the son of Poseidon. For this, Poseidon vowed Odysseus would never see his home. It wasn't until Athena petitioned Zeus for his safe return home that it actually happened.

Mitologi Yunani/Odiseus

title: Greek Mythology/Heroes/Odysseus


text:
Political Philosophy: Ancient to Renaissance/The Historians/Thucydides

(raw materials)
From William James' Moral Equivalent of War:

In modern eyes, precious though wars may be they must not be waged solely for the sake of the ideal harvest. Only when forced upon one, is a war now thought permissible.

It was not thus in ancient times. The earlier men were hunting men, and to hunt a neighboring tribe, kill the males, loot the village and possess the females, was the most profitable, as well as the most exciting, way of living. Thus were the more martial tribes selected, and in chiefs and peoples a pure pugnacity and love of glory came to mingle with the more fundamental appetite for plunder.

Modern war is so expensive that we feel trade to be a better avenue to plunder; but modern man inherits all the innate pugnacity and all the love of glory of his ancestors. Showing war's irrationality and horror is of no effect on him. The horrors make the fascination. War is the strong life; it is life in extremis; war taxes are the only ones men never hesitate to pay, as the budgets of all nations show us.

History is a bath of blood. The Illiad is one long recital of how Diomedes and Ajax, Sarpedon and Hector killed. No detail of the wounds they made is spared us, and the Greek mind fed upon the story. Greek history is a panorama of jingoism and imperialism -- war for war's sake, all the citizen's being warriors. It is horrible reading -- because of the irrationality of it all -- save for the purpose of making "history" -- and the history is that of the utter ruin of a civilization in intellectual respects perhaps the highest the earth has ever seen.

Those wars were purely piratical. Pride, gold, women, slaves excitement were their only motives. In the Peloponesian war, for example, the Athenians ask the inhabitants of Melos (the island where the "Venus de Milo" was found), hitherto neutral, to own their lordship. The envoys meet, and hold a debate which Thucydides gives in full, and which, for sweet reasonableness of form, would have satisfied Matthew Arnold. "The powerful exact what they can," said the Athenians, "and the weak grant what they must." When the Meleans say that sooner than be slaves they will appeal to the gods, the Athenians reply, "Of the gods we believe and of men we know that, by a law of their nature, wherever they can rule they will. This law was not made by us, and we are not the first to have acted upon it; we did but inherit it, and we know that you and all mankind, if you were as strong as we are, would do as we do. So much for the gods; we have told you why we expect to stand as high in their good opinion as you." Well, the Meleans still refused, and their town was taken. "The Athenians," Thucydides quietly says, "thereupon put to death all who were of military age and made slaves of the women and children. They then colonized the island, sending thither five hundred settlers of their own."

The translation of Thucydides used here is that of Thomas Hobbes. Although the language is rather antiquated, the student of political philosophy will find special interest in Hobbes' translation, especially if her interest in political philosophy extends into the modern period. The editor's notes, will, however, make note of some significant differences between this and more contemporary translations. Also, if a passage is particularly confusing, it may be worthwhile to consult the Benjamin Jowett translation, also in the public domain:

http://www.gutenberg.org/etext/7142


text:
Political Philosophy: Ancient to Renaissance/Plato/Euthyphro

(raw materials)
Euthyphro


text:
Political Philosophy: Ancient to Renaissance/Plato/Meno

(raw materials)
Plato's Meno


text:
Political Philosophy: Ancient to Renaissance/Plato/Apology

(raw materials)
Plato's Apology


text:
Political Philosophy: Ancient to Renaissance/Plato/Republic

(raw materials)
Benjamin Jowett's introduction

 * /Book I/
 * /Book II/
 * /Book III/
 * /Book IV/
 * /Book V/
 * /Book VI/
 * /Book VII/
 * /Book VIII/
 * /Book IX/
 * /Book X/


text:
Political Philosophy: Ancient to Renaissance/Aristotle/Nicomachean

(raw materials)
Aristotle was born in Stagira, on the peninsula of Chalcidice in 384 BC. His father, Nicomachus, was court physician to King Amyntas III of Macedonia. It is believed that Aristotle's ancestors held this position under various kings soon got too heavy. Macedonia did not know what to do. Let's go to the school, instead he was taught by his father. His father's medical knowledge was perhaps the inspiration for Aristotle's later interest in natural phenomena.

Little is known about his mother, Phaestis, who died early in Aristotle's life. His father Nicomachus died when Aristotle was ten, making him an orphan. Then he was placed under the guardianship of his uncle, Proxenus of Atarneus, who also took over his education. He gave Aristotle significant instruction in Greek, rhetoric, and poetry (O'Connor et al., 2004). Aristotle went to Athens at the age of 18, and attended Plato's school for young Greek aristocracy (the Academy). Aristotle quickly became Plato's favorite student.

From the age of 18 to 37 Aristotle remained at the Academy. The relationship between Plato and Aristotle has formed the subject of various legends, many of which depict Aristotle unfavorably. No doubt there were divergences of opinion between Plato, who took his stand on sublime, idealistic principles, and Aristotle with realistic principle i.e metaphysics, who even at that time showed a preference for the investigation of the facts and laws of the physical world. It is also probable that Plato suggested that Aristotle needed restraining rather than encouragement, but not that there was an open breach of friendship. In fact, Aristotle's conduct after the death of Plato, his continued associations with Xenocrates and other Platonist, and his allusions in his writings to Plato's doctrines prove that while there were conflicts of opinions between Plato and Aristotle, there was no lack of cordial appreciation or mutual forbearance. Legends that reflect Aristotle unfavorably are allegedly traceable to the Epicureans, although some doubt remains of this charge. If such legends were circulated widely by patristic writers such as Justin Martyr and Gregory Nazianzen, the reason may rest in the exaggerated esteem which early Christian heretics had for Aristotle.

It is not exactly clear when in his life, but according to Clearchus of Soli in his work "De Somno" (apud: Josephus, Contra Apionem, I, 176-183:), Aristotle met a Jew in Asia Minor and regarded him very favorable, noting that there is something to learn from him. Clearchus of Soli quotes Aristoteles as: "'Well', said Aristotle, [...] 'the man was a Jew of Coele-Syria. These people are descended from the Indian philosophers. The philosophers, they say, are in India called Calani, in Syria by the territorial name of Jews; for the district which they inhabit is known as Judea. Their city has a remarkably odd name: they call it Hierusaleme. (180) Now this man, who entertained by a large circle of friends and was on his way from the interior to the coast, not only spoke Greek but had the soul of a Greek. (181) During my stay in Asia, he visited the same places as I did, and came to converse with me and some other scholars, to test our learning. But as one who had been intimate with many cultivated persons, it was rather he who imparted to us something of his own." Flavius Josephus writes: "...he [Aristoteles] went on to speak of the great and astonishing endurance and sobriety displayed by this Jew in his manner of life." (trans. H. St. J. Tackery, The Loeb Classical Library, Cambridge (Mass.)-London)


text:
Radiation Oncology/Vagina

Vaginal Cancer

 * Staging
 * Official Guidelines
 * Overview
 * Treatment

title: Radiation Oncology/Vagina


text:
User:Mmmooonnnsssttteeerrr/Calculus

This is the prototype page for Elementary Calculus. Contents written here may be transferred to there when a section is written here and if its content is deemed of acceptable standard for Elementary Calculus book.

Function
Function generates only one value for each value of an element. Function can be tested using Vertical Line Test.

Let's try to express the area of an equilateral triangle as a function of one of its sides. This problem can be solved by using property of 30-60-90 special right triangle. We know that 30-60-90 right triangle has side ratio of $$1:\sqrt{3}:2$$. Also, we know that we can divide an equilateral triangle into two 30-60-90 right triangles. Let x denote the base of an equilateral triangle and A(x) be the area of an equilateral triangle. Then,
 * $$A(x)=\frac{\frac{x}{2}\times\frac{\sqrt{3}}{2}}{2}\times2\,$$
 * $$=\frac{\sqrt{3}\times x}{4}\;, x>0\,$$

Functions can be classified into power function, root function, a degree of polynomial, rational function, algebraic function, trigonometric function, exponential function, or trigonometric function. Let's try to classify some functions ourselves. $$f(x)=\sqrt[5]{x}$$ is a root function. $$g(x)=\sqrt{1-x^2}$$ is an algebraic function. $$h(x)=x^9+x^4$$ is a polynomial of degree 9. $$r(x)=\frac{x^2+1}{x^3+x}$$ is a rational function. $$s(s)=\tan 2x$$ is a trigonometric function. $$t(x)=\log_{10} x$$ is a logarithmic function. Transcendental functions include trigonometric, inverse trigonometric, exponential, and logarithmic functions.

In statistical study of linear regression, there is a way to conceptualize function as joint distribution of marginal distribution P(x) of explanatory variable x and conditional distribution P(y|x) of response variable y. Explanatory variable is also called endogenous variable or input variable. Response variable is also called exogenous variable or output variable. Of course, there can be more than one explanatory variables in marginal distribution and more than one response variables in conditional distribution.

Tutorial 2
1. (a) Sketch $$f(x)=\sqrt{x}-4$$ and state its domain and range.

To find the domain we know that x>0, so the domain is x>0. To find the range we consider x,y-intercepts, domain, and shape of the curve. The x-intercept is 16, the y-intercept is -4, we know the domain is x>0, and we know that f(x) is $$\sqrt{x}$$ moved downwards by 4 units. Therefore, the range for f(x) is y>-4. $$\Box$$

(b) $$f(f^{-1}(x))=x$$, use this to find the inverse function of f(x) and state its domain and range.

$$x=f(f^{-1}(x))=\sqrt{f^{-1}(x)}-4$$

$$x+4=\sqrt{f^{-1}(x)}$$

$$(x+4)^2=f^{-1}(x)$$

So, the inverse function of f(x) is $$(x+4)^2$$. By the definition of inverse function, we know that the domain of the inverse function is the range of f(x), and the range of the inverse function is the domain of f(x). Therefore, the domain of the inverse function is x>-4, and the range is y>0.

 * composite functions of trignometric and inverse trigonometric functions

Theorem
$$\int_1^\infty\frac{1}{x^p}dx=\begin{cases}p>1,integral\;converges\\p\le1,integral\;diverges\end{cases}$$

My Proof
$$\int_{1}^{\infty}\frac{1}{x^p}dx=lim_{a\rightarrow\infty}\int_1^a\frac{1}{x^p}dx=\begin{cases}lim_{a\rightarrow\infty}\left[\frac{x^{-p+1}}{-p+1}\right]^a_1,p\ne1\\lim_{a\rightarrow\infty}\left[ln x^p\right]^a_1,p=1\end{cases}$$

If $$p>1, -p+1<0$$:

Let $$|-p+1|=k$$,

$$\left[\frac{x^{-k}}{-k}\right]^a_1=\frac{a^{-k}}{-k}-\frac{1}{-k}=\frac{1}{-ka^k}-\frac{1}{-k}$$

Therefore, $$lim_{a\rightarrow\infty}\left[\frac{1}{-ka^k}+\frac{1}{k}\right]=\frac{1}{k}.$$

If $$p<1, -p+1>0$$:

Let $$-p+1=k$$

$$\left[\frac{x^k}{k}\right]^a_1=\frac{a^k}{k}-\frac{1}{k}$$

Therefore, $$lim_{a\rightarrow\infty}\left[\frac{a^k}{k}-\frac{1}{k}\right]\rightarrow\infty.$$

If $$p=1$$:

$$\left[ln x^p\right]^a_1=ln a^p-ln 1=ln a^p$$

Therefore, $$lim_{a\rightarrow\infty}\left[ln a^p\right]\rightarrow\infty.\Box$$

title: User:Mmmooonnnsssttteeerrr/Calculus


text:
Cookbook:Borhani (Spiced Yogurt Drink)

| Beverages | Indian Cuisine

Borhani are yoghurt-based drinks popular in Bangladesh. It's traditionally served in wedding ceremonies around the country.

Ingredients

 * 3 tsp cumin seeds
 * 500 mL (2 cups) full-fat plain yoghurt
 * 1 cup (200 mL) cold water
 * ½ tsp fresh green chile peppers
 * ½ tsp mint
 * ½ tsp coriander
 * ¾ tsp white mustard seeds
 * ¾ tsp ground white pepper
 * ½ tsp ground black pepper
 * 3 tsp sugar
 * ½ tsp rock salt
 * ½ tsp salt

Procedure

 * 1) Dry-roast cumin seeds by cooking them over low heat in small pan until you can smell the seasoning, about 2 minutes. Cool and grind to a powder.
 * 2) Beat yoghurt with water until it becomes smooth. Strain green chili, mint, leaf and coriander pastes with some water blend into the yoghurt. Combine all other ingredients and mix well.
 * 3) Serve cold.

title: Cookbook:Borhani (Spiced Yogurt Drink)


text:
D Programming/Garbage collector/Thoughts about better GC implementations

Requirements
It should be possible to have different GC Implementations. E.g.
 * precise
 * concurrent
 * generational
 * compacting/moving

This leads to more concrete requirements

Which word is a pointer
A precise GC should only mark that memory, that is referenced from a pointer. It should not mark memory "referenced" from non-pointer types. A moving GC also needs to modify pointer values, if an object was relocated.

Which address belongs to which Object
If a pointer is scanned, the start address of an object should be know. So it should be possible to get the PLI (pointer location information), which is needed to go on.

Moving references
In concurrent/incremental GC implementation, the moving reference is a problem. Object refa = new Object; Object refb = null;

 * 1) start of gc collecting cycle
 * 2) gc scans refb, which is null
 * 3) gc pauses or is interrupted from another thread
 * 4) somewhere else: refb = refa; refa = null;
 * 5) gc continues ('thinking' refb is null)
 * 6) gc scans refa, which is now null also
 * GC: Oh, no ref to obj, I can free it!
 * 1) the appl tries to reference refb which is not null and crashes

This is the cause for the need of a write barrier. In a concurrent/incremental GC, every write to a reference needs to invalidate the scans of the old target reference value.

Conservative Stack Scanning
Since scanning the stack precisely could be a hard problem (especially when considerign C interfaces, i.e. callbacks from C code to D code), one could simply conservatively scan the stack and "pin" all objects that are possibly referenced from the stack. The new Mono GC does this.

See section "Conservative Scanning". The stack is treated in a similar way like the current mark & sweep algorithm does it.

Object hash codes
In order to support Object.toHash in presence of a moving GC, one needs to store the hash code in the object itsself. The hash code can be taken from the object's address, but since its address can be changed, it needs to be stored.

Weak Pointers
It should be considered to support weak pointers, which are a potentially useful and an often requested feature. A weak pointer is set to null, if there are no more non-weak pointers to an object. Java and C# also support weak pointers.

Pointer to native types and member variable
Pointer to native types should be possible by the language, but should not be GC relevant. This means, they should not prevent the GC from deleting an object, and they are not marked as "pointers".

So the GC does not need to find the object start. The programmer just needs to be sure, that he does not make references to member, that live longer than the complete object.

GC specific per object data
A specific GC implementation might be implemented more efficiently if it is possible to store a limited amount of GC data inside the object (i.e. flags). But note that most management data can be stored in the memory block which contains the object.

Object Layout
Brain storming what concrete object layouts (only wrt. to GC) would be possible:

Typeinfo pointer
The first 4 bytes would contain a typeinfo pointer, and the type info contains the layout information for the object. This layout information would exist as a bitmap or a region list (a list of (offset, length) pairs)).

Bidirectional memory layout
A very specialized idea to separate pointer and integer data, so no bitmap or similar complex data structures would be required for the GC to scan an object. Pointers and integers would just be completely separated:

+--+    + integers + .  ...    .     +--+     + reflen   + +--+  <-- object ptr .  ...    .     + pointers + +--+

A pointer to an object always points into the middle of the object. Above object ptr, all data is integer data, and below the object ptr, everything is pointer data. The "reflen" member can be used by the GC to find the size of the region it needs to scan.

Inherited classes just can attach their integer/pointer data above/below the data of the base address. The "reflen" member would need to be set correctly if the object is constructed.

Although this would be very fast (as opposed to bitmaps), it also maybe would be very hard to integrate into existing compilers/environments/toolchains. With interrior pointers, the class head would be harder to find. Arrays of structs also would be a (maybe solvable) problem.

Modified bidirectional memory layout
One also could organize pointer data in regions and link that pointer-data regions like a singly linked list (i.e. in presence of inheritance, where pointers can't be grouped into a single region). Every pointer-data region would start with a non-pointer word containing the size of the region, and either the first word of an object would contain a pointer to the first pointer-data region, or the object would start with such a region by itsself.

Read/Write Barriers
Some GC need to run some code each time a reference is overwritten and/or if a reference is read. A flexible way can be, to give the compiler an function, to use for read and write accesses. These functions should always be inlined and optimized. e.g.: ___ref_assign( void * trg, void * src ){ trg = src; } void* ___ref_read( void * src ){ return src; }

Management of pointer location info
The allocation function of the GC should not only receive the size of memory, which is required. It should also receive a bitfield with the information, which words in this memory are references.

Reference info for the stack
each stack frame begins with the bitfield with reference information. If the GC scans the stack, the frames have to be recognized.

Register values
The compiler should ensure, that reference values are always present in memory also. So the GC do not need to scan the registers, and it does not need to know which one contains pointer values.

enable/disable
Implemented for concurrent. Should be recursive usable. This means it should work with a counter. The counter is incremented with each call of disable and decremented with calls to enable.

pin/unpin
Implemented for moving/compacting GCs.

fullcollect
Forces a collection cycle. The call returns after the collection cycle finished. In a Stop-the-world implementation this means, that all threads will pause. In a concurrent implementation not. A reference counting solution will return immediately.


text:
User:Sergio.ballestrero

see my page on Wikipedia EN

Interesting things to work on here

 * School_of_Physics_and_Astronomy
 * C++ Programming
 * Statistics
 * Basic Physics of Nuclear Medicine
 * Modern Physics
 * Introduction to Physical Science
 * FHSST_Physics
 * LaTeX

title: User:Sergio.ballestrero


text:
Understanding Darcs/Reviewing your work

whatsnew
The whatsnew command allows you to get an overview of what unrecorded changes you have made on your working copy.

This way you can get an idea of what needs to be saved.

changes
Changes gives a changelog-style summary of the repo history

diff
Using this command you can get an output like that produced by the diff command. Allowing you to save changes in a plain old (yet very common) format.

Note that darcs does not depend on the diff binary.

title: Understanding Darcs/Reviewing your work


text:
User:Jmoinian

Islam An American friend asked me; what is Islam? Well, I replied submission to God. My friend wanted to know more about the religion of Islam so I decided to pot a brief introduction of Islam for whoever is interested to know about it.

Islam has spread from Arabia Peninsula around 1400 years ago by a chosen one name Muhammad. At the age of 40 this man was chosen to be Lord’s last messenger on Earth. Prophet Muhammad was not able to either write or read. He did not write the holy book Quran. It was reveled to him by the Angle Gabriel in Mount Hara which is located in Saudi Arabia. The religion of Islam has spread quickly all over the world. Right now there are 108 billion Muslims in the world in the second major religion on Earth. There are two major sects: Sunnis whom are about 90% of the Muslims of the world and the rest are Shiite. They both worship only one God. Both they do disagree in the doctrines.

	Who is a true Muslim? Anyone who believe in only God 	Who is without child, parents, or wife. 	God does not have an equal 	God is not created by any other being. 	Any one whom believes in these rules is a Muslim

	There are five pillars which must be followed: 	Delectation of Faith 	Five times daily Prayers 	Giving to the charity from a portion of your wealth 	Establishing a Family 	Taking a trip to Mecca for Hij if your finical situation permits you

We are peaceful people. God has instructed us to be respectful and tolerant toward the people of scriptures’. God has mentioned in Oran 5:87 that Lord does not like aggressors. Also in Koran 49:13 has mentioned “O people, we created you from the same male and female and rendered distinct people, that you may recognize one another. The best among you in the sight of God is the most righteous one:

title: User:Jmoinian


text:
User:Cbrown1023

Hi, I'm Cbrown1023.

title: User:Cbrown1023


text:
Talk:Portuguese/Contents/Slang (Brazil)

Untitled
Gente, bom trabalho, continuem assim! Lendo essa página, me lembrei de um artigo da wikipedia portuguesa com uma lista de gírias, talvez ele lhes seja útil: Lista de Gírias. Valeu! --Bruno Ansarah

I'm going to be visiting Curitiba in a few months, what do they say around there?

title: Talk:Portuguese/Contents/Slang (Brazil)


text:
User:Kc8ukw

Kc8ukw is an graduate physics student at Washington University in Saint Louis. He is currently working on building an NMR probe for high pressure, high temperature studies.

title: User:Kc8ukw


text:
User talk:DavidRoss

2006 August 6

Hello!

My name is David, and I'm new here at wikibooks, well, as a contributor anyway. I have long surfed wikipedia and wikibooks to glean information for fun and profit.

So, here I am now, ready contribute (hopefully positive) back this excellent resource and the comunity at large.

I think the first couple of things I'll help work on is the python wikibook, and then some of the help pages. I don't quite yet fully comprehend the organisation of site, so any pointers would be useful.

The help system and information seems to be disjointed between the "help" and wikibooks categories.

title: User talk:DavidRoss


text:
C Sharp Programming/Interfaces

An INTERFACE in C# is a type definition similar to a class, except that it purely represents a contract between an object and its user. It can neither be directly instantiated as an object, nor can data members be defined. So, an interface is nothing but a collection of method and property declarations. The following defines a simple interface:

A CONVENTION            used in the .NET Framework (and likewise by many C# programmers) is to place an "I" at the beginning of an interface name to distinguish it from a class name. Another common interface naming convention is used when an interface declares only one key method, such as  in the above example. The interface name is then formed as an adjective by adding the "...able" suffix. So, the interface name above could also be. This convention is used throughout the .NET Framework.

Implementing an interface is simply done by inheriting off it and defining all the methods and properties declared by the interface after that. For instance,

Although a class can inherit from one class only, it can inherit from any number of interfaces. This is a simplified form of multiple inheritance supported by C#. When inheriting from a class and one or more interfaces, the base class should be provided first in the inheritance list, followed by any interfaces to be implemented. For example:

Object references can be declared using an interface type. For instance, using the previous examples,

Interfaces can inherit off of any number of other interfaces, but cannot inherit from classes. For example:

Additional details
Access specifiers (i.e., , etc.) cannot be provided for interface members, as all members are public by default. A class implementing an interface must define all the members declared by the interface. The implementing class has the option of making an implemented method virtual, if it is expected to be overridden in a child class.

There are no static methods within an interface, but any static methods can be implemented in a class that manages objects using it.

In addition to methods and properties, interfaces can declare events and indexers as well.

For those familiar with Java, C#'s interfaces are extremely similar to Java's.

title: C Sharp Programming/Interfaces


text:
Jeep Liberty/Tires & Rims/List of States Where Wheel Spacers are Illegal

Many older and cheaper lug centric wheel spacer design were unsafe and gave wheel spacers a bad reputation. As a result wheel spacers are now banned in the following states. Keep in mind that hub centric cast aluminum wheel spacers are usually perfectly safe as long as they're regularly checked for tightness.

 * Pennsylvania - spacers thicker than 1/4" are banned (Title 67 of the PA Code)
 * Mass all spacers are banned. (540 CMR 6.04)


text:
English in Use/Pronoun Usage

Pronoun Usage

A pronoun comes from a Latin word that means 'for a noun'. It is a word that stands in for a noun. The English language has lots of different kinds of pronouns.

Pronouns are often divided into first, second and third person, singular and plural. First person refers to the speaker, second person refers to the person or thing being spoken to, and third person refers to a person or thing neither speaking nor being spoken to.

The first person pronoun (referring to the speaker) is 'I' or 'me' in the singular, and 'we' or 'us' in the plural. The first of each set, "I/we", is used as the subject of a verb; the second, 'me/us', is used as the object of a verb or preposition. There are also reflexive pronouns which can be made (i.e. they are the same person as the subject) by adding the suffix '-self' to the possessive (myself/ourselves).

The second person pronoun (referring to the person being spoken to) is 'you' in singular and plural, as subject or object. The reflexive is "yourself" in the singular and "yourselves" in the plural.

title: English in Use/Pronoun Usage


text:
Python Programming/Decision Control

Python, like many other computer programming languages, uses Boolean logic for its decision control. That is, the Python interpreter compares one or more values in order to decide whether to execute a piece of code or not, given the proper syntax and instructions.

Decision control is then divided into two major categories, conditional and repetition. Conditional logic simply uses the keyword if and a Boolean expression to decide whether or not to execute a code block. Repetition builds on the conditional constructs by giving us a simple method in which to repeat a block of code while a Boolean expression evaluates to true.

Boolean Expressions
Here is a little example of boolean expressions (you don't have to type it in): With the output being: 1 True 2 False 3 True 4 False 5 True 6 True 7 False 8 True 9 False What is going on? The program consists of a bunch of funny looking print statements. Each print statement prints a number and an expression. The number is to help keep track of which statement I am dealing with. Notice how each expression ends up being either True or False; these are built-in Python values.

The lines: print out True and False respectively, just as expected, since the first is true and the second is false. The third print, print (3, a == 6 and b == 7), is a little different. The operator  and means if both the statement before and the statement after are true then the whole expression is true otherwise the whole expression is false. The next line, print (4, a == 7 and b == 7), shows how if part of an  and expression is false, the whole thing is false. The behavior of  and can be summarized as follows:

Note that if the first expression is false Python does not check the second expression since it knows the whole expression is false.

The next line, print (5, not a == 7 and b == 7), uses the <tt>not</tt> operator. <tt>not</tt> just gives the opposite of the expression (The expression could be rewritten as <tt>print (5, a != 7 and b == 7)</tt>). Here's the table:

The two following lines, <tt>print (6, a == 7 or b == 7)</tt> and <tt>print (7, a == 7 or b == 6)</tt>, use the <tt> or</tt> operator. The <tt> or</tt> operator returns true if the first expression is true, or if the second expression is true or both are true. If neither are true it returns false. Here's the table:

Note that if the first expression is true Python doesn't check the second expression since it knows the whole expression is true. This works since <tt> or</tt> is true if at least one of the expressions are true. The first part is true so the second part could be either false or true, but the whole expression is still true.

The next two lines, <tt>print (8, not (a == 7 and b == 6))</tt> and <tt>print (9, not a == 7 and b == 6)</tt>, show that parentheses can be used to group expressions and force one part to be evaluated first. Notice that the parentheses changed the expression from false to true. This occurred since the parentheses forced the <tt> not</tt> to apply to the whole expression instead of just the <tt> a == 7</tt> portion.

Here is an example of using a boolean expression:

See the Lists chapter for an explanation of the slice operator, [:], occurring in.

Here is the output: First Match: Jill

This program works by continuing to check for a match <tt> while count < len(copy) and copy[count] != prev</tt>. When either <tt> count</tt> is greater than the last index of <tt> copy</tt> or a match has been found the <tt> and</tt> is no longer true so the loop exits. The <tt> if</tt> simply checks to make sure that the <tt> while</tt> exited because a match was found.

The other 'trick' of <tt> and</tt> is used in this example. If you look at the table for <tt> and</tt> notice that the third entry is "false and won't check". If <tt> count >= len(copy)</tt> (in other words <tt> count < len(copy)</tt> is false) then copy[count] is never looked at. This is because Python knows that if the first is false then they both can't be true. This is known as a short circuit and is useful if the second half of the <tt> and</tt> will cause an error if something is wrong. I used the first expression (<tt> count < len(copy)</tt>) to check and see if <tt> count</tt> was a valid index for <tt> copy</tt>. (If you don't believe me remove the matches `Jill' and `Life', check that it still works and then reverse the order of <tt> count < len(copy) and copy[count] != prev</tt> to <tt> copy[count] != prev and count < len(copy)</tt>.)

Boolean expressions can be used when you need to check two or more different things at once.

Examples
password1.py

Sample runs What is your name? Josh What is the password? Friday Welcome Josh

What is your name? Bill What is the password? Saturday I don't know you.

Exercises

 * 1) Write a program that has a user guess your name, but they only get 3 chances to do so until the program quits.

Solutions

title: Python Programming/Decision Control


text:
C Sharp Programming/Delegates and Events

Introduction
Delegates and events are fundamental to any Windows or Web Application, allowing the developer to "subscribe" to particular actions carried out by the user. Therefore, instead of expecting everything and filtering out what you want, you choose what you want to be notified of and react to that action.

A delegate is a way of telling C# which method to call when an event is triggered. For example, if you click a on a form, the program would call a specific method. It is this pointer that is a delegate. Delegates are good, as you can notify several methods that an event has occurred, if you wish so.

An event is a notification by the .NET framework that an action has occurred. Each event contains information about the specific event, e.g., a mouse click would say which mouse button was clicked where on the form.

Let's say you write a program reacting only to a click. Here is the sequence of events that occurs:

 * User presses the mouse button down over a button
 * The .NET framework raises a event
 * User releases the mouse button
 * The .NET framework raises a event
 * The .NET framework raises a event
 * The .NET framework raises a event on the

Since the button's click event has been subscribed, the rest of the events are ignored by the program and your delegate tells the .NET framework which method to call, now that the event has been raised.

Delegates
Delegates form the basis of event handling in C#. They are a construct for abstracting and creating objects that reference methods and can be used to call those methods. A delegate declaration specifies a particular method signature. References to one or more methods can be added to a delegate instance. The delegate instance can then be "called", which effectively calls all the methods that have been added to the delegate instance. A simple example:

In this example, the delegate is declared by the line. This statement is a complete abstraction. It does not result in executable code that does any work, but merely declares a delegate type called that takes no arguments and returns nothing. Next, in the method, the statement  = ; instantiates a delegate. The assignment means that the delegate is not initially referencing any methods. The statements +=  and += add two static methods to the delegate instance. Note that the class name can also be left off, as the statement is occurring inside. The statement +=  adds a non-static method to the delegate instance. For a non-static method, the method name is preceded by an object reference. When the delegate instance is called, is called on the object that was supplied when the method was added to the delegate instance. Finally, the statement calls the delegate instance. All the methods that were added to the delegate instance are now called in the order that they were added.

Methods that have been added to a delegate instance can be removed with the  operator:

In C# 2.0, adding or removing a method reference to a delegate instance can be shortened as follows:

Invoking a delegate instance that presently contains no method references results in a.

Note that, if a delegate declaration specifies a return type and multiple methods are added to a delegate instance, an invocation of the delegate instance returns the return value of the last method referenced. The return values of the other methods cannot be retrieved (unless explicitly stored somewhere in addition to being returned).

Anonymous delegates
Anonymous delegates are a short way to write delegate code, specified using the keyword. The delegate code can also reference local variables of the function in which they are declared. Anonymous delegates are automatically converted into methods by the compiler. For example:

They can accept arguments just as normal methods can:

The output is:

testing testing, 100

Lambda expressions
Lambda expressions are a clearer way to achieve the same thing as an anonymous delegate. Its form is:

(type1 arg1, type2 arg2, ...) => expression

This is equivalent to:

If there is only one argument, the parentheses can be omitted. The type names can also be omitted to let the compiler infer the types from the context. In the following example, is a, and the return type is an :

This is equivalent to:

Events
An event is a special kind of delegate that facilitates event-driven programming. Events are class members that cannot be called outside of the class regardless of its access specifier. So, for example, an event declared to be public would allow other classes the use of  and   on the event, but firing the event (i.e. invoking the delegate) is only allowed in the class containing the event. A simple example:

A method in another class can then subscribe to the event by adding one of its methods to the event delegate:

Even though the event is declared public, it cannot be directly fired anywhere except in the class containing it.


text:
User:DavidRoss

2006 August 6

Hello!

My name is David, and I'm new here at wikibooks, well, as a contributor anyway. I have long surfed wikipedia and wikibooks to glean information for fun and profit.

So, here I am now, ready contribute (hopefully positive) back this excellent resource and the comunity at large.

I think the first couple of things I'll help work on is the python wikibook, and then some of the help pages. I don't quite yet fully comprehend the organisation of site, so any pointers would be useful.

The help system and information seems to be disjointed between the "help" and wikibooks categories.

title: User:DavidRoss


text:
Umbraco/Samples and Articles/Protecting Documents

= Basics in limiting public access to documents =

This guide is based on the site installed with the Website Wizard package and is therefore referencing specific templates and documenttypes from this installation. However the basics apply to other templates and documenttypes as well.

Approaching protection
You have two ways of protecting one or more documents in Umbraco.

 * 1) Access based on a simple shared login and password.
 * 2) Access based on memberGroups - memberTypes and Members

Install the Member Controls package
If you can't find it at rtk-cv.dk then you will have to ask in the Umbraco Forum

After installing the package you will have 3 new macros in your Developer/Macros section.

 * Member Login
 * Member Password Reminder
 * Member Signup

Create a template
You need to create a template to hold the login function. This has to be done for either approach and is done in the 'Settings' section of your Umbraco installation.

 * Rightclick on 'Templates' and click 'Create'.
 * Give the template a descriptive name fx. 'Login'
 * Go to the Textpage template and copy alt its contents to the clipboard
 * Go to your newly created Login template and paste the contents of your clipboard
 * Set the Login template's parent template to your master template
 * Make a new line right after your '<?UMBRACO_GETITEM field="bodyText"/>'
 * Add in a '<?ASPNET_FORM>' field.
 * Click 'Insert umbraco macro' icon in the toolbar and select 'Member Login' from the dropdown combo and click 'OK'
 * Add in a '' after the macro insert.
 * Fill in the fields with your desired text and click 'OK'
 * Save your template
 * Finally allow the basic document to inherit the Login template by opening 'Document Types', clicking your 'Textpage' type and in the 'Allowed Templates' section check the 'Login' template
 * Save your document type

Create a login page.

 * Go to the 'Contents' of your installation.
 * Rightclick on your 'Frontpage' document and select 'Create'
 * Set your document type to 'Textpage' and name it 'Login' (or whatever you prefer) and click 'OK'
 * Select your new 'Login' document
 * Select 'Properties' and change the template to the 'Login' template
 * Save your document

Protect your document(s)
If the document you are applying protection to has child documents these documents are protected as well.

The easy approach to protecting documents is one single username/password and this is achieved by

 * Right-clicking your document and selecting 'Public Access'
 * Select the 'Simple: ....' link
 * Fill in username and password
 * Click 'Choose' to select your login page and browse to your 'Login' document
 * Do the same with 'Error page' and select your 'Login' document
 * Click 'Update'

Advanced protection
If you want more control over the access to the documents you can apply security on a memberGroup basis.

If you choose this approach you will have to go to the Members Section before applying security on the document(s).

 * In the Members Section you start by adding a Member Group.
 * The Member Group can contain several different Member Types which can be assigned to Members.
 * When you have created a Member Group and at least one Member Type, create a user.

If you start using Member Groups you might want to look into how to create password reminders and even automated user registration.

Important
When assigning security on documents it is important to remember that both Login page and Error page has to be defined. They can easily be the same page but both has to be selected. If you fail to do so you will get a servererror when trying to update the settings.

Other resources
If you prefer some visualizing you could goto Niels Hartvigs online Screen Cast showing how to protect documents in Umbraco CMS. There is also a reference here

Best Regards

--F.Hundewadt 07:47, 7 August 2006 (UTC)


text:
Template:Python Programming/TopNav

 * This template is derived from: Template:TopNav

title: Template:Python Programming/TopNav


text:
Python Programming/Conditional Statements

Decisions
A Decision is when a program has more than one choice of actions depending on a variable's value. Think of a traffic light. When it is green, we continue our drive. When we see the light turn yellow, we reduce our speed, and when it is red, we stop. These are logical decisions that depend on the value of the traffic light. Luckily, Python has a decision statement to help us when our application needs to make such decision for the user.

If statements
Here is a warm-up exercise - a short program to compute the absolute value of a number:

absoval.py

Here is the output from the two times that I ran this program: Integer? -34 The absolute value of -34 is 34

Integer? 1 The absolute value of 1 is 1

What does the computer do when it sees this piece of code? First it prompts the user for a number with the statement "n = input("Integer? ")". Next it reads the line "if n < 0:". If  n is less than zero Python runs the line "print ("The absolute value of",n,"is",-n)". Otherwise python runs the line "print ("The absolute value of",n,"is",n)".

More formally, Python looks at whether the expression  n < 0 is true or false. An  if statement is followed by an indented block of statements that are run when the expression is true. After the <tt> if</tt> statement is an optional <tt> else</tt> statement and another indented block of statements. This 2nd block of statements is run if the expression is false.

Expressions can be tested several different ways. Here is a table of all of them:

Another feature of the <tt> if</tt> command is the <tt> elif </tt> statement. It stands for "else if," which means that if the original <tt> if</tt> statement is false and the <tt> elif</tt> statement is true, execute the block of code following the <tt>elif</tt> statement. Here's an example:

ifloop.py

and the output:

1 <= 7 2 <= 7 3 <= 7 4 <= 7 5 <= 7 6 > 5 7 > 5 8 > 5 9 > 5 10 > 5

Notice how the <tt> elif a <= 7</tt> is only tested when the <tt> if</tt> statement fails to be true. <tt> elif</tt> allows multiple tests to be done in a single if statement.

If Example
Sample run: Let's play the guessing game! What number am I thinking of? 22 Little higher What number am I thinking of? 25 Little Lower What number am I thinking of? 23 MINDREADER!!!

As it states in its comments, this code is not prepared to handle invalid input (i.e., strings instead of numbers). If you are wondering how you would implement such functionality in Python, you are referred to the Errors Chapter of this book, where you will learn about error handling. For the above code you may try this slight modification of the <tt>while</tt> loop:

Sample runs. Tell me a number: 3 3 is odd.

Tell me a number: 2 2 is even.

Tell me a number: 3.14159 3.14159 is very strange.

Sample runs Welcome to the average calculator program NOTE- THIS PROGRAM ONLY CALCULATES AVERAGES FOR 3 NUMBERS Please enter the first number 7 Please enter the second number 6 Please enter the third number 4 5.66666666667

Sample runs This program will take several numbers, then average them. How many numbers would you like to sum: 2 Number 0 Enter a number: 3 Number 1 Enter a number: 5 The average was: 4.0

This program will take several numbers, then average them. How many numbers would you like to sum: 3 Number 0 Enter a number: 1 Number 1 Enter a number: 4 Number 2 Enter a number: 3 The average was: 2.66666666667

Sample runs Welcome to the Average Calculator, please insert a number New number 1 The current average is 1.0 New number 3 The current average is 2.0 New number 6 The current average is 3.333 New number 6 The current average is 4.0 New number

If Exercises

 * 1) Write a password guessing program to keep track of how many times the user has entered the password wrong. If it is more than 3 times, print You have been denied access. and terminate the program. If the password is correct, print You have successfully logged in. and terminate the program.
 * 2) Write a program that asks for two numbers. If the sum of the numbers is greater than 100, print That is a big number and terminate the program.
 * 3) Write a program that asks the user their name. If they enter your name, say "That is a nice name."  If they enter "John Cleese" or "Michael Palin", tell them how you feel about them ;), otherwise tell them "You have a nice name."
 * 4) Ask the user to enter the password. If the password is correct print "You have successfully logged in" and exit the program. If the password is wrong print "Sorry the password is wrong" and ask the user to enter the password 3 times. If the password is wrong print "You have been denied access" and exit the program.

Conditional Statements
Many languages (like Java and PHP) have the concept of a one-line conditional (called The Ternary Operator), often used to simplify conditionally accessing a value. For instance (in Java):

For many years Python did not have the same construct natively, however you could replicate it by constructing a tuple of results and calling the test as the index of the tuple, like so:

It is important to note that, unlike a built in conditional statement, both the true and false branches are evaluated before returning, which can lead to unexpected results and slower executions if you're not careful. To resolve this issue, and as a better practice, wrap whatever you put in the tuple in anonymous function calls (lambda notation) to prevent them from being evaluated until the desired branch is called:

Since Python 2.5 however, there has been an equivalent operator to The Ternary Operator (though not called such, and with a totally different syntax):

Switch
A switch is a control statement present in most computer programming languages to minimize a bunch of If - elif statements. The switch case functionality was added to Python 3.10 with a new syntax called match case. Prior to version 3.10 switch was not officially supported. The switch statement can be recreated by cleverly using an array or dictionary.

This works because Python stores a reference of the function in the array at its particular index, and by adding a pair of parentheses we are actually calling the function. Here the last line is equivalent to:

Another way
Another way is to use lambdas. Code pasted here with permissions1

For more information on lambda see anonymous functions in the function section.


text:
Python Programming/Source Documentation and Comments

Documentation is the process of leaving information about your code. The two mechanisms for doing this in Python are comments and documentation strings.

Comments
There will always be a time in which you have to return to your code. Perhaps it is to fix a bug, or to add a new feature. Regardless, looking at your own code after six months is almost as bad as looking at someone else's code. What one needs is a means to leave reminders to yourself as to what you were doing.

For this purpose, you leave comments. Comments are little snippets of text embedded inside your code that are ignored by the Python interpreter. A comment is denoted by the hash character (#) and extends to the end of the line. For example:

As you can see, you can also use comments to temporarily remove segments of your code, like the second print statement.

Comment Guidelines
The following guidelines are from PEP 8, written by Guido van Rossum.

 * General
 * Comments that contradict the code are worse than no comments. Always make a priority of keeping the comments up-to-date when the code changes!
 * Comments should be complete sentences. If a comment is a phrase or sentence, its first word should be capitalized, unless it is an identifier that begins with a lower case letter (never alter the case of identifiers!).
 * If a comment is short, the period at the end can be omitted. Block comments generally consist of one or more paragraphs built out of complete sentences, and each sentence should end in a period.
 * You should use two spaces after a sentence-ending period.
 * When writing English, Strunk and White applies.
 * Python coders from non-English speaking countries: please write your comments in English, unless you are 120% sure that the code will never be read by people who don't speak your language.
 * Inline Comments
 * An inline comment is a comment on the same line as a statement. Inline comments should be separated by at least two spaces from the statement.  They should start with a # and a single space.
 * Inline comments are unnecessary and in fact distracting if they state the obvious. Don't do this:   But sometimes, this is useful:

Documentation Strings
But what if you just want to know how to use a function, class, or method? You could add comments before the function, but comments are inside the code, so you would have to pull up a text editor and view them that way. But you can't pull up comments from a C extension, so that is less than ideal. You could always write a separate text file with how to call the functions, but that would mean that you would have to remember to update that file. If only there was a mechanism for being able to embed the documentation and get at it easily...

Fortunately, Python has such a capability. Documentation strings (or docstrings) are used to create easily-accessible documentation. You can add a docstring to a function, class, or module by adding a string as the first indented statement. For example:

The convention is to use triple-quoted strings, because it makes it easier to add more documentation spanning multiple lines.

To access the documentation, you can use the  function inside a Python shell with the object you want help on, or you can use the   command from your system's shell. If we were in the directory where docstringexample.py lives, one could enter  to get documentation on that module.


text:
Python Programming/User Interaction

For command-line interface, see ../Input and output.

For graphical user interface (GUI), see ../GUI Programming

title: Python Programming/User Interaction


text:
Horticulture/Garden Bed Cleanup

Cleaning up a garden bed can be a joy, but can also be daunting if the bed hasn't been maintained on a regular basis. By organizing the cleanup into separate tasks, the gardener can concentrate on getting one thing done at a time, perhaps breaking up the chores over different days, or having one gardener start with the first step, and another gardener working on the next.

The most important thing is to keep cleaned up as the work progresses, meaning that the gardener shouldn't start the next step before cleaning up after the previous one. Cleaning up is often more time consuming and physically arduous than doing the actual chores,so it should not be left for the end of the day.

Garden bed cleanup:

 * Initial run-through
 * The initial run-through is the time for taking care of the big problems such as large weeds, dead plants, debris, etc. This should always be done first because if the gardener is called away to other tasks, at least the major eyesores will be taken care of. This stage of the cleanup doesn't require tools, just eyes and hands. If something requires tools, just wait for a later step, since there's only so much room on a tool belt and while you're removing the big stuff it's best to have both hands free.
 * Pull big, easy weeds
 * Leave small weeds in areas that can be cultivated using a hoe
 * If transplanting or potting up volunteers, do this during the initial run through and pot them up or heel them right away (see ../Plant Rescues/)
 * Edge, if necessary.
 * Go through with weeding tool and pruners or loppers.
 * Cut down or dig out large weeds that can't be pulled.
 * Get weeds that can’t be gotten by root with hand-pulling
 * Cut any tree saplings too large for the weeder
 * Cultivate in any open areas using a hoe or other cultivator
 * Prune if appropriate, and divide any large plants (depending on season).
 * Detail around plant crowns (areas not able to be cultivated), and take care of any dead stems or foliage.
 * Clean up thoroughly
 * Pick up any piles of rocks or other debris present.
 * Add plants, if desired
 * Irrigate well
 * Add mulch or pre-emergents, if desired

/Techniques

title: Horticulture/Garden Bed Cleanup


text: Template:Cquote

title: Template:Cquote


text:
MATLAB Programming/Advanced Topics/Applications and Examples/Filtering

Filtering is a broad subject. For the MATlab wiki I will focus on how to implement filters. For more on the theory of filtering the reader should reference the Digital Signal Processing wiki book.

The Moving Average Filter
Formula:

$$y[n] = \frac{1}{h} \sum_{p=0}^{h-1} x[n-p] $$

MATLAB implementation(All the code here was intended to be put in an M-file): The moving average filter is simple and effective. One of the things that is a problem is the lag associated with the moving average filter. The more samples used the longer the lag experienced(All filters have lag). How much lag can be tolerated is up to the individual.

The Kalman Filter
The Kalman filter is a recursive method of combining two estimates to determine the truth. A few parameters that are widely used are the initial conditions or current value and measured data.

Equation:

Example: All this code does is take a constant value R and adds noise to it. Then it filters the new signal in an effort to separate the noise from the original signal.


text:
Learning the vi Editor/Moving around

We can move around in the editor by first entering command mode, and then using the, , , and keys.

 * Note: your arrow keys may be set up to work, and you can use them if you like, but for proficiency and for advanced work later, you should learn to use the letter keys.

 * The key, in command mode, moves the cursor one character left.
 * The key, in command mode, moves the cursor one character down.
 * The key, in command mode, moves the cursor one character up.
 * The key, in command mode, moves the cursor one character right.

If you have trouble remembering this, keep in mind that is leftmost, the letter goes down below the line, the letter pokes up above the line, and the  key is rightmost. (J also resembles an arrow pointing downward, if you squint a bit.)

After you have moved the cursor using those keys, you can enter insert mode again by pressing. When you do this, you insert text at the cursor, inserting text between the character to the left of the cursor and the current position of the cursor. Let's practice this in an exercise.

title: Learning the vi Editor/Moving around


text:
Croatian/Main Contents/Level 2/Lesson 3

Verbs in the present tense of Croatian are simpler than those of English. Pišem can mean I write, I do write, or I am writing. In the present tense, verbs can be categorized into three basic types, as: znati, raditi, pisati. As it is difficult to distinguish which category a verb belongs to, it is often given in the infinitive and present forms. For most verbs, the present forms can be deduced from the first person singular (exceptions: biti, htjeti, moći). The infinitive and the first person singular present form are the so-called "principal forms" of a Croatian verb.

To form verbs in the present tense, if the first person singular present is not known: Start with the infinitive: znati Remove the final three letters: znati = zn + -a + -ti =  zn- Add the appropriate endings, i.e.: (ja) znam

The best way is to memorize the 1st person singular to create the other forms without any problems.

Verbs like znati (principal form: -am)
znati, to know

Verbs like raditi (principal form: -im)
raditi, to work, to do

Verbs like pisati (principal form: -jem)
pisati, to write

Verbs like ići (principal form: -em)
ići, to go ići = id + -ti = id-

Infinitive
It ends on -ti or -ći

-TI: raditi, to work; spavati, to sleep; igrati, to play; jesti, to eat; trčati, to run; ubiti, to kill; tražiti, to search; piti, to drink;

-ĆI: ići, to go; teći, to flow; reći, to say; moći, to be able to, can;

Pronouns (accusative form)
In Croatian language reflexive pronouns have 2 forms: shorter and longer. It is often better to use shorter form than longer one. Longer ones can sometimes be used on the beginning of a sentence while short forms can't.

Here is an example: Vidim je. - I see her.

Pronoun drop
Croatian, like all other Slavic languages and most Romance ones as well, is a pro-drop language. This means that personal pronouns (I, you, etc.) are omitted from most sentences. Because the verb stem ending clearly indicates who performs the action, it is not necessary to put pronouns, unless it is for emphasis.

For example: Razumijem hrvatski., I understand Croatian. From this sentence, we know that the speaker is speaking in the first person singular.

Exceptions to pro-drop:

 * For emphasis, e.g.,
 * Tko zna odgovor?, Who knows the answer?
 * Ja znam!, I know

 * Two verbs htjeti and biti have longer forms that are used as answers to questions. They can be translated as "I/you/he/she/it/we/they did" or in some cases "I am/You are/He is/She is/It is/We are/They are" (when confirming identity).
 * Negative forms of the verb htjeti can be written in two ways: neću or ne ću. I, as croatian native speaker, prefer this first form, "neću". Of course, both forms are correct.

Next lesson

title: Croatian/Main Contents/Level 2/Lesson 3


text:
Self Interest and Social Behavior

Self Interest and Social Behavior introduces you to decision theory and game theory by considering important applications throughout the social sciences.

Some sample questions we will ponder:

GREED or ALTRUISM ??

When do people sacrifice for others?

How about animals?

Or is there really a payoff for them after all?

Social behavior, in general, involves actions taken by individuals that, at least when aggregated over a group, affect other individuals. We want to predict and explain this behavior. Viewing this as scientists, we would like to discover, in effect, any “natural laws” that determine this behavior, if not for all environments then for some. One candidate for such a law of social behavior, one that may offer the foundation for a paradigm for each of the social sciences, is that individuals behave to further their own self interest. These models are relatively simple, powerful in their predictions, and might apply to all social behavior. Self Interest and Social Behavior examines these models, builds up their mathematical infrastructure as necessary, and examines these models and their implications through important applications throughout the social sciences. These applications clearly come from economics, political science, psychology, and anthropology, but also biology and philosophy whenever they try to predict or explain social behavior. We intend to demonstrate that these models should, at a minimum, be considered seriously because of their simplicity, their power, and their potentially wide scope.

Models of individuals furthering their own self interest are formalized with either decision theory or game theory. Decision theory is the mathematics of optimizing behavior, where choices are made that further self interest against an environment that does not change in response to these choices. In decision theory, each individual’s choices can be considered independently of choices that any other individual makes. It can be the foundation of either rational choice models or of evolutionary models. Game theory, building upon the foundation of decision theory, is the mathematics of strategic decisions, decisions where the value of the outcome to each individual depends upon the actions that other individuals take as well as actions that the decision maker takes herself. The rival’s choices may be influenced by the first individual’s choices. In game theory, an individual’s choices are interdependent with other individual’s choices. These "choices" might actually be rational choices that individuals make, or they may be the implicit "choices" that natural selection or cultural selection make, in that other alternatives nearly vanish in later populations.

Table of Contents

 * /Aims and Objectives/
 * /Contributors/

/Decision Theory/

 * /Smart Choices and Models Based Upon Them/
 * /Optimization in Markets/
 * /Sincere Voters/
 * /Natural Selection/
 * /Cooperation with Kin Selection/
 * /Cultural Evolution and Social Norms/
 * /Decision Theory with Uncertainty/
 * /Investments, Insurance, and Search/
 * /Anomalies and Responses to Them/

title: Self Interest and Social Behavior