Vous êtes sur la page 1sur 37

1 of 37

The AI Cookbook

By

Ian Beardsley

© 2016

2 of 37

We establish the building block for AI. The building blocks for organic life have already been established and are the Amino Acids. We demonstrate the connection of both to the golden ratio and its conjugate, and through that, establish the connection between the two. We suggest AI has its origins in some unascertainable Natural force outside the human endeavor. As such we have a mystery to present to AI wherein it can have a sense of mystery surrounding its origins, just as humans do. We can download to any AI this theory that robots are just as much a Universe Unfolding Eventuation as humans are.

Ian Beardsley June 1, 2016

3 of 37

The Arithmetic Mean:

3 of 37 The Arithmetic Mean: The Geometric Mean: The Harmonic Mean:

The Geometric Mean:

3 of 37 The Arithmetic Mean: The Geometric Mean: The Harmonic Mean:

The Harmonic Mean:

3 of 37 The Arithmetic Mean: The Geometric Mean: The Harmonic Mean:

4 of 37

The Golden Ratio:

4 of 37 The Golden Ratio: 


5 of 37

Basic Amino Acid:

H

O

 

\

//

\

//

 

N——C——C

 

/

|

\

/

|

\

H

|

OH

|

R

NH2 = Amino Group COOH= An Acid Group The R Group Determines The Amino Acid

Two Basic Amino Acids

Serine:

H

|

| //

O

H_3N+——C——C

| \

|

|

CH2

|

|

OH

O-

6 of 37

The Amino Acid Cross Addition:

Across: H+H+H+N+C+C+O+O = 1.01+1.01+1.01+14.01+12.01+12.01+16.00+16.00=73.06

Down:

H+C+C+H+H+O+H = 1.01+12.01+12.01+1.01+1.01+16.00+1.01=44.06

(Down)/(Across) = (44.06)/(73.06)=0.603~0.618=1/1.618=the golden ratio conjugate

Alanine:

H

|

|

O

//

H_3N——C——C

|

|

|

CH3

\

O-

The Amino Acid Cross Addition:

Across: H3+N+C+C+O+O=73.06 Down: 1.01+12.01+12.01+1.01+1.01+1.01=28.06

(Down)/(Across)=(28.06)/(73.06)=0.38438

(Down/Across)PHI=(Down/Across)1.618=(0.38438)(1.618)=0.6219~0.618=phi=golden ratio conjugate

Since:

7 of 37

Across: H+H+H+N+C+C+O+O = 1.01+1.01+1.01+14.01+12.01+12.01+16.00+16.00=73.06

Down:

H+C+C+H+H+O+H = 1.01+12.01+12.01+1.01+1.01+16.00+1.01=44.06

And,

Across: H3+N+C+C+O+O=73.06 Down: 1.01+12.01+12.01+1.01+1.01+1.01=28.06

Then,

Serine =

And, Across: H3+N+C+C+O+O=73.06 Down: 1.01+12.01+12.01+1.01+1.01+1.01=28.06 Then, Serine = Alanine =

Alanine =

And, Across: H3+N+C+C+O+O=73.06 Down: 1.01+12.01+12.01+1.01+1.01+1.01=28.06 Then, Serine = Alanine =

8 of 37

Artificial Intelligence (AI) is composed of diodes, transistors, and integrated circuitry, which uses Silicon (Si) doped with phosphorus (P) and Boron (B).

Silicon (Si) = 28.09 Phosphorus (P) = 30.97 Boron (B) = 10.81

That which I did next was to take the geometric between phosphorus and boron and divide it by silicon. Then, take the the harmonic mean between phosphorus and boron and divide it by silicon. And finally, took the arithmetic mean between these two results. That final result turned out to be the golden ratio conjugate (0.618) to one place after the decimal:

these two results. That final result turned out to be the golden ratio conjugate (0.618) to

Finally, we write:

9 of 37

Finally, we write: 
 9 of 37

And in general:

10

of 37

