Lecture 23 Numeric and Symbolic Computing Numeric & Symbolic Computing

advertisement

Lecture 23 4/5/04 23:16

4/5/04

(S&G, §§ 11.3

– 11.4, 12.1

– 12.2)

CS 100 - Lecture 23 1

CS 100

4/5/04

Numeric and Symbolic

Computing

CS 100 - Lecture 23 2

1

Lecture 23

Numeric Computation

• Applications that make heavy use of real arithmetic

• Especially used in science, engineering, economics, statistics, animation

• The motivation for the first computers

• Still drives the development of supercomputers and parallel computers

 a teraflop machine performs at least 10 12 (a trillion) floating-point operations per second

 36 Tflops already achieved (Japan’s Earth Simulator, which cost $350–500M)

4/5/04 CS 100 - Lecture 23 3

Computer Science Issues

• Performance:

– better algorithms

– accessing of data in memory hierarchies

– parallel computation

– data communication in networks

• Mathematical software libraries

• Accuracy and stability of numerical approximations

4/5/04 CS 100 - Lecture 23 4

4/5/04 23:16

CS 100 2

Lecture 23

CS 100

Symbolic Computing

• Manipulate mathematical formulas, equations, etc. much the way a mathematician would

– automate processes that are mechanical, tedious, and error-prone

• Examples: Macsyma, Mathematica, Maple,

MatLab

4/5/04 CS 100 - Lecture 23 5

Example: Simplification

( x − 1 )

2

+ ( x + 2 ) + ( 2 x − 3 )

2

+ x

• Simplify[(x-1)^2 + (x+2) +

(2x-3)^2 + x]

• 12 - 12x + 5x 2

4/5/04 CS 100 - Lecture 23 6

4/5/04 23:16

3

Lecture 23

Example: Expansion

( 1 + x + 3 y )

4

• Expand[(1 + x + 3y)^4]

• 1 + 4x + 6x

2 + 4x 3 + x 4 + 12y

2 y + 12x 3 y + 54y 2

+ 108xy 2 + 54x

+108xy 3 + 81y 4

2 y 2 + 108y 3

4/5/04 CS 100 - Lecture 23 7

Example: Solving Equations

2 x + y = 11

6 x − 2 y = 8

