202211081129 Python Formula 002

Coulomb’s law states that F the magnitude of the electrostatic force of attraction or repulsion between two point charges Q_1 and Q_2 is directly proportional to Q_1Q_2 the product of the magnitudes of charges and inversely proportional to r^2 the square of the distance between them:

\displaystyle{F=\frac{Q_1Q_2}{4\pi\epsilon_0r^2}}

Wikipedia on Coulomb’s law


Roughwork.

The nucleus of a helium atom contains two protons \sim 3.8\times 10^{-15}\,\mathrm{m} apart each of electric charge +e=+1.6\times 10^{-19}\,\mathrm{C}. The electrostatic force of repulsion between them is

202211081044 Python Formula 001

Converting between temperature scales.

\begin{aligned} & x\,^\circ\mathrm{F}\triangleq (x-32)\times \frac{5}{9}\,^\circ\mathrm{C} & \qquad & x\,^\circ\mathrm{C}\triangleq (x\times \frac{9}{5}+32)\,^\circ\mathrm{F} \\ &  x\,^\circ\mathrm{F}\triangleq (x+459.67)\times \frac{5}{9}\,\mathrm{K} & \qquad & x\,\mathrm{K}\triangleq (x\times \frac{9}{5}-459.67)\,^\circ\mathrm{F} \\ &  x\,^\circ\mathrm{F} \triangleq (x+459.67) ^\circ\mathrm{R} & \qquad & x\,^\circ\mathrm{R}\triangleq (x-459.67)\,^\circ\mathrm{F} \\ \end{aligned}


Roughwork.

One has a slight fever when one’s body temperature is 37.8\,^\circ\mathrm{C}, or in degrees Fahrenheit,

The rest of conversion of temperature scales, in Celsius, Fahrenheit, Kelvin, Rankine, etc., are left for the reader to code.

202205261415 Arithmetic in Lisp

Given two operands a and b which are real numbers, define the operators,

a+b, a-b, a\times b, a\div b, a^{b}, \sqrt[b]{a}, a\bmod b,

with respect to arithmetic operations such as addition, subtraction, multiplication, division, exponentiation, rooting, and Modulo.

Not so accustomed to these, Lisp cannot interpret or compile them until we have defined those seven primitive functions, better known as symbolic computations; as were newborn infants taught human intelligence by grownup adults between homo sapiens.

To Lisp, arithmetic operations are usually \textrm{\scriptsize{NOT}} predefined. We have in our toolkit \textrm{\scriptsize{ONLY}} three mathematical functors, i.e., list, iteration, and recursion.

The roots of quadratic equation are given by the formula:

\displaystyle{x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}}

the expected outcome of which is calculated by parts, first the discriminant ‘delta’:

\Delta = b^2-4ac;

then the plus-minus ‘pm’:

\pm (x)=(+x,-x);

and hence

will solve for real roots, ignoring the complex though.

\therefore Predefining the seven primitive functions is in order for solving any computational problems by Lisp.

(to be continued)

202205251335 SQL Table 005

202112021138 SQL Table 004

Background. (Equilibrium)

Equilibrium is established by the exchange of energy, volume, or particle number between different systems or subsystems.

Section 2.2. Arovas. (2019). Thermodynamics and Statistical Mechanics


202111251402 Exercise 2.59 in Lisp

Implement the union-set operation for the unordered-list representation of sets.

Extracted from Structure and Interpretation of Computer Programs, SICP


Attempts.

Define a function element-of-set?by

to determine whether an object xis an element of a set set.

Define a function intersection-set by

to draw the intersection intersection-set of two sets set1 and set2.

Define a function union-set by

to draw the union  union-set of two sets set1 and set2.

202109291137 SQL Table 003

 

202109281720 SQL Table 002

202109281636 SQL Table 001

202108050932 Project Euler Problem 1 solved by C

Problem 1 of Project Euler

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

Ans. 233168


(step-by-step approach, slow but sure logic)

I wish to find all the multiples of 3 (excluding multiples of 5) below 1000:

Then I wish to find all the multiples of 5 (excluding multiples of 3) below 1000:

Lastly I wish to find all the multiples of 15=3\times 5 below 1000:

In sum,

\begin{aligned} & \quad \textrm{The sum of all multiples of 3 or 5 below 1000} \\ & = 133\small,668 + 66\small,335 + 33\small,165 \\ & = 233\small,168 \end{aligned}

Ans. 233168 \quad\checkmark

(to be continued)


Going off at a tangent, the sum of all numbers from 1 to 1000 is 500500. See:

(proof)

\begin{aligned} & \quad 1+2+3+\cdots +1000 \\ & = \sum_{k=1}^{1000}k \\ & = \frac{(1000)(1000+1)}{2} \\ & = 500500 \\ \end{aligned}


(continue)

Solution. (fast and furious attempt)