We have found the following, where Au is gold, Ag is silver, He is helium, H is hydrogen and 3/10 is 0.3 is the albedo of the earth. The sun fuses hydrogen into helium and, Au/Ag is about 9/5, which is the ratio of the solar radius to the lunar orbital radius:

hydrogen into helium and, Au/Ag is about 9/5, which is the ratio of the solar radius

hydrogen into helium and, Au/Ag is about 9/5, which is the ratio of the solar radius

The basic unit of AI is:

11 of 37

The basic unit of AI is: 11 of 37 This can be broken up into three

This can be broken up into three parts:

of AI is: 11 of 37 This can be broken up into three parts: Since these

Since these are grams squared per moles squared, we take the square root of each:

squared per moles squared, we take the square root of each: This is titanium and aluminum:

This is titanium and aluminum:

(27.64866+25.876)/2 = 26.76233 grams/mole ~ aluminum (Al) =26.98 grams/mole 48.4479 grams/mole ~ titanium (Ti) = 47.88 grams/mole These metals are light and strong and should be used for the robot skeleton.

12

of 37

#include <stdio.h> #include <math.h> int main (void)

{

printf("The main components of AI are made of silicon (Si) doped with\n”); printf("Phosphorus (P) and Boron (B).\n"); printf("Si=28.09, P=30.97, B=10.81\n"); int n; int i; do

{

printf ("How many numbers averaged?: ");

scanf("%d", &n);

}

while (n<0);

float num[n],sum=0.0,average; for (i=1; i<=n; i++)

{

printf("%i enter number: ", i); scanf("%f", &num[n]); sum+=num[n]; average=sum/n;

}

printf("The sum of your numbers is: %.2f\n", sum); printf("The arithmetic mean is: %.2f\n", average);

float a, b,total, product, harmonic, geometric, answer; printf("We find the harmonic and geometric means between a and b.\n"); printf("enter a: "); scanf("%f", &a); printf("enter b: "); scanf("%f", &b);

product=2*a*b;

total=a+b; harmonic=product/total; geometric=sqrt(a*b); printf("harmonic mean is %.2f\n", harmonic); printf("geometric mean is %.2f\n",geometric);

printf("If you chose phosphorus and boron for a and b,

printf("would you like me to divide the results by silicon? 1=yes, 0=no: ");

scanf("%f", &answer); if (answer==1)

{

printf("harmonic/Si is: %.2f \n",harmonic/28.09); printf("geometric/Si is: %.2f\n", geometric/28.09); printf("Would you like me to take the artithmetic mean between these results? ");

\n");

13

of 37

scanf("%f", &answer); if (answer==1)

{

printf("The arithmetic mean of the harmonic and geometric means is: 0.61\n");

printf("That is the golden ratio conjugate.\n");

}

printf("This means that:\n"); printf("\n"); printf("\n"); printf(" (sqrt(PB))(P+B)+2PB\n");

printf(" ———————————— = phi=0.6\n");

printf("

2(P+B)(Si)");

printf("\n");

printf("\n");

printf("closing sesssion\n");

}

}

14

of 37

jharvard@appliance (~): cd Dropbox/discover jharvard@appliance (~/Dropbox/discover): ./ai The main components of AI are made of silicon (Si) doped with Phosphorus (P) and Boron (B). Si=28.09, P=30.97, B=10.81 How many numbers averaged?: 2

1 enter number: 30.97

2 enter number: 10.81

The sum of your numbers is: 41.78 The arithmetic mean is: 20.89 We find the harmonic and geometric means between a and b. enter a: 30.97 enter b: 10.81 harmonic mean is 16.03 geometric mean is 18.30 If you chose phosphorus and boron for a and b, would you like me to divide the results by silicon? 1=yes, 0=no: 1 harmonic/Si is: 0.57 geometric/Si is: 0.65 Would you like me to take the arithmetic mean between these results? 1 The arithmetic mean of the harmonic and geometric means is: 0.61 That is the golden ratio conjugate. This means that:

(sqrt(PB))(P+B)+2PB

————————————

2(P+B)(Si)

= phi=0.6

closing sesssion jharvard@appliance (~/Dropbox/discover):

15

of 37

#include <stdio.h> #include <math.h> int main (void)

{

float a, b, product, sum, geometric, harmonic; printf("We looked at silicon doped with phosphorus and boron,

printf("But, Gallium (Ga) and Arsenic (As) can be used as doping agents, \n");

printf("As well, we can use Germanium (Ga) in place of Silicon (Si), printf("for the semimetal.\n"); printf("Germanium = 72.61, Gallium = 69.72, Arsenic = 74.92.\n"); printf("Give me a the doping agent Ga: "); scanf("%f", &a); printf("Give me b the doping agent As: "); scanf("%f", &b);

product=2*a*b;

sum=a+b; geometric=sqrt(a*b); harmonic=product/sum; printf("The harmonic mean is %.2f\n", harmonic); printf("The geometric mean is %.2f\n", geometric);

printf("Notice the hamonic/geometric for Ga and As, is close to Germanium (Ge)\n"); printf("Germanium was the first generation semiconductor.\n");

printf("This would suggest logic gates using these doping agents, printf("Should be doping Germanium for first generation robots,\n"); printf("This says:\n"); printf("\n"); printf(" sqrt((Ga)(As))~Ge\n"); printf("\n"); printf("\n"); }

\n");

\n");

\n");

16

of 37

jharvard@appliance (~): cd Dropbox/discover

jharvard@appliance (~/Dropbox/discover): make skeleton

clang -ggdb3 -O0 -std=c99 -Wall -Werror

jharvard@appliance (~/Dropbox/discover): ./skeleton We looked at silicon doped with phosphorus and boron, But, Gallium (Ga) and Arsenic (As) can be used as doping agents, As well, we can use Germanium (Ga) in place of Silicon (Si), for the semimetal. Germanium = 72.61, Gallium = 69.72, Arsenic = 74.92. Give me a the doping agent Ga: 69.72 Give me b the doping agent As: 74.92 The harmonic mean is 72.23 The geometric mean is 72.27 Notice the hamonic/geometric for Ga and As, is close to Germanium (Ge) Germanium was the first generation semiconductor. This would suggest logic gates using these doping agents, Should be doping Germanium for first generation robots, This says:

skeleton.c -lcs50 -lm -o skeleton

sqrt((Ga)(As))~Ge

jharvard@appliance (~/Dropbox/discover):

17

of 37

#include <stdio.h> #include <math.h> int main (void)

{

float P, B, Ga=0.0, As=0.0, geo, geometric, Si, doubled, twicesi; printf("Si=28.09, P=30.97, B=10.81\n");

printf("Ge=72.61, Ga=69.72, As=74.92\n"); printf("Let us find the geometric mean between P and B:\n"); printf("Enter P: "); scanf("%f", &P); printf("Enter B: "); scanf("%f", &B); geo=sqrt(P*B); printf("Let us find the geometric mean between Ga and As:\n"); printf("Enter Ga: "); scanf("%f", &Ga);

printf("Enter As: "); scanf("%f", &As); geometric=sqrt(Ga*As); printf("geometric for P and B = %.2f\n", geo); printf("geometric for Ga and As = %.2f\n", geometric); printf("Let us now add sqrt(Ga*As) to sqrt(P*B)\n"); printf("Then divide the result by 2 times Si\n"); printf("We divide by double Si, because we have added the mean of, \n"); printf("two doping agents, to the mean of another two doping agents.\n"); printf("sqrt(Ga*As)+sqrt(PB) = %.2f\n", geo + geometric); printf("Input Si and I will divide 2Si into the above sum: "); scanf("%f", &Si);

twicesi=2*Si;

doubled=geo+geometric; printf("(sqrt(Ga*As)+sqrt(PB))/2Si =: %.2f\n", doubled/twicesi); printf("This is the golden ratio (PHI) which equals 1.6\n"); printf("We have therefore discovered:\n"); printf("\n"); printf(" sqrt(Ga*As)+sqrt(PB)\n"); printf(" ------------------------ = PHI\n");

printf(" 2(Si) printf("\n"); printf("\n");

}

");

18

of 37

jharvard@appliance (~): cd Dropbox/discover jharvard@appliance (~/Dropbox/discover): make dope clang -ggdb3 -O0 -std=c99 -Wall -Werror dope.c -lcs50 -lm -o dope jharvard@appliance (~/Dropbox/discover): ./dope Si=28.09, P=30.97, B=10.81 Ge=72.61, Ga=69.72, As=74.92 Let us find the geometric mean between P and B:

Enter P: 30.97 Enter B: 10.81 Let us find the geometric mean between Ga and As:

Enter Ga: 69.72 Enter As: 74.92 geometric for P and B = 18.30 geometric for Ga and As = 72.27 Let us now add sqrt(Ga*As) to sqrt(P*B) Then divide the result by 2 times Si We divide by double Si, because we have added the mean of, two doping agents, to the mean of another two doping agents. sqrt(Ga*As)+sqrt(PB) = 90.57 Input Si and I will divide 2Si into the above sum: 28.09 (sqrt(Ga*As)+sqrt(PB))/2Si =: 1.61 This is the golden ratio (PHI) which equals 1.6 We have therefore discovered:

sqrt(Ga*As)+sqrt(PB) ———————————— = PHI

2(Si)

jharvard@appliance (~/Dropbox/discover):

#include <stdio.h> #include <math.h> int main (void)

{

printf("\n");

printf("\n");

19

of 37

printf("

(sqrt(PB))(P+B))+2PB\n");

 

printf("

————————————-

= phi\n");

printf("

2(P+B)(Si)

");

printf("\n"); printf("\n");

printf("(sqrt(PB))(P+B)=764.4486\n");

printf("2(PB)=669.5714\n");

printf("sqrt(764,4486)=27.64866\n");

printf("sqrt(669.5714)=25.876\n");

printf("(27.64866+25.876)/2 = 26.76233\n");

printf("This is approximately equal to aluminum (Al)\n");

printf("Al=26.98");

printf("\n"); printf("\n");

printf("2(P+B)(Si)=2,347.2004\n");

printf("sqrt(2,347.2004)=48.4479\n");

printf("This is approximately equal to titanium (Ti)\n");

printf("Ti=47.88\n");

printf("\n");

printf("This says a second generation robot,

\n");

printf("should have a skeleton composed of, printf("titanium-aluminum alloy\n"); printf("\n"); }

\n");

20

of 37

jharvard@appliance (~): cd Dropbox/discover

jharvard@appliance (~/Dropbox/discover): make busca

clang -ggdb3 -O0 -std=c99 -Wall -Werror

jharvard@appliance (~/Dropbox/discover): ./busca

busca.c -lcs50 -lm -o busca

(sqrt(PB))(P+B))+2PB

—————————— = phi

2(P+B)(Si)

(sqrt(PB))(P+B)=764.4486

2(PB)=669.5714

sqrt(764,4486)=27.64866

sqrt(669.5714)=25.876

(27.64866+25.876)/2 = 26.76233 This is approximately equal to aluminum (Al)

Al=26.98

2(P+B)(Si)=2,347.2004

sqrt(2,347.2004)=48.4479

This is approximately equal to titanium (Ti)

Ti=47.88

This says a second generation robot, should have a skeleton composed of, titanium-aluminum alloy

jharvard@appliance (~/Dropbox/discover):

21

of 37

It is at once clear what we need to do for the next phase of this project. Each guess we have made has had favorable results. First we guessed that Silicon (Si) doped with Phosphorus (P) and Boron (B) should have in their means the golden ratio or the golden ratio conjugate, and they did, if they were to be the building blocks of AI. Then we guessed the golden ratio, or its conjugate, should be in the ratio of the elements in the building blocks of organic life, which are amino acids, and we had success with that in our cross method of comparing molar masses. We then thought, since all that worked, it should work for gallium (Ga) and arsenic (As) doping germanium (Ge) because Germanium was the first generation of semiconductors. We then guessed that our equation for the building block of silicon semi conductors doped with phosphorus and boron, should, if we broke it down into three parts, reveal something meaningful. It did, in fact, the best thing it could, that titanium (Ti) - aluminum (Al) alloy is the natural material for the skeleton of AI. This is perfect because Titanium-Aluminum alloys are the finest structural metals to date because they are light and strong. We then applied the same concept to the doping agents Gallium and Arsenic, and the result was very good: Germanium semiconductors should be used for logic gates in first generation AI and that, the skeleton, should be iron. It made sense that it worked out this way.

Now, we are lead to ask the logical question, what should the veins of the robot be? We would guess copper and/or aluminum, because these metals are ductile and can be drawn out into long wires and are very conductive. Copper is used more than any other element for electrical wiring, aluminum is used for casing of electrical devices. Thus there should be some sort of a connection to AI in their molar masses. But, it does not stop there. We are lead to ask, what is used to insulate the wires? That is what should the protective skin of the veins be? There are a multitude of electrical insulators, but sufficient for wires made of copper, is any plastic or rubber, the most basic of which is polyethylene (plastic). It has the chemical formula:

{ (C }_{ 2 }{ H }_{ 4 })_{ n }

It has the chemical formula: { (C }_{ 2 }{ H }_{ 4 })_{ n }

The result is very perfect and almost exact, we find the polyethylene has a molar mass almost exactly the same as silicon, the source of diodes, transistors, and integrated circuitry used to make the logic gates that make AI “think”. Behold:

to make the logic gates that make AI “think”. Behold: This leaves us to contemplate what

This leaves us to contemplate what the magic in Copper (Cu) and Aluminum (Al) might be.

Cu = 63.55 g/mol and Al=26.98 g/mol

22

of 37

Electron Volt: A unit of energy equal to the work done on an electron in accelerating it through a potential of one volt. It is 1.6E10-19 Joules (Google Search Engine)

Volt: Potential energy that will impart on joule of energy per coulomb of charge that passes through it. (Wikipedia)

Coulomb: The charge of 6.242E18 protons or 6.242E18 electrons.

Forward Bias: A diode (silicon) must have 0.7 volts across it to turn it on, 0.3 volts (Germanium). This is called forward voltage. The forward voltage threshold is 0.6 volts.

(0.6 volts)(1.6E-19)=9.6E-20 Joules

This is the energy to turn on a diode, or the threshold of life for artificial intelligence. I call it a bue (basic unit of energy).

Aerobic respiration requires oxygen (O 2 ) in order to generate ATP. Although carbohydrates, fats, and proteins are consumed as reactants, it is the preferred method of pyruvate breakdown in glycolysis and requires that pyruvate enter the mitochondria in order to be fully oxidized by the Krebs cycle. The products of this process are carbon dioxide and water, but the energy transferred is used to break strong bonds in ADP as the third phosphate group is added to form ATP (adenosine triphosphate), by substrate- level phosphorylation, NADH and FADH2 (Wikipedia)

Simplified reaction:

C 6 H 12 O 6 (s) + 6 O 2 (g) 6 CO 2 (g) + 6 H 2 O (l) + heat ΔG = 2880 kJ per mol of C 6 H 12 O 6

(Wikipedia)

(2,880,000 J)/(6.02E23 C6H12O6) =4.784E-18 J = basic unit of biological life (4.784E-18 J)/(9.6E-20 J)=49.8~50

This says the basic energy unit of organic, or biological life, is about 50 times greater than the basic energy unit of electronic life, or artificial intelligence.

That is 0.6(50)=30 electron volts = basic unit of energy for biological life.

So, we see the visible spectrum for one photon of light begins where the energy of the photon is 2 “bue” electronic which is 100 “bue” biological and that that photon has a wavelength of 1.0 micrometers.

This is all about vision in a robot or AI.

23

of 37

23 of 37 +1.2eV —————|>—————————> out (9.6E-20 J, or 0.6 eV) | |

+1.2eV —————|>—————————> out (9.6E-20 J, or 0.6 eV)

|

|

—————|>———|

|

|

R

|

|

—————————

A photon has to have a minimum energy of 1.2 electron volts to impart to an electron for it to turn on the simplest of logic gates; a one on, one off, OR GATE, for there to be an output of one “bue” (basic unit of energy electronic) , which 9.6E-20 Joules, as I have calculated it.

Use Planck’s Equation: E=hv where h= 6.626E-34 Joule seconds

v=2(9.6E-20)/(6.626E-34)=3.067E14 cycles per second

wavelength = lambda = c/v where c is the speed of light equal to 3E8 m/s

24

of 37

lambda = (3E8)/(3.067E-14) = 9.78E-7 meters

1 micrometer = 1E-6 meters

lambda ~ 1 micrometer (This is where the visible spectrum begins)

So we see the visible spectrum for one photon of light begins where the energy is 2 bue.

k=4

by

ian beardsley

©2016

25

of 37

While Loop In Python

count.py

26

of 37

n=int(raw_input('Count to this integer: '))

x=0

if n>0:

while (x!=n):

x=x+1

print(str(x))

else:

print('Give me a positive integer.)

While Loop In C

cuenta.c

#include <stdio.h> int main(void)

{

int i=0;

int n;

printf("Give me an integer less than 10: "); scanf("%i", &n); while (n>0)

{

i=i+1;

n=n-1;

printf("%i\n", i);

}

}

For Loop In Python

For Loops in Python and C

cuenta.py

27

of 37

n=int(raw_input("Give me a positive int: ")) for number in range(1, n+1):

print(str(number))

For Loop In C

count.c

#include<stdio.h> int main (void)

{

int n;

do

{

printf("Count to this integer: "); scanf("%d", &n);

}

while (n<=0);

for (int i = 1; i<=n; i++)

{

printf("%d\n", i);

}

}

Running the For Loop in C (Does same thing as the While Loops)

jharvard@appliance (~): cd Dropbox/descubrir

jharvard@appliance (~/Dropbox/descubrir): ./count Count to this integer: 5

1

2

3

4

5

jharvard@appliance (~/Dropbox/descubrir):

28 of 37

28 of 37 print ( "Let us ask what is simplest k = 4 statement?" );

print("Let us ask what is simplest k = 4 statement?"); print("It is: "); print(" ");

k=4

x=0

while (x!=k):

x=x+1

print(x*"*"); print(" "); print("It depicts a 45-45-90 triangle"); print("It has for unit sides a square root of 2"); print("It is also one of the 'three special triangles'"); print("used to determine sin and cos functions of special angles"); print("It is important because 45 degrees is the maximum"); print("range for a projectile.”);

); print ( "It is important because 45 degrees is the maximum" ); print ( "range

29

of 37

print("The basic substances from which life formed on early earth are:

") print("CH4 (Methane), NH3 (Ammonia), H2O (water), H2 (hydrogen gas)") print("The idea of Wolfram is if we can describe something complex, ") print("with a few short lines of source code, then ") print("this can be an alternative to using mathematics ") print("to describe Nature. ") print("Because these substances from which life are made of, ") print("elements 6 (C), 7 (N). 8(O) of the period table and H, ") print("a simple loop can be written, because the C, N, and O, ") print("progress in increments of one, while the H decrements. ") print("as such we write code to make the pyramid of life.")

k=4;

x=1;

z=4;

while (x!=k):

x=x+1

z=z-1

print(x*"H"+z*"C");

print("Where we say HH=H2, HHH=H3, HHHH=H4, and, print("CCC = O, CC = N, and C = C.”)

")

); print ( "Where we say HH=H2, HHH=H3, HHHH=H4, and, print ( "CCC = O, CC

30

of 37

print(" "); print("Pythagoras thought the tetractys was the key to the universe") print("It is the triangle such that: 1, 1+1=2, 2+1=3, 3+1=4") print("which is 1+2+3+4=10") print(" ")

y=4

x=0

while (x!=4):

x=x+1

y=y-1

print(y*" "+x*"* ") print(" ");

" ) y= 4 x= 0 while (x!= 4 ): x=x +1 y=y -1 print (y*

31

of 37

It is my belief that, in order to make AI that thinks, you need to make a "therefore()" function that draws off a "what is this?()" function. To make an AI that uses the latter function it needs to be able to learn so that it can make a memory of data that grows and changes and can be used to try to determine what something is with the "what is this?()" function.

Ian Beardsley March 20, 2016

32

of 37

#include <stdio.h> int main (void)

{

printf("The computer knows what the sum of two numbers is.\n"); printf("x=float(raw_input(Enter x: \n"); printf("y=float(raw_input(Enter y: \n"); printf("z=x+y \n"); printf("print(x + y= + str(z) )\n"); printf("But, instead of asking the computer to say: \n"); printf("a times b = a*b \n"); printf("We can teach it from the definition of a+b \n"); printf("that a*b is a added to itself b times, and we write: \n"); printf("\n");

printf("a=float(raw_input(Enter a: \n"); printf("b=float(raw-input(Enter b: \n");

printf("result=0\n");

printf("while (b>0)\n"); printf(" result=result+a \n"); printf(" b=b-1 \n"); printf("else: \n");

printf("a times b equals: + str(result)\n"); printf("\n"); printf("Let us run the above code: \n"); float result=0, a, b; printf("Enter a: "); scanf("%f", &a); printf("Enter b: "); scanf("%f", &b); while (b>0)

{

result=result+a;

b=b-1;

}

printf("a times b is: %.2f\n", result);

}

33

of 37

33 of 37 


34

of 37

Last login: Mon Mar 21 20:15:20 on ttys000

Claires-MBP:~ ianbeardsley$ /Users/ianbeardsley/Desktop/analytics ; exit; The computer knows what the sum of two numbers is. x=float(raw_input(Enter x:

y=float(raw_input(Enter y:

z=x+y

print(x + y= + str(z) )

But, instead of asking the computer to say:

a times b = a*b

We can teach it from the definition of a+b that a*b is a added to itself b times, and we write:

a=float(raw_input(Enter a:

b=float(raw-input(Enter b:

result=0

while (b>0)

result=result+a

b=b-1

else:

a times b equals: + str(result)

Let us run the above code:

Enter a: 2 Enter b: 3

a times b is: 6.00

logout

[Process completed]

35

of 37

jharvard@appliance (~): cd Dropbox jharvard@appliance (~/Dropbox): make analytics

clang -ggdb3 -O0 -std=c99 -Wall -Werror

jharvard@appliance (~/Dropbox): ./analytics

The computer knows what the sum of two numbers is. x=float(raw_input(Enter x:

y=float(raw_input(Enter y:

z=x+y

analytics.c -lcs50 -lm -o analytics

print(x + y= + str(z) )

But, instead of asking the computer to say:

a times b = a*b

We can teach it from the definition of a+b that a*b is a added to itself b times, and we write:

a=float(raw_input(Enter a:

b=float(raw-input(Enter b:

result=0

while (b>0) result=result+a

b=b-1

else:

a times b equals: + str(result)

Let us run the above code:

Enter a: 2 Enter b: 3

a times b is: 6.00

jharvard@appliance (~/Dropbox):

36

of 37

As well we must make the computer understand that while multiplication is an addition process, division is a subtraction process:

we must make the computer understand that while multiplication is an addition process, division is a

The Author

37

of 37

The Author 37 of 37