# Newton's Laws

## Newton's Laws of Motion

The following is copied verbatim from Wikipedia for the purposes of playing around with Mathjax.

Newton's laws of motion are three physical laws that form the basis for classical mechanics. They describe the relationship between the forces acting on a body and its motion due to those forces. They have been expressed in several different ways over nearly three centuries, and can be summarized as follows:

• First law: If an object experiences no net force, then its velocity is constant: the object is either at rest (if its velocity is zero), or it moves in a straight line with constant speed (if its velocity is nonzero).
• Second law: For a body with constant mass, the acceleration $\mathbf{a}$ of the body is parallel and directly proportional to the net force $\mathbf{F}$ acting on the body, is in the direction of the net force, and is inversely proportional to the mass $m$ of the body, i.e., $\mathbf{F}=m\mathbf{a}$. In general, the force is directly proportional to the rate of change of momentum of the body, i.e., $$\mathbf{F}=\frac{d}{dt}\left(m\mathbf{v}\right).$$
• Third law: When a first body exerts a force $\mathbf{F}_1$ on a second body, the second body simultaneously exerts a force $\mathbf{F}_2 = -\mathbf{F}_1$ on the first body. This means that $\mathbf{F}_1$ and $\mathbf{F}_2$ are equal in magnitude and opposite in direction.
The three laws of motion were first compiled by Sir Isaac Newton in his work Philosophiæ Naturalis Principia Mathematica, first published in 1687. Newton used them to explain and investigate the motion of many physical objects and systems. For example, in the third volume of the text, Newton showed that these laws of motion, combined with his law of universal gravitation, explained Kepler's laws of planetary motion.

## Newton's Laws of Gravitation

Again, what follows is from Wikipedia.

Newton's law of universal gravitation states that every point mass in the universe attracts every other point mass with a force that is directly proportional to the product of their masses and inversely proportional to the square of the distance between them. (Separately it was shown that large spherically symmetrical masses attract and are attracted as if all their mass were concentrated at their centers.) This is a general physical law derived from empirical observations by what Newton called induction. It is a part of classical mechanics and was formulated in Newton's work Philosophiæ Naturalis Principia Mathematica ("the Principia"), first published on 5 July 1687. (When Newton's book was presented in 1686 to the Royal Society, Robert Hooke made a claim that Newton had obtained the inverse square law from him – see History section below.) In modern language, the law states the following:

Every point mass attracts every single other point mass by a force pointing along the line intersecting both points. The force is proportional to the product of the two masses and inversely proportional to the square of the distance between them: $$F = G \frac{m_1 m_2}{r^2},$$ where:
• $F$ is the magnitude of the force between the masses,
• $G$ is the gravitational constant,
• $m_1$ is the first mass,
• $m_2$ is the second mass, and
• $r$ is the distance between the centers of the masses.

## Appendix

The table below shows the SI units for the quantities involved in the above discussion.

Symbol Quantity Unit
$\mathbf{F}$ Force Newton ($N$)
$m$ Mass Kilogram ($kg$)
$\mathbf{a}$ Acceleration Metres per second${}^2$ ($ms^{-2}$)
$\mathbf{v}$ Velocity Metres per second ($ms^{-1}$)
$r$ Distance Metres ($m$)
$G$ Gravitational constant $N m^2 kg^{-2}$

# Examples of Python code in webpages

Here's a link to a .py file, which can be downloaded by right-clicking and selecting 'save as'.

Here's what the code looks like using Google Prettify.


# an implementation of the game of higher or lower

from random import randint

number = randint(1, 100)

print()
print("Higher or lower?")
print("----------------")
print()
print("Try to guess the number I've thought of between 1 and 100.")

attempts = 0
guess = 0

while guess != number:
attempts += 1

if attempts > 7:
print("Hurry up!")

attempt_number = str(attempts)
guess = int(input("Guess "+attempt_number+": "))

if guess > number:
print(guess, "is too high")
elif guess < number:
print(guess, "is too low")

print("Correct! The answer was", guess)
print("You took", attempts, "attempts.")

if attempts > 8 and attempts < 11:
print("Too slow for my liking!")
elif attempts > 10:
print("Were you even trying?")



And here's embedded code using repl.it

.