• Solve[ {2x + y == 11,

6x - 2y == 8},

• {{x -> 3, y -> 5}}

4/5/04 CS 100 - Lecture 23 8

4/5/04 23:16

CS 100 4

Lecture 23

Typical Expansion Rules

Expand [ X × ( Y + Z ) ] ⇒ X × Y + X × Z

Hence ,

Expand [ ( X + Y ) × Z ] ⇒ X × Z + Y × Z

Expand [ ] ⇒ X × X

Expand[( n + 1) 2 ]

⇒ Expand[( n + 1)( n + 1)]

⇒ Expand[( n + 1) n + ( n + 1)1]

⇒ Expand[( n + 1) n + ( n + 1)1]

⇒ Expand[ n × n + 1 × n + n × 1 + 1 × 1]

4/5/04 CS 100 - Lecture 23 9

Digression

• Recall our discussion of formalized mathematics , and the idea of reducing mathematics to the mechanical application of formal rules

• Formal rules: depend on the form of expressions, not their meaning

• Symbolic computation is an application of the idea of a calculus

4/5/04 CS 100 - Lecture 23 10

4/5/04 23:16

CS 100 5

Lecture 23

Computer Science Issues

• Symbolic computation systems are:

– very high-level languages

– problem-specific

– nonprocedural

• Depend on many algorithms, e.g.:

– pattern matching

– efficient management of complex data structures representing formulas

• Results should be presented in a form familiar and useful to the mathematically literate

4/5/04 CS 100 - Lecture 23 11

4/5/04 23:16

CS 100

4/5/04

Computer Networks

(S&G ch. 12)

CS 100 - Lecture 23 12

6

Lecture 23

Communication Links

• Switched dial-up phone lines

– require modem (modulator-demodulator) to interface between digital interface and analog phone line

• Dedicated links

– wired (wire proper & fiber optic cable)

– wireless

4/5/04 CS 100 - Lecture 23 13

Kinds of Networks

• Local Area Network (LAN)

– limited range (building, campus)

– typically owned by owners of premises

– example: Ethernet

• Wide Area Network (WAN)

– worldwide (and beyond!)

– typically owned by telecommunications services

– example: Internet

4/5/04 CS 100 - Lecture 23 14

4/5/04 23:16

CS 100 7

Lecture 23

Ethernet

• Developed at Xerox PARC in mid-70s

• Communication protocols govern use of the network

• Ethernet uses contention-based distributed control

4/5/04 CS 100 - Lecture 23 15

Single-Cable Ethernet intended transmission

4/5/04 23:16

CS 100

4/5/04 CS 100 - Lecture 23 16

8

Lecture 23

Single-Cable Ethernet

(1) Listen

4/5/04 CS 100 - Lecture 23

Single-Cable Ethernet

(2) Transmit

17

4/5/04 23:16

CS 100

4/5/04 CS 100 - Lecture 23 18

9

Lecture 23

Single-Cable Ethernet

(3) Broadcast

4/5/04 CS 100 - Lecture 23

Single-Cable Ethernet

(4) Receive

19

4/5/04 23:16

CS 100

4/5/04 CS 100 - Lecture 23 20

10

Lecture 23

Single-Cable Ethernet

(5) Inactive

4/5/04 CS 100 - Lecture 23

Single-Cable Ethernet

(1) Listen

21

4/5/04 23:16

CS 100

4/5/04 CS 100 - Lecture 23 22

11

Lecture 23

Single-Cable Ethernet

(2) Transmit

4/5/04 CS 100 - Lecture 23

Single-Cable Ethernet

(3) Collision

23

4/5/04 23:16

CS 100

4/5/04 CS 100 - Lecture 23 24

12

Lecture 23

Single-Cable Ethernet

(4) Wait Randomly

4/5/04 CS 100 - Lecture 23

Single-Cable Ethernet

(5) Listen

25

4/5/04 23:16

CS 100

4/5/04 CS 100 - Lecture 23 26

13

Lecture 23

Single-Cable Ethernet

(6) Rebroadcast

4/5/04 CS 100 - Lecture 23

Single-Cable Ethernet

(7) Inactive

27

4/5/04 23:16

CS 100

4/5/04 CS 100 - Lecture 23 28

14

Lecture 23

Single-Cable Ethernet

(8) Listen

4/5/04 CS 100 - Lecture 23

Single-Cable Ethernet

(9) Rebroadcast

29

4/5/04 23:16

CS 100

4/5/04 CS 100 - Lecture 23 30

15

Lecture 23

CS 100

A:

B: wait

C: time

4/5/04 wait

Collision Recovery

CS 100 - Lecture 23 wait

31

Wide Area Networks (WANs)

• LANs typically broadcast messages

• WANs typically use point-to-point communication

• Typically use store and forward packetswitching

– packet = fixed-size quantity of information

– large messages divided into packets

4/5/04 CS 100 - Lecture 23 32

4/5/04 23:16

16

Lecture 23

Point-to-point Communication

4/5/04 23:16

4/5/04 CS 100 - Lecture 23

Point-to-point Communication:

Node Failure

33

CS 100

4/5/04 CS 100 - Lecture 23 34

17

Lecture 23

CS 100

Store-and-Forward Packet-Switching

A

C

ACK

D: packet

D: packet

B

4/5/04 CS 100 - Lecture 23 35

What We Need

• A way of finding a computer (“server”) on the Internet

• A way of locating a Web page on that computer

• A way of displaying that Web page on my computer (“client”)

4/5/04 CS 100 - Lecture 23

(slide < S. Levy)

36

4/5/04 23:16

18

Lecture 23

Locating Computers on the Internet

• TCP/IP (Transmission Control Protocol/Internet

Protocol) – a set of protocols (“rules of the game”) for making transactions

• IP address – standard for identifying a computer

• TCP – describes how packets are sent and retrieved

4/5/04 CS 100 - Lecture 23

(slide < S. Levy)

37

IP Format

• Example: 204.202.129.230

• 4 groups of 3 digits

• Range from 0 to 255 (8 bits)

• Total of 256 4 or over 4 billion computers

4/5/04 CS 100 - Lecture 23

(slide < S. Levy)

38

4/5/04 23:16

CS 100 19

Lecture 23

CS 100

The Internet and the Web

• The Web sits on top of the Internet and uses its protocols (HTTP, FTP, MAILTO, etc.)

• URL (Uniform Resource Locator) – allows different computers to use the same protocols for Web-based transactions

• HTTP (HyperText Transfer Protocol) format: http: // where / what e.g., http://www.cs.utk.edu/~cs100

4/5/04 CS 100 - Lecture 23

(slide adapted < S. Levy)

39

4/5/04

The Internet and the Web

Web

Internet

URL

HTTP, FTP,

MAILTO, ...

TCP

IP

CS 100 - Lecture 23

(slide < S. Levy)

40

4/5/04 23:16

20

Lecture 23

CS 100

Named Address ( Domain Name )

• It’s hard to remember 12 digits

• Provide a name and get the computer

(Domain Name Server) to translate it to the IP

address

• e.g, http://160.36.56.64/~cs100 =

http://www.cs.utk.edu/~cs100

4/5/04 CS 100 - Lecture 23

(slide adapted < S. Levy)

41

Two Standards for Web Pages

• Standard protocol (URL)

• Standard language for describing Web pages (HTML – HyperText Markup

Language)

• HTML: A set of commands for formatting

Web pages

4/5/04 CS 100 - Lecture 23

(slide < S. Levy)

42

4/5/04 23:16

21

Lecture 23

How HTML Works: Client/Server

Server’s disk Network connection

Client’s browser

1. The client sends a request for a page to the server.

2. HTML code is sent as text to the client.

3. HTML code is stored in the client’s cache (temporary memory).

4. The client’s browser interprets the HTML code and formats the page.

4/5/04 CS 100 - Lecture 23

(slide < S. Levy)

43

How HTML Works: Client-Side

• The spirit of HTML:

– Content (text, images, videos) + “suggestions” on how to format it

– Hyper-links to other web pages

• Actual formatting (fonts, positions, colors) should be up to client’s browser ( e.g., lynx entirely text-based)

• In practice, web designers want more control (frames, tables, blank spaces)

4/5/04 CS 100 - Lecture 23

(slide < S. Levy)

44

4/5/04 23:16

CS 100 22

Lecture 23

Typical Network Services

• Resource sharing

– print servers, file , compute servers

• Information sharing

– data interchange, information utilities

• Communication

– e-mail, bulletin boards, news groups, chat rooms

• Electronic commerce

• Security issues

– authentication, secrecy, fault tolerance

4/5/04 CS 100 - Lecture 23 45

4/5/04 23:16

4/5/04

Read S&G, ch. 13

(Artificial Intelligence) for next class

CS 100 - Lecture 23 46

CS 100 23

Download