doc-src/Exercises/2003/a3/a3.thy
author wenzelm
Sat, 29 May 2004 15:05:25 +0200
changeset 14830 faa4865ba1ce
parent 14526 51dc6c7b1fd7
permissions -rw-r--r--
removed norm_typ; improved output; refer to Pretty.pp;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14526
mehta
parents:
diff changeset
     1
(*<*)
mehta
parents:
diff changeset
     2
theory a3 = Main:
mehta
parents:
diff changeset
     3
(*>*)
mehta
parents:
diff changeset
     4
mehta
parents:
diff changeset
     5
subsection{* Computing with natural numbers - Magical Methods *}
mehta
parents:
diff changeset
     6
mehta
parents:
diff changeset
     7
text{*
mehta
parents:
diff changeset
     8
A book about Vedic Mathematics describes three methods to make the calculation of squares of natural numbers easier:
mehta
parents:
diff changeset
     9
mehta
parents:
diff changeset
    10
\begin{itemize}
mehta
parents:
diff changeset
    11
\item {\em MM1}: Numbers whose predecessors have squares that are known or can easily be calculated. For example:
mehta
parents:
diff changeset
    12
\\ Needed: $61^2$  
mehta
parents:
diff changeset
    13
\\ Given: $60^2 = 3600$
mehta
parents:
diff changeset
    14
\\ Observe: $61^2 = 3600 + 60 + 61 = 3721$
mehta
parents:
diff changeset
    15
mehta
parents:
diff changeset
    16
\item {\em MM2}: Numbers greater than, but near 100. For example:
mehta
parents:
diff changeset
    17
\\ Needed: $102^2$
mehta
parents:
diff changeset
    18
\\ Let $h = 102 - 100 = 2$ , $h^2 = 4$
mehta
parents:
diff changeset
    19
\\ Observe: $102^2 = (102+h)$ shifted two places to the left $ + h^2 = 10404$
mehta
parents:
diff changeset
    20
 
mehta
parents:
diff changeset
    21
\item {\em MM3}: Numbers ending in $5$. For example:
mehta
parents:
diff changeset
    22
\\ Needed: $85^2$
mehta
parents:
diff changeset
    23
\\ Observe: $85^2 = (8 * 9)$ appended to $ 25 = 7225$
mehta
parents:
diff changeset
    24
\\ Needed: $995^2$
mehta
parents:
diff changeset
    25
\\ Observe: $995^2 = (99 * 100)$ appended to $ 25 = 990025 $
mehta
parents:
diff changeset
    26
\end{itemize}
mehta
parents:
diff changeset
    27
mehta
parents:
diff changeset
    28
mehta
parents:
diff changeset
    29
In this exercise we will show that these methods are not so magical after all!
mehta
parents:
diff changeset
    30
mehta
parents:
diff changeset
    31
\begin{itemize}
mehta
parents:
diff changeset
    32
\item Based on {\em MM1} define a function @{term "sq"} that calculates the square of a natural number.
mehta
parents:
diff changeset
    33
\item Prove the correctness of @{term "sq"} (i.e.\ @{term "sq n = n * n"}).
mehta
parents:
diff changeset
    34
\item Formulate and prove the correctness of {\em MM2}.\\ Hints:
mehta
parents:
diff changeset
    35
  \begin{itemize}
mehta
parents:
diff changeset
    36
  \item Generalise {\em MM2} for an arbitrary constant (instead of $100$).
mehta
parents:
diff changeset
    37
  \item Universally quantify all variables other than the induction variable.
mehta
parents:
diff changeset
    38
\end{itemize}
mehta
parents:
diff changeset
    39
\item Formulate and prove the correctness of {\em MM3}.\\ Hints:
mehta
parents:
diff changeset
    40
  \begin{itemize}
mehta
parents:
diff changeset
    41
  \item Try to formulate the property `numbers ending in $5$' such that it is easy to get to the rest of the number.
mehta
parents:
diff changeset
    42
  \item Proving the binomial formula for $(a+b)^2$ can be of some help.
mehta
parents:
diff changeset
    43
  \end{itemize}
mehta
parents:
diff changeset
    44
\end{itemize}
mehta
parents:
diff changeset
    45
*}
mehta
parents:
diff changeset
    46
mehta
parents:
diff changeset
    47
(*<*) end (*>*)