• 500 likes • 607 Views
Chapter 9: Sample Applications. Outline Spreadsheets Databases Numeric and Symbolic Computations Computer Networks. Social Issues. Applications. Software. Virtual Machine. Hardware. Algorithmic Foundations. Spreadsheets. An electronic spreadsheet combines elements of: a calculator
E N D
Chapter 9: Sample Applications • Outline • Spreadsheets • Databases • Numeric and Symbolic Computations • Computer Networks Social Issues Applications Software Virtual Machine Hardware Algorithmic Foundations
Spreadsheets • An electronic spreadsheet combines elements of: • a calculator • a word processor • a database manager • a graphing tool • a modeling tool • … • Spreadsheet programs: • Widely used • Examples: • VisiCalc • MS Excel
Spreadsheets • A spreadsheet is a 2-dimensional grid of cells: • Rows: 1, 2, 3, … • Columns: A, B, C, … • Only a portion of the spreadsheet in visible on the screen • window • Window can be scrolled down/up • Cell: specifies a row and a column: • Activated using mouse or cursor • Example: • D2 means the cell at 2nd row and 4th column
Spreadsheets • Information in each cell may be: • Label • Numeric value • Mathematical formula • Labels • Text information that appear on the screen in a cell • Any cell can contain a label (row numbers and columns letters are also labels) • Format can be chosen: Font size, boldface, … • Example A B C D E 1 Item1 Item2 Total labels 2 3.25 5.75 9.00 numeric values
Spreadsheets • Numeric values: • Like labels can be formatted e.g. • only 2 digits after the decimal point • negative value in parentheses • Mathematical formulas • Do not appear on the screen • Entering a formula usually require some extra keystroke be done first • Example: • C2 = A2 + B2 • Total (C2) is computed automatically • Error message if A2 or B2 are not numeric values • Example: Payroll of a company
Spreadsheets A B C D E F G 1 ID Name Age Rate Hours Pay 2 101 Janet K 51 16.60 94 3 102 Adam R 18 8.50 185 4 103 Fred L 43 12.35 250 5 104 John A 53 17.80 245 6 105 Butch H 17 6.70 53 7 • Pay of Janet D2*E2 formula needed for Pay • Entering the formulas: • Enter D2*E2 in cell F2 • Copy (automatically supported) to other cells in column F
Spreadsheets What you enter: (formulas entered) A B C D E F 1 ID Name Age Rate Hours Pay 2 101 Janet K 51 16.60 94 D2*E2 3 102 Adam R 18 8.50 185 D3*E3 4 103 Fred L 43 12.35 250 D4*E4 5 104 John A 53 17.80 245 D5*E5 6 105 Butch H 17 6.70 53 D6*E6 What you see: (values computed) A B C D E F 1 ID Name Age Rate Hours Pay 2 101 Janet K 51 16.60 94 1560.40 3 102 Adam R 18 8.50 185 1572.50 4 103 Fred L 43 12.35 250 3087.50 5 104 John A 53 17.80 245 4361.00 6 105 Butch H 17 6.70 53 355.10
Spreadsheets • Other Features • Built-in functions for: • Average • Maximum • Minimum • User selects the desired cells and apply function • Graphics: • Data can be presented in graphical form • Line graph • Bar graph • Pie graph • etc. • Multiple sheets can be handled at one time • Formulas can be propagated to all sheets in use (if possible) • Create 3-dimensional sheets
Spreadsheets • Other Features (contd) • User can write macros • Macro: • A series of instructions called by name • “Like” a function … • The name serves as a shortcut notation • Use of macros saves time • Example of a macro • Select spreadsheet • Select chart type • Print sheet • every time you call the macro the 3 tasks are done automatically • Some database functions are also included in some spreadsheet programs
Spreadsheets • Spreadsheet as a modeling tool • Spreadsheet software does more than just: • edit spreadsheets • Perform simple calculations • … • Spreadsheets allow quick data modification and result presentation • Suppose the owner of the payroll spreadsheet wants to give his/her employees a raise (in a good year) • For example the increment should be 2% for each employee • a new cell in the spreadsheet to hold the fixed increment: 2% • a new column headed New Pay is also needed to store the incremented pay for each employee
Spreadsheets A B C D E F G 1 ID Name Age Rate Hours Pay New Pay 2 101 Janet K 51 16.60 94 1560.40 1591.61 3 102 Adam R 18 8.50 185 1572.50 1603.95 4 103 Fred L 43 12.35 250 3087.50 3149.25 5 104 John A 53 17.80 245 4361.00 4448.22 6 105 Butch H 17 6.70 53 355.10 362.20 7 8 Base Increase % 2 9 Totals $10936.50 $11155.23 G: new column for increased pay C8: stores the 2% value F9 and G9: store the total pay
Spreadsheets • Needed formulas: • D2*(1 + $C$8/100)*E2 (entered in cell G2) • G3 … G6: inserted automatically (by copying) after inserting G2 • same formula is used • $C$ in order to prevent indexing the C column for G2 … G6 (constant value!) • To compute the total in F9: • SUM(F2:F6) (entered in cell F9) • this means sum up all values in cells between F2 and F6 • By copying to cell G9, the corresponding formula SUM(G2:G6) is automatically generated • The nice thing is now that if the owner wants to examine an increased pay using another percent, say 3%, only cell C8 needs to be modified! • the new column G and the total pays are adjusted automatically
Spreadsheets • The owner may also use another more realistic formula for increments: • Each employee is given a “merit” percentage over a fixed base rate • A B C D E F G H • 1 ID Name Age Rate Hours Pay Merit New Pay • 2 101 Janet K 51 16.60 94 1560.40 3 1638.42 • 3 102 Adam R 18 8.50 185 1572.50 2 1635.40 • 4 103 Fred L 43 12.35 250 3087.50 3 3241.87 • 5 104 John A 53 17.80 245 4361.00 2 4535.44 • 6 105 Butch H 17 6.70 53 355.10 1 365.75 • 7 • 8 Base Increase % 2 • 9 Totals $10936.50 $11416.80
Spreadsheets • Formulas needed to be typed in (for “merits” example): • First, a column (we use G) is created to model the merits • Now column H is for new pay • D2*(1 + ($C$8 + G2)/100)*E2 (entered in H2) • Formulas in H3…H6 are generated automatically after copying • Moreover, some spreadsheet program can perform “goal seeking” • Suppose the owner only knows: • What merits each employee is worth • The amount of money reserved for salaries (in the current year) • Owner types in these values AND spreadsheet software seeks the amount of base increase percentage automatically • For example: • Suppose amount for this year is $12000.00 • Spreadsheet software will assign to cell C3 the value 7.33 automatically • Owner is now happy to know what is the base increment in this year (that does not exceed his/her expectation)
Spreadsheets • Imagine more complicated examples: • Company may vary the price of a product or the cost of supply and see immediately the effect on the profit • A chemist can experiment with the amount of additives necessary to obtain a smooth flow of a liquid in a pipe • An economist can track revenue impacts of a proposed tax increase • … • spreadsheet programs have become modeling and forecasting tools! • However: • Spreadsheets can only perform “numeric” modeling • Time dependence of data is not directly supported (but can be achieved)
Spreadsheets • Programming levels of spreadsheets: • Macro programming ( highest level): • Here a real programming language including (sequential, conditional, and interactive) instruction is provided in order to develop “programs” that simplify the work (of inputting formulas etc.) • Visual programming ( intermediate level): • Spreadsheet program acts like a (visual) language interpreter • it waits for the user to change something, and then delivers new results • “event-driven programming” • Can be compared to an (interpreted) functional language, since only formulas (functions!) are used • Formulas can: • Explicitly use if (-statement): e.g. IF(A3 > B3, A3-B3, B3-A3) • Implicitly use loops: e.g. when determining a base (input) value given a target one (like when we use target total pay 12000.00 to determine the base percentage) • Formulas (programming) ( lowest level): • Use of the basic arithmetic operations: e.g. A1*B1*C1 • Use of built-in functions: e.g. SUM(B2:B10), ABS(A1), etc.
Databases • Since Herman Hollerith demonstrated the advantages of mechanizing the processing of large amounts of data (in the US census of 1890), data processing emerged and evolved to a very common task at almost each desktop computer in the world • Large amounts of data are stored in permanent storages (disks, tapes, …) • Related data are organized in files in background storage: • A file has a name and further attributes, and • It includes the (user) data themselves • Common file types: • Text files: produced by e.g. a word processor • Graphic files: produced by e.g. drawing program • Program files: produced by e.g. a compiler (which is also stored in a program file) • … • File manager: • Often part of the operating system
Databases • Is a program that offers operations for: • Creating a new file in a directory • Reading information in a directory • Updating information in a directory • Deleting a file from a directory • A directory is a list of records consisting of: • File name • File size • Time of last update • Access rights • … • File manager has elementary capabilities: • A file is for the file manager a black box • File manager cannot even distinguish file types • More than that is needed … ( data organization) • But file manager is indispensable, since access to background storage is always through it(s operations).
Databases • Data organization • Let us confine us to (simple) user data files (no program files) • Data are based on bits and bytes • but these are too small quantities in real life • Data can be better organized in: • Fields: a collection of bytes (e.g. employee name) • Records: a collection of fields (e.g. employee information – name, phone#, …) • Data files: a collection of records (e.g. all employees in a company) • Database: a collection of data files (e.g. employees, inventory, …) • Structure of a database (consisting of 1 file) Field1 (e.g.ID) Field2 (e.g Name) Field3 (e.g. Age) Field4 (e.g. PayRate) Record1 Record2 Record3 Record4
Database • Attention: A record is unlike an array, since it may include fields of different data types and those fields are not accessed via indexes! • Database management system (DBMS) • A program that manages files in a databases • Codd E. F. observed records in a file as one entity: 2-dimensional table • He introduced the relational database model: • Now an employee file is not a collection of individual records but it is a 2 dimensional table • He suggested new terminology (now widely used): • Entity: is what the table represents e.g. employees file • Tuple: represents one instance of this entity (the old record or a row in a table) • Attribute: Heading (or name) of a column in a table (e.g. employee name, age, …) • Primary key: An attribute (or a collection of attributes) that uniquely identifies a tuple (e.g. SSN of an employee) • Relation: Same as entity from the point of view of “related” attributes
Databases • A DBMS is more than a file manager: • It works on the level of attributes and relations • It knows how data are organized and how to access them the best (using primary keys) • User data is a glass box for a DBMS (not a black box) • A DBMS is really a complex program: • It has its own data definition language (DDL) • It has its own data manipulation language or query language (DML) • After defining the data using DLL, the query language can be used to perform complex operations on the data • SQL: Structured Query Language • Examples of queries in SQL: • Get all information about employee 123, the user poses the following query: SELECTID, Name, Age, Payrate, Hours, Pay FROM Employee WHERE ID = 123;
Databases • Get pays of a specific employee: SELECT Name, Pay FROM Employee WHERE Name = ‘John Kay’; • Get all information about employees ordered by their IDs: SELECT * FROM Employee ORDERED BY ID; • Get all information about employees older then 21 years: SELECT * FROM Employee WHERE Age > 21; • A query using two tables: SELECT Employee.Name, Insurance.PanType FROM Employee, Insurance WHERE Employee.Name = ‘Fred James’ AND Employee.ID = Insurance.ID;
Databases • Issues in databases: • Transactions: • All-or-nothing… • Multimedia data: • Audio • Video • … • WWW • Accessing databases using browsers (hypermedia) • Distributed Databases • Data distributed among nodes • Replication and fault tolerance • Security
Numeric and Symbolic Computation • Historically, the first application of computers is numeric computation: • Baggage Analytic Engine for mathematical equations • Hollerith solved statistical problems (US census • 1940’s computers motivated by military-based mathematical problems • Today: numeric computation still a challenging task • Problems with up to 1015 mathematical operations are not uncommon • Typical areas: • Weather forecasting • Molecular analysis • Real-time imaging • Simulation • Natural language processing
Numeric and Symbolic Computation • Mentioned challenges yielded to the development of supercomputers and highly parallel computers • Machines with 1010 (and more) floating point operation per second have been constructed • Example: virtual reality ( real-time imaging) • Computer generates images in the same time frame and with the same orientation as when seen in real life • Images are displayed on glasses and headsets are used to feel like in a real scene • For example: as you are moving your arms, legs, and eyes, the computer may be generating and displaying simulated images of what you would see during a stroll through a forest. • High demands on computation ability: • about 24 images / sec • each image = e.g. one million of pixels (picture elements) • for each image: hundreds or thousands of mathematical operations
Numeric and Symbolic Computation • Computer determines repeatedly: • How far you have moved (since last image) • How your eyes/head is positioned • What is visible (what colors etc.) and what not from the current perspective • Thus: 24 images/sec, 1000 pixels each, 1000s of operations a pixel more than 24 billion of mathematical operations per second • In another rather esoteric area: quantum chromodynamics • 100 trillion (1014) of operations are needed for a single result! • A regular computer (25 MIPS) would work 1.5 moths to generate result • A supercomputer: 1 hour • A teraflop machine: less than 2 minutes
Numeric and Symbolic Computation • Even after the emergence of non-numeric applications (like word processing, databases, …), numeric computation are still very demanding, and in particular the field of symbolic computing • Symbolic Computing • Traditional numeric problems are based on “numeric values”: e.g. 13.57/1.8897 *sin(1.2*p) – cos(1.34*p)*10-4 • Symbolic computing works on quantities that represent numbers (like unknown variables of high school mathematics) • Examples: • Spreadsheets formula: D2*E2 • Simplify: -x2 + 3x – 4 + 3x2– x + 1 • Solve: x3 + 2x2 + 10x - 13 = 0 • Factor: x3 + x2– 3x – 3 • Plot: sin(3x) for 0 <= x <= 2p
Numeric and Symbolic Computation • There is a variety of software tools for symbolic computation (e.g. Mathematica, Maple) • Of course these tools are able to do numeric computations as well • In general the tools are interactive: • User: enters some request (here boldface) • Program: displays result (here italic) • Example: N[expr, i] • Entered when a numeric computation is wanted • Arithmetic expression expr is evaluated with the precision I • N[((13.1842/1.976) Sin[2.1 Pi])^(1.0/3.0) + 0.0406893, 6] 1.31346
Numeric and Symbolic Computation • Most symbolic systems work with ASCII representation of numbers and not with their binary representation: • “10” = 1010 (4 bits) • “10” = ‘1’’0’ (2 bytes) • they can achieve high precision (but need more memory) • Examples: • Compute p with 250 precision: • N[Pi, 250] 3.1415926535…52271201909 • Compute the factorial of 200: • 200! 78865786479050…737472000…00000
Numeric and Symbolic Computation • However the strength of these systems is in symbolic computing • Examples • Simplify expression: Simplify[expr] • Simplify[(x-1)^2 + (x+2) + (2x-3)^2 + x] 12 – 12 x + 5 x2 • Factor polynomial: Factor[polynomial] • Factor[x^10 -1] (-1 + x) (1 + x) (1 – x + x2 - x3 + x4) (1 + x + x2 + x3 + x4) • Expand expression: Expand[expr] • Expand[(1 + x + 3y)^4] 1 + 4x + 6x2 + 4x3 + x4 + 12y + 36xy + 36x2y + 12x3y + 54y2 + 108xy2 + 54x2y2 + 108y3 + 108xy3 + 81y4
Numeric and Symbolic Computation • Solve equations: Solve[equation, unknown] • Solve[x^2 – 5x + 4 == 0, x] (Note: “==“ means equal) {{x 4} { x 1}} • Solve transcendental equations like ex – 1.5 == 0 • Solve[Exp[x]– 1.5 == 0, x] {{x 0.405465} • Solve system of linear equations: • Solve[{2x + y == 11, 6x – 2y == 8}, {x, y}] {{x 3, y 5}} • Solve system of linear equations: • Solve[{2x + y == 11, 2x + y == 8}, {x, y}] { }
Numeric and Symbolic Computation • Calculus operations: • Differentiation: • D[x^3+6x-7, x] 6+ 3x2 • Integration: • Integrate[x^4 - 2, x] 1/5 x5 - 2x • Summation of (convergent) infinite series: • N[Sum[1/2^i, {i, 1, Infinity}]] 1.0 • Summation of (divergent) infinite series: • N[Sum[1/k, {k, 2, Infinity}]] Sum diverges
Numeric and Symbolic Computation • Plotting functions: • Plot[x^2 + x – 2, {x, -3, +2}] • Plot[5 Sin[3x], {x, 0, 2 Pi}]
Numeric and Symbolic Computation • Various options for plots are available: • Discrete: only some points • 3-dimensional: e.g. Plot3D[Sin[x*y]. {x, 0, 3}, {y, 0, 3}] • … • Process of performing user requests: • Get and analyze request • Activate the appropriate program to handle the request • Receive results • Display results • Issues: • Algorithms for symbolic computation • Exploiting parallelism • Distribution in a network
Computer Networks • A computer network consists of: • Computers • Peripheral devices (printers, disks, …) • An interconnection network • Types of networks: • local area network: LAN e.g. within buildings • Wide area network: WAN e.g. across countries • Benefits of networks: • Share physical resources: e.g. one printer in a department • Share logical resources: e.g. access to files, databases, … • Fault tolerance: e.g. if one printer fails, another can be used • Parallelism: e.g. print two documents on two different printers • Communication: e.g. email
Computer Networks • Further benefits: • Use of supercomputers in a WAN • Groupware: Joint editing of documents • Electronic data interchange: Data transfer from a program to a program; e.g. orders as output from a program at company X are transmitted to another program (that handles bills and shipping) at company Y ( no human intervention) • Use of network-centric applications: • WWW • E-commerce • Search engines • …
Computer Networks • Internet • One of the largest computer networks • Outgrowth of ARPANET (US DoD) • ARPANET was developed in 1970s • Internet is a network of networks • Advantages (of Internet) • Email • Voice mail • Cellular phones • Teleconferencing • … • Issues: • Reliability of networks • Efficiency • Privacy and confidentiality
Computer Networks • More about the Internet • Vision: “information superhighway” • global information access from everywhere by everyone at every time • Information should be a basic infrastructure good • Information should flow like current/voltage flows from plugs • Information is accessible through services • Internet is a big WAN (actually a WAN of WANs/LANs) • Internet is big collection of nodes connected by wire, each node is either a individual computer (e.g. mainframe) or a switching station
Computer Networks • User connects to the internet using: • Workstation • PC • Laptop • … • Connection: • Direct: user connects by telephone line to a “host” (already connected to Internet) • Over LAN: user machine is in a LAN that is connected to an internet host • Internet services • Email: • In order to communicate with someone via email you must know his/her email address
Computer Networks • Addressing scheme is hierarchical: jones@ournode.ccc.uleth.ca • “jones” identifies an individual account on a host computer • “ournode” identifies the host computer • “ccc” identifies where the host is located (perhaps central computer center) • “uleth” identifies the organization where this machine is located (U of L) • “ca” specifies the country or organization sector (here Canada) • Problems with Email: • Is not protected (default) • Informality of an email may be misinterpreted (by reader) • Viruses in emails!
Computer Networks • Remote log-in • The service is called “telnet” • Used to log on to any computer in the Internet • Login types: • Anonymous • Individual • After logging in your are like a direct user of the machines • Why? • In order to access a database • In order to use a special compiler • In order to run a program on a supercomputer • … • Clearly, the user notices a delay when accessing remote machines
Computer Networks • File transfer: • Service: FTP (file transfer protocol) • This service allows a user to transfer files between two machines • Files can be of arbitrary length and of any type • Commands: • Put: from your machine to remote computer • Get: from remote computer to your machine • … • Anonymous ftp: open services for everyone • Difference between telnet, ftp, and email: • Telnet: you are a user of the remote machine • FTP: you are not a user, you are only allowed to use commands of FTP • Emails: only text files, you communicate with a user (not a machine)
Computer Networks • Browsing: • Gopher: • Allows to “jump” from one machine to another collecting information • Menu-driven • Menu contents e.g. • Library entries • General information • Next gopher site(s) • WAIS: • Use keywords to retrieve information from directories in the Internet • WWW: • Hypertext-based navigation • Any kind of information (text, audio, video, …) • Browser software needed (e.g. Netscape, Internet Explorer, …)
Computer Networks • Different services: • Search engines • Email • Applications/Applets • … • Bulletin board: • E.g. newsgroups: discussion groups on a specific topic • Hierarchal naming e.g. cs.comp.parallel • In general moderated • Chatting • …
Computer Networks • Some Internet statistics (rather old) • 20,000 networks in the Internet • A new network every 10 minutes • 4 million hosts • More than 50 million people have access to the Internet • Over 5,000 news groups • Over 4,000 Gopher servers • Annual traffic growth of WWW is 341,634 percent!!! • Internet services in use for more than 2 decades (by insiders) • Based on current growth, by 2003 every person on the globe will have Internet access (???)
Computer Networks • Issues in networking • Transmission is analog, but data are digital • conversion is needed • conversion: use of Fourier series to approximate digital signal by superposition of multiple analog ones • Bandwidth: maximum transmission rate (medium-specific) • Media: • Twisted pair copper wire: • Used in telephone networks • Inexpensive • Limited bandwidth • Signal deteriorates at distances longer than 10 km (amplifiers needed, repeaters)
Computer Networks • Coaxial cable: • Used for cable TV • More bandwidth but more expensive • Signal deterioration also at about 10 km but is less subject to “noise” • Fiber optic: • Bundles of thin glass wire • Signal are pulses of light • High bandwidth • Up to 100 km without deterioration • More expensive • Message transmission in a WAN • In general a WAN is a switched network • messages travel from one switch to another on the way to their destinations
Computer Networks • A message includes its destination address in order to help intermediate nodes to “switch in the right direction” • Multiple paths from source to destination are possible (and usual) • Why? • Reliability: redundant connections • Efficiency: more connections among nodes with higher traffic or parallel connections • What path is the best? • Shortest ones? • Less intermediate nodes or less distance? • Path with highest bandwidth? • Priorities for messages? • High priority messages use high bandwidth paths • Low priority messages use low bandwidth paths
Computer Networks • Thus, answer is not trivial… • After all, determining the “best” path is a prohibitively long task • compare: bin-packing problem O(2n) • A number of routing algorithms are in use • Message transmission in a LAN • Bus-based LANs (e.g. Ethernet) • Broadcasting: • Any message is sent to ALL nodes in the network • Each node checks whether or not it is the message destination • If yes, message is completely received and processed • If not, message is ignored • Collision is possible: • “A” sends “m1” and before “m1” is received “A2” sends “m2” • Since medium is shared, “m2” collides with “m1” • Both are then useless for potential receivers
Computer Networks • Thus, collision must be detected and sending machines retry to send the message again • In order not to collide another time the machines wait different “random” periods before sending