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