259 Lecture 25: Simple Programming

Size: px
Start display at page:

Download "259 Lecture 25: Simple Programming"

Transcription

1 259 Lecture 25: Simple Programming In[1]:= In[2]:= Off General::spell Off General::spell1 Note: To type a command in a Mathematica notebook, use the mouse to move the cursor until it is horizontal, click the left mouse button, and type the command. To enter a command, use the mouse to move the cursor until it is vertical and over the command line, then click the left mouse button, and finally press and hold the Shift key followed by Enter key or use the Enter key on the smaller number keypad (lower right-hand corner of keyboard). To expand cells, double click on the cell bracket (blue vertical bar to the right) with the downward pointing arrow. Def: A computer program or program is a sequence of instructions that a computer can interpret and execute. (from dictionary.com) Def: A computer program is one or more instructions that are intended for execution by a computer. Without programs, computers would not run. Moreover, a computer program does nothing unless its instructions are executed by a central processor. Computer programs are the result of the compilation or interpretation of programming languages, are embedded into hardware, or may be manually inputted to the central processor of a computer. (from Wikipedia) Mathematica can be used to write computer programs when more than single step or an iterative process is required for some application or problem that needs to be solved. In addition to the logical operators AND, OR, NOT, etc, there are several built-in functions similar to the IF command in Excel that can be used to write computer programs! We will look at these logical operators, as well as WHICH, SWITCH, NEST, PRINT, DO, FOR, and WHILE, and finish up with a simple program for Newton's Method. Logical Operators (And, Or, Not) And e 1 && e 2 && is the logical AND function. It evaluates its arguments in order, giving False immediately if any of them are False, and True, if they are all True. And[e 1, e 2, ] can be input in StandardForm and InputForm as e 1 e 2.

2 2 259Lecture25sp17.nb The character can be entered as Ç&&, Çand or [And]. Example 1 In[3]:= 2 3 4&&4 2 Out[3]= False In[4]:= Out[4]= False In[5]:= Out[5]= And 2 3 5, 4 4 True In[6]:= Out[6]= a True, False True, False In[7]:= TableForm Table And a i, a j, i, 1, 2, j, 1, 2, TableHeadings a, a Out[7]//TableForm= True False True True False False False False Or e 1 e 2 is the logical OR function. It evaluates its arguments in order, giving True immediately if any of them are True, and False if they are all False. Or[e 1, e 2, ] can be input in StandardForm and InputForm as e 1 e 2. The character can be entered as Ç, Çor or [Or]. Example 2 In[8]:= Out[8]= True In[9]:= Out[9]= False In[10]:= Out[10]= Or 1 Sin 2, 3 True In[11]:= Out[11]= a True, False True, False

3 259Lecture25sp17.nb 3 In[12]:= Out[12]//TableForm= TableForm Table Or a i, a j, i, 1, 2, j, 1, 2, TableHeadings a, a True False True True True False True False Not!expr is the logical NOT function. It gives False if expr is True, and True if it is False. Not[expr] can be input in StandardForm and InputForm as Ÿexpr. The character Ÿ can be entered as Ç!, Çnot or [Not]. In[13]:= 3 3 Example 3 Out[13]= True In[14]:= Out[14]= 3 3 False In[15]:= Out[15]= Not 3 3 False In[16]:= Out[16]= Not 2 3 True In[17]:= Out[17]= True False In[18]:= Out[18]= 7 4 False In[19]:= Out[19]= Not Not True True In[20]:= Out[20]= True False False In[21]:= Out[21]= True In[22]:= Out[22]= True False False

4 4 259Lecture25sp17.nb In[23]:= Out[23]= a True, False True, False In[24]:= Out[24]= Table a i, i, 1, 2 False, True More Logical Operators (Xor, Nor, Nand) Xor Xor[e 1, e 2, ] is the logical XOR (exclusive OR) function. It gives True if an odd number of the e i are True, and the rest are False. It gives False if an even number of the e i are True, and the rest are False. Xor[e 1, e 2, ] can be input in StandardForm and InputForm as e 1 ƒ e 2 ƒ. The character ƒ can be entered as Çxor or [Xor]. Example 4 In[25]:= Out[25]= Xor True, 2 4, False True In[26]:= Out[26]= Xor True, 2 4, False, True False In[27]:= Out[27]= a True, False True, False In[28]:= TableForm Table Xor a i, a j, i, 1, 2, j, 1, 2, TableHeadings a, a Out[28]//TableForm= True False True False True False True False Nor Nor[e 1, e 2, ] is the logical NOR function. It evaluates its arguments in order, giving False immediately if any of them are True, and True if they are all False. Nor[e 1, e 2, ] can be input in StandardForm and InputForm as e 1 e 2. The character can be entered as Çnor or [Nor].

5 259Lecture25sp17.nb 5 Nor[e 1, e 2, ] is equivalent to Not[Or[e 1, e 2, ]]. Example 5 In[29]:= Out[29]= a True, False True, False In[30]:= TableForm Table Nor a i, a j, i, 1, 2, j, 1, 2, TableHeadings a, a Out[30]//TableForm= True False True False False False False True In[31]:= TableForm Table Or a i, a j, i, 1, 2, j, 1, 2, TableHeadings a, a Out[31]//TableForm= True False True False False False False True Nand Nand[e 1, e 2, ] is the logical NAND function. It evaluates its arguments in order, giving True immediately if any of them are False, and False if they are all True. Nand[e 1, e 2, ] can be input in StandardForm and InputForm as e 1 e 2. The character can be entered as Çnand or [Nand]. Nand[e 1, e 2, ] is equivalent to Not[And[e 1, e 2, ]]. Example 6 In[32]:= Out[32]= a True, False True, False In[33]:= TableForm Table Nand a i, a j, i, 1, 2, j, 1, 2, TableHeadings a, a Out[33]//TableForm= True False True False True False True True In[34]:= TableForm Table And a i, a j, i, 1, 2, j, 1, 2, TableHeadings a, a Out[34]//TableForm= True False True False True False True True

6 6 259Lecture25sp17.nb If If[condition, t, f] gives t if condition evaluates to True, and f if it evaluates to False. If[condition, t, f, u] gives u if condition evaluates to neither True nor False. If evaluates only the argument determined by the value of the condition. If[condition, t, f] is left unevaluated if condition evaluates to neither True nor False. If[condition, t] gives Null if condition evaluates to False. Example 7 If Syntax: In[35]:= If 3 3,, 0,7 Out[35]= 0 In[36]:= If 3 3 True,, 0,7 Out[36]= In[37]:= If x,, 0,7 Out[37]= 7 A piecewise-defined function that can be differentiated! In[38]:= Clear f In[39]:= f x_ : x ; x 0 f x_ : x ; x 0 In[41]:= Plot f x, x, 2, Out[41]=

7 259Lecture25sp17.nb 7 In[42]:= Plot f x, x, 2, Out[42]= In[43]:= Out[43]= f' x f x In[44]:= In[45]:= In[46]:= Clear f f x_ : If x 0, x, x Plot f x, x, 2, Out[46]=

8 8 259Lecture25sp17.nb In[47]:= Plot f x, x, 2, Out[47]= In[48]:= Out[48]= f' x If x 0, 1, 1 In[49]:= Out[49]= f'' x If x 0, 0, 0 Which Which[test 1, value 1, test 2, value 2, ] evaluates each of the test i in turn, returning the value of the value i corresponding to the first one that yields True. If any of the test i evaluated by Which give neither True nor False, then a Which object containing these remaining elements is returned unevaluated. You can make Which return a default value by taking the last test i to be True. Example 8 Which can be used to construct piecewise-defined functions! In[50]:= g x_ : Which x 2, 2 x, 2 x 0, x 2,x 0, Cos x

9 259Lecture25sp17.nb 9 In[51]:= Plot g x, x, 3, Out[51]= In[52]:= Plot g x, x, 3, Out[52]= In[53]:= g' x Out[53]= Which x 2, 1, 2 x 0, Here is the Heaviside Function: 1 2 x 2,x 0, Sin x In[54]:= H x_ : Which x 0, 0, x 0, 1

10 10 259Lecture25sp17.nb In[55]:= Plot H x, x, 1, Out[55]= In[56]:= Out[56]= Which True, 45, y, 23 In[57]:= Out[57]= Which False, 45, y, 23 Which y, 23 In[58]:= Out[58]= Which y, 23, False, 45, True, 87 Which y, 23, False, 45, True, 87 In[59]:= Out[59]= 87 Which True, 87, y, 23, False, 45 Switch Switch[expr, form 1, value 1, form 2, value 2, ] evaluates expr, then compares it with each of the form i in turn, evaluating and returning the value i corresponding to the first match found. Only the value i corresponding to the first form i that matches expr is evaluated. Each form i is evaluated only when the match is tried. If the last form i is the pattern _, then the corresponding value i is always returned if this case is reached. If none of the form i match expr, the Switch is returned unevaluated. Example 9 This use of Switch defines a function that depends on the values of its argument modulo 3. In[60]:= r x_ : Switch Mod x, 3, 0, a, 1, b, 2, c, _, "Input is not an integer "

11 259Lecture25sp17.nb 11 In[61]:= Out[61]= r 1 b In[62]:= Out[62]= r 11 c In[63]:= Out[63]= r 234 True, False In[64]:=?a Global`a a True, False In[65]:= In[66]:= Out[66]= Clear a r 234 a In[67]:= Out[67]= r 2.3 Input is not an integer In[68]:= Out[68]= r à Input is not an integer In[69]:= Out[69]= r à à a Nest Nest[f, expr, n] gives an expression with f applied n times to expr. Example 10 The Nest command can be used to find closed-form solutions of recurrence relations! a. x n = 1 + r x n - 1 In[70]:= In[71]:= Clear f f x_ : 1 r x

12 12 259Lecture25sp17.nb In[72]:= Out[72]//TableForm= TableForm Table n, Simplify Nest f, x 0,n, n, 0, 10, TableHeadings None, "n", "x n " n x n 0 x r x r 2 x r 3 x r 4 x r 5 x r 6 x r 7 x r 8 x r 9 x r 10 x 0 In[73]:= Clear x b. x n =ax n - 1 +b In[74]:= In[75]:= g x_ : x TableForm Table n, Simplify Nest g, x 0,n, n, 0, 10, TableHeadings None, "n", "x n " Out[75]//TableForm= n x n 0 x 0 1 x 0 2 x 0 3 x x x x x x x x 0 Print Print[expr 1, expr 2, ] prints the expr i concatenated together. Example 11 Try each command!

13 259Lecture25sp17.nb 13 In[76]:= Print "Hello World " Hello World In[77]:= p 4 Out[77]= 4 In[78]:= Print "p is equal to ", p p is equal to 4 In[79]:= Print "p 2 is equal to ", p 2, "." p 2 is equal to 16. In[80]:= Print "Part of this sentence \n", "is printed on a new line " Part of this sentence is printed on a new line In[81]:= Print "The graph of y sin x on the interval 0, looks like this:\n", Plot Sin x, x, 0,, "\nwhat would the graph look like on,?" The graph of y sin x on the interval 0, looks like this: What would the graph look like on,? Do Do[expr, {i max }] evaluates expr i max times. Do[expr, {i, i max }] evaluates expr with the variable i successively taking on the values 1 through i max (in steps of 1). Do[expr, {i, i min, i max }] starts with i = i min Do[expr, {i, i min, i max, di}] uses steps di. Do[expr, {i, i min, i max }, {j, j min, j max }, ] evaluates expr looping over different values of j, etc. for each i. (As with Table, the outermost iterator comes first...) Unless an explicit Return is used, the value returned by Do is Null. Null is a symbol used to indicate the absence of an expression or a result. When it appears as an output expression, no output is printed.

14 14 259Lecture25sp17.nb Example 12 Here is a way to add the sum of the squares of the first 10 positive integers! In[82]:= sum 0; In[83]:= Do sum sum i^2, i, 10 In[84]:= sum Out[84]= 385 In[85]:= In[86]:=?i Clear sum Note that in a Do loop, the counter i is a local variable. The variable "sum" was defined externally, so it is global. In[87]:=? sum Global`sum Check with the known formula : In[88]:= Out[88]= Sum i 2, i, 1, n 1 n 1 n 1 2n 6 In[89]:= Out[89]= This loop can be simplified by replacing the =sum+ with +=: In[90]:= sum 0; In[91]:= Do sum i^2, i, 1000 In[92]:= sum Out[92]= In[93]:= Clear sum We can print out the intermediate sums with Print: In[94]:= sum 0; In[95]:= Do Print "The sum of the squares of the first ", i, " positive integers is ", sum i^2, i, 10

15 259Lecture25sp17.nb 15 The sum of the squares of the first 1 positive integers is 1 The sum of the squares of the first 2 positive integers is 5 The sum of the squares of the first 3 positive integers is 14 The sum of the squares of the first 4 positive integers is 30 The sum of the squares of the first 5 positive integers is 55 The sum of the squares of the first 6 positive integers is 91 The sum of the squares of the first 7 positive integers is 140 The sum of the squares of the first 8 positive integers is 204 The sum of the squares of the first 9 positive integers is 285 The sum of the squares of the first 10 positive integers is 385 How could we "fix" this Print command so that it uses "correct" grammar? One possible solution In[96]:= sum 0; In[97]:= Do If i 1, Print "The sum of the squares of the first ", i, " positive integer is ", sum i^2, Print "The sum of the squares of the first ", i, " positive integers is ", sum i^2, i, 10 The sum of the squares of the first 1 positive integer is 1 The sum of the squares of the first 2 positive integers is 5 The sum of the squares of the first 3 positive integers is 14 The sum of the squares of the first 4 positive integers is 30 The sum of the squares of the first 5 positive integers is 55 The sum of the squares of the first 6 positive integers is 91 The sum of the squares of the first 7 positive integers is 140 The sum of the squares of the first 8 positive integers is 204 The sum of the squares of the first 9 positive integers is 285 The sum of the squares of the first 10 positive integers is 385 In[98]:= Clear sum For For[start, test, incr, body] executes start, then repeatedly evaluates body and incr until test fails to give True. For[start, test, incr] does the loop with a null body.

16 16 259Lecture25sp17.nb The sequence of evaluation is test, body, incr. The For loop exits as soon as test fails. If Break[ ] is generated in the evaluation of body, the For loop exits. Continue[ ] exits the evaluation of body, and continues the loop by evaluating incr. Unless an explicit Return is used, the value returned by For is Null. Example 13 Try each command! In[99]:= In[100]:= For i 0, i 5, i, i^2 Print Null Unless otherwise specified, For returns Null. Null is a symbol used to indicate the absence of an expression or a result. When it appears as an output expression, no output is printed. One way to get output from this command is to use the Print function inside the For loop! In[101]:= For i 0, i 5, i, Print i^ In[102]:=?i Note that unlike the Do command, the counter variables are global so they actually change and are stored in memory! i 6 One way to get rid of this "problem" is to use the Module command, which specifies which variables are local, i.e. not saved in memory as a global variable! The syntax for Module is: Module[{x, y, }, expr]. In this case, occurrences of the symbols x, y, in expr are treated as local. Module[{x = x 0, }, expr] defines initial values for local variables x,. In[103]:= Module i, For i 0, i 15, i, Print "When i ", i, ", i 2 ", i^2, "."

17 259Lecture25sp17.nb 17 In[104]:=?i When i 0, i 2 0. When i 1, i 2 1. When i 2, i 2 4. When i 3, i 2 9. When i 4, i When i 5, i When i 6, i When i 7, i When i 8, i When i 9, i When i 10, i When i 11, i When i 12, i When i 13, i When i 14, i When i 15, i i 6 In[105]:= Clear i In[106]:= L 4; For i 0, i L, i, Print "Hello World, number ", i Hello World, number 0 Hello World, number 1 Hello World, number 2 Hello World, number 3 Hello World, number 4 In[108]:=?i i 5 In[109]:=?L Global`L L 4

18 18 259Lecture25sp17.nb In[110]:= Clear L, i In[111]:= Module L, L 4; For i 0, i L, i, Print "Hello World, number ", i Hello World, number 0 Hello World, number 1 Hello World, number 2 Hello World, number 3 Hello World, number 4 In[112]:=?L Global`L In[113]:=?i i 5 In[114]:= Clear L, i In[115]:= Module L, i, L 4; For i 0, i L, i, Print "Hello World, number ", i Hello World, number 0 Hello World, number 1 Hello World, number 2 Hello World, number 3 Hello World, number 4 In[116]:=?L Global`L In[117]:=?i Anything that results in a numerical value can be used in the counter! Also note that placement of the iterator can affect the For loop's output! In[118]:= For i 0, i 5, i, Print "Hello World, number ", i

19 259Lecture25sp17.nb 19 Hello World, number 0 Hello World, number 1 Hello World, number 2 Hello World, number 3 Hello World, number 4 Hello World, number 5 In[119]:=?i i 6 In[120]:= For i 2, i 5, i, Print "Hello World, number ", i Hello World, number 2 Hello World, number 1 Hello World, number 0 Hello World, number 1 Hello World, number 2 Hello World, number 3 Hello World, number 4 Hello World, number 5 In[121]:=?i i 6 In[122]:= For i 0.1, i 5, i, Print "Hello World, number ", i Hello World, number 0.1 Hello World, number 1.1 Hello World, number 2.1 Hello World, number 3.1 Hello World, number 4.1 In[123]:=?i i 5.1 In[124]:= For i,i 5, i, Print "Hello World, number ", i Hello World, number Hello World, number 1

20 20 259Lecture25sp17.nb In[125]:=?i i 2 In[126]:= For i 2, i 5, Print "Hello World, number ", i, i Hello World, number 1 Hello World, number 0 Hello World, number 1 Hello World, number 2 Hello World, number 3 Hello World, number 4 Hello World, number 5 Hello World, number 6 In[127]:=?i i 6 The Continue command can be used to bypass calculation for certain values of the counter in a For loop! In[128]:= For i 2, i 5, i, If i 3 i 5, Continue, Print "Hello World, number ", i Hello World, number 2 Hello World, number 1 Hello World, number 0 Hello World, number 1 Hello World, number 2 Hello World, number 4 In[129]:=?i i 6 In[130]:= Clear i While While[test, body] evaluates test, then body, repetitively, until test first fails to give True.

21 259Lecture25sp17.nb 21 While[test] does the loop with a null body. If Break[ ] is generated in the evaluation of body, the While loop exits. Continue[ ] exits the evaluation of body, and continues the loop. Unless an explicit Return is used, the value returned by While is Null. Example 14 Use While to simulate flipping a pair of coins and counting the number of heads in each toss. In[131]:= tosses 20; i 0; While i i 1 tosses, Print "Number of Heads in Toss ", i, " is ", RandomInteger 0, 2 Number of Heads in Toss 1 is 1 Number of Heads in Toss 2 is 1 Number of Heads in Toss 3 is 0 Number of Heads in Toss 4 is 1 Number of Heads in Toss 5 is 2 Number of Heads in Toss 6 is 2 Number of Heads in Toss 7 is 2 Number of Heads in Toss 8 is 2 Number of Heads in Toss 9 is 0 Number of Heads in Toss 10 is 0 Number of Heads in Toss 11 is 0 Number of Heads in Toss 12 is 2 Number of Heads in Toss 13 is 0 Number of Heads in Toss 14 is 0 Number of Heads in Toss 15 is 2 Number of Heads in Toss 16 is 1 Number of Heads in Toss 17 is 2 Number of Heads in Toss 18 is 0 Number of Heads in Toss 19 is 0 Number of Heads in Toss 20 is 1 In[134]:=?i

22 22 259Lecture25sp17.nb i 21 In[135]:= In[137]:= Example 15 Use While to randomly choose an integer from 0 to 10 until the number 2 is chosen. 0; While 2, RandomInteger 0, 10 ; Print Note that the loop can run for a very long time, as there is no preset bound on how many times the loop will execute. We can set an upper limit on the number of iterations of the For loop by including an And within the statement! 0; i 0; While 2&&i 20, RandomInteger 0, 10 ; Print ; i

23 259Lecture25sp17.nb In[140]:=?i i 17 Newton's Method Example In[141]:= Clear f, g, x In[142]:= f x_ : x 3 2x 5

24 24 259Lecture25sp17.nb In[143]:= Plot f x, x, 5, 5, PlotRange All Out[143]= In[144]:= g x_ : x f x f' x In[145]:= Out[145]= g x 5 2x x3 x 2 3x 2 In[146]:= Newton's Method "by hand"! Choose x = 0 as the initial guess for the root of g(x) = 0. Run ten iterations by putting the output back into g(x) to get the next guess! N g 0 Out[146]= 2.5 In[147]:= N g Out[147]= In[148]:= N g Out[148]= In[149]:= N g Out[149]= In[150]:= N g Out[150]= In[151]:= N g Out[151]= In[152]:= N g Out[152]= In[153]:= N g Out[153]=

25 259Lecture25sp17.nb 25 In[154]:= N g Out[154]= In[155]:= N g Out[155]= Version 1 In[156]:= x 0; Do x N g x, n, 1, 10 ; x Out[157]= Version 2 In[158]:= x 0; Do Print "n ", n, " x ", x ; x N g x, n, 0, 10 n 0 x 0 n 1 x 2.5 n 2 x n 3 x n 4 x n 5 x n 6 x n 7 x n 8 x n 9 x n 10 x Version 3 In[160]:= Clear x, y In[161]:= tolerence 0.001; In[162]:= For x 0; y 0; n 0, n 50, n, Print "n ", n, " x ", x, " and change from last guess is ", x y ; y x; x N g x ; If Abs x y tolerence, Print "n ", n 1, " x ", x, " change from last guess is ", x y ; Break

26 26 259Lecture25sp17.nb n 0 x 0 and change from last guess is 0 n 1 x 2.5 and change from last guess is 2.5 n 2 x and change from last guess is n 3 x and change from last guess is n 4 x and change from last guess is n 5 x and change from last guess is n 6 x and change from last guess is n 7 x and change from last guess is n 8 x and change from last guess is n 9 x and change from last guess is n 10 x and change from last guess is n 11 x and change from last guess is n 12 x and change from last guess is n 13 x and change from last guess is n 14 x and change from last guess is n 15 x and change from last guess is n 16 x and change from last guess is n 17 x and change from last guess is n 18 x change from last guess is Notice that within the command are a way to stop calculation after at most 50 steps (the "n<50") or stop if the tolerence is achieved (the Break[] within the If statement). Here's a version of the previous command that doesn't print out the intermediate steps! In[163]:= For x 0; n 0, n 50, n, y x; x N g x ; If Abs x y tolerence, Print "After ", n 1, " steps, x ", x, ", with absolute error ", Abs x y, "." ; Break ; After 18 steps, x , with absolute error Note: Portions of this lecture are based on the book Mathematica by S. Wolfram. The rest was created by M. A. Karls in Fall 2007 and revised in Fall 2008.

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill 12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring Chris Hill Mathematica Look in more detail at some of the programming features in Mathematica There are many of these features

More information

Ph3 Mathematica Homework: Week 1

Ph3 Mathematica Homework: Week 1 Ph3 Mathematica Homework: Week 1 Eric D. Black California Institute of Technology v1.1 1 Obtaining, installing, and starting Mathematica Exercise 1: If you don t already have Mathematica, download it and

More information

Ph3 Mathematica Homework: Week 6

Ph3 Mathematica Homework: Week 6 Ph3 Mathematica Homework: Week 6 Eric D. Black California Institute of Technology v1.1 Now that we ve covered techniques specific to data analysis, we will branch out into some more general topics. This

More information

Introduction to Excel Workshop

Introduction to Excel Workshop Introduction to Excel Workshop Empirical Reasoning Center June 6, 2016 1 Important Terminology 1. Rows are identified by numbers. 2. Columns are identified by letters. 3. Cells are identified by the row-column

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

ECE 202 LAB 3 ADVANCED MATLAB

ECE 202 LAB 3 ADVANCED MATLAB Version 1.2 1 of 13 BEFORE YOU BEGIN PREREQUISITE LABS ECE 201 Labs EXPECTED KNOWLEDGE ECE 202 LAB 3 ADVANCED MATLAB Understanding of the Laplace transform and transfer functions EQUIPMENT Intel PC with

More information

61A Lecture 2. Wednesday, September 4, 2013

61A Lecture 2. Wednesday, September 4, 2013 61A Lecture 2 Wednesday, September 4, 2013 Names, Assignment, and User-Defined Functions (Demo) Types of Expressions Primitive expressions: 2 add 'hello' Number or Numeral Name String Call expressions:

More information

Outline. Midterm Review. Using Excel. Midterm Review: Excel Basics. Using VBA. Sample Exam Question. Midterm Review April 4, 2014

Outline. Midterm Review. Using Excel. Midterm Review: Excel Basics. Using VBA. Sample Exam Question. Midterm Review April 4, 2014 Midterm Review Larry Caretto Mechanical Engineering 209 Computer Programming for Mechanical Engineers April 4, 2017 Outline Excel spreadsheet basics Use of VBA functions and subs Declaring/using variables

More information

Getting Started with Mathematica

Getting Started with Mathematica G563 Quantitative Paleontology Department of Geological Sciences P. David Polly Getting Started with Mathematica Mathematica has a unique interface that takes a while to get used to. You open to a blank

More information

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 18 Switch Statement (Contd.) And Introduction to

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

61A Lecture 2. Friday, August 28, 2015

61A Lecture 2. Friday, August 28, 2015 61A Lecture 2 Friday, August 28, 2015 Names, Assignment, and User-Defined Functions (Demo) Types of Expressions Primitive expressions: 2 add 'hello' Number or Numeral Name String Call expressions: max

More information

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017 Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The

More information

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Using Monte Carlo to Estimate π using Buffon s Needle Problem An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Here s the problem (in a simplified form). Suppose

More information

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Programming Basics and Practice GEDB029 Decision Making, Branching and Looping Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Decision Making and Branching C language possesses such decision-making capabilities

More information

Formulas and Functions

Formulas and Functions Conventions used in this document: Keyboard keys that must be pressed will be shown as Enter or Ctrl. Controls to be activated with the mouse will be shown as Start button > Settings > System > About.

More information

3 The L oop Control Structure

3 The L oop Control Structure 3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement

More information

Functions and Graphs. The METRIC Project, Imperial College. Imperial College of Science Technology and Medicine, 1996.

Functions and Graphs. The METRIC Project, Imperial College. Imperial College of Science Technology and Medicine, 1996. Functions and Graphs The METRIC Project, Imperial College. Imperial College of Science Technology and Medicine, 1996. Launch Mathematica. Type

More information

lab MS Excel 2010 active cell

lab MS Excel 2010 active cell MS Excel is an example of a spreadsheet, a branch of software meant for performing different kinds of calculations, numeric data analysis and presentation, statistical operations and forecasts. The main

More information

STEPHEN WOLFRAM MATHEMATICADO. Fourth Edition WOLFRAM MEDIA CAMBRIDGE UNIVERSITY PRESS

STEPHEN WOLFRAM MATHEMATICADO. Fourth Edition WOLFRAM MEDIA CAMBRIDGE UNIVERSITY PRESS STEPHEN WOLFRAM MATHEMATICADO OO Fourth Edition WOLFRAM MEDIA CAMBRIDGE UNIVERSITY PRESS Table of Contents XXI a section new for Version 3 a section new for Version 4 a section substantially modified for

More information

Chapter 1. Fundamentals of Higher Order Programming

Chapter 1. Fundamentals of Higher Order Programming Chapter 1 Fundamentals of Higher Order Programming 1 The Elements of Programming Any powerful language features: so does Scheme primitive data procedures combinations abstraction We will see that Scheme

More information

Activity: page 1/10 Introduction to Excel. Getting Started

Activity: page 1/10 Introduction to Excel. Getting Started Activity: page 1/10 Introduction to Excel Excel is a computer spreadsheet program. Spreadsheets are convenient to use for entering and analyzing data. Although Excel has many capabilities for analyzing

More information

Today s class. Roots of equation Finish up incremental search Open methods. Numerical Methods, Fall 2011 Lecture 5. Prof. Jinbo Bi CSE, UConn

Today s class. Roots of equation Finish up incremental search Open methods. Numerical Methods, Fall 2011 Lecture 5. Prof. Jinbo Bi CSE, UConn Today s class Roots of equation Finish up incremental search Open methods 1 False Position Method Although the interval [a,b] where the root becomes iteratively closer with the false position method, unlike

More information

Introduction to Excel Workshop

Introduction to Excel Workshop Introduction to Excel Workshop Empirical Reasoning Center September 9, 2016 1 Important Terminology 1. Rows are identified by numbers. 2. Columns are identified by letters. 3. Cells are identified by the

More information

Microsoft Office Excel Use Excel s functions. Tutorial 2 Working With Formulas and Functions

Microsoft Office Excel Use Excel s functions. Tutorial 2 Working With Formulas and Functions Microsoft Office Excel 2003 Tutorial 2 Working With Formulas and Functions 1 Use Excel s functions You can easily calculate the sum of a large number of cells by using a function. A function is a predefined,

More information

Section 2.4 Library of Functions; Piecewise-Defined Functions

Section 2.4 Library of Functions; Piecewise-Defined Functions Section. Library of Functions; Piecewise-Defined Functions Objective #: Building the Library of Basic Functions. Graph the following: Ex. f(x) = b; constant function Since there is no variable x in the

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs

More information

Fall 2018 Discussion 8: October 24, 2018 Solutions. 1 Introduction. 2 Primitives

Fall 2018 Discussion 8: October 24, 2018 Solutions. 1 Introduction. 2 Primitives CS 6A Scheme Fall 208 Discussion 8: October 24, 208 Solutions Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write

More information

Mathematical Experiments with Mathematica

Mathematical Experiments with Mathematica Mathematical Experiments with Mathematica Instructor: Valentina Kiritchenko Classes: F 12:00-1:20 pm E-mail : vkiritchenko@yahoo.ca, vkiritch@hse.ru Office hours : Th 5:00-6:20 pm, F 3:30-5:00 pm 1. Syllabus

More information

Excel Formulas & Functions I CS101

Excel Formulas & Functions I CS101 Excel Formulas & Functions I CS101 Topics Covered Use statistical functions Use cell references Use AutoFill Write formulas Use the RANK.EQ function Calculation in Excel Click the cell where you want to

More information

f( x ), or a solution to the equation f( x) 0. You are already familiar with ways of solving

f( x ), or a solution to the equation f( x) 0. You are already familiar with ways of solving The Bisection Method and Newton s Method. If f( x ) a function, then a number r for which f( r) 0 is called a zero or a root of the function f( x ), or a solution to the equation f( x) 0. You are already

More information

Mathematica Basics. Exponential Functions Exp[expression] Natural Logarithms (ln) Log[expression]

Mathematica Basics. Exponential Functions Exp[expression] Natural Logarithms (ln) Log[expression] Mathematica Basics To evaluate a Mathematica command, press [Shift]+[Enter]. Pay attention to spaces! Mathematica interprets some of them as multiplication. Syntax, capitalization and punctuation are meaningful.

More information

VBA Collections A Group of Similar Objects that Share Common Properties, Methods and

VBA Collections A Group of Similar Objects that Share Common Properties, Methods and VBA AND MACROS VBA is a major division of the stand-alone Visual Basic programming language. It is integrated into Microsoft Office applications. It is the macro language of Microsoft Office Suite. Previously

More information

Rockefeller College MPA Excel Workshop: Clinton Impeachment Data Example

Rockefeller College MPA Excel Workshop: Clinton Impeachment Data Example Rockefeller College MPA Excel Workshop: Clinton Impeachment Data Example This exercise is a follow-up to the MPA admissions example used in the Excel Workshop. This document contains detailed solutions

More information

3+2 3*2 3/2 3^2 3**2 In matlab, use ^ or ** for exponentiation. In fortran, use only ** not ^ VARIABLES LECTURE 1: ARITHMETIC AND FUNCTIONS

3+2 3*2 3/2 3^2 3**2 In matlab, use ^ or ** for exponentiation. In fortran, use only ** not ^ VARIABLES LECTURE 1: ARITHMETIC AND FUNCTIONS LECTURE 1: ARITHMETIC AND FUNCTIONS MATH 190 WEBSITE: www.math.hawaii.edu/ gautier/190.html PREREQUISITE: You must have taken or be taking Calculus I concurrently. If not taken here, specify the college

More information

How to Design Programs Languages

How to Design Programs Languages How to Design Programs Languages Version 4.1 August 12, 2008 The languages documented in this manual are provided by DrScheme to be used with the How to Design Programs book. 1 Contents 1 Beginning Student

More information

A Brief Introduction to Scheme (I)

A Brief Introduction to Scheme (I) A Brief Introduction to Scheme (I) Philip W. L. Fong pwlfong@cs.uregina.ca Department of Computer Science University of Regina Regina, Saskatchewan, Canada Scheme Scheme I p.1/44 Scheme: Feature Set A

More information

ü 1.1 Getting Started

ü 1.1 Getting Started Chapter 1 Introduction Welcome to Mathematica! This tutorial manual is intended as a supplement to Rogawski's Calculus textbook and aimed at students looking to quickly learn Mathematica through examples.

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Graphing Calculator Tutorial

Graphing Calculator Tutorial Graphing Calculator Tutorial This tutorial is designed as an interactive activity. The best way to learn the calculator functions will be to work the examples on your own calculator as you read the tutorial.

More information

B&E 105: TECHNOLOGY FOR BUSINESS SOLUTIONS EXAM 5 CHECKLIST & OUTLINE

B&E 105: TECHNOLOGY FOR BUSINESS SOLUTIONS EXAM 5 CHECKLIST & OUTLINE B&E 105: TECHNOLOGY FOR BUSINESS SOLUTIONS EXAM 5 CHECKLIST & OUTLINE Strategy for doing well: Work along with the videos, filling out your Excel file(s) step by step. Do this until you can comfortably

More information

Random Simulation Simulation Modeling

Random Simulation Simulation Modeling Random Simulation 5.1 86 Simulation Modeling Goal: Use probabilistic methods to analyze deterministic and probabilistic models. Example. Determine the best elevator delivery scheme. The wait is too long,

More information

Math 1113 Notes - Functions Revisited

Math 1113 Notes - Functions Revisited Math 1113 Notes - Functions Revisited Philippe B. Laval Kennesaw State University February 14, 2005 Abstract This handout contains more material on functions. It continues the material which was presented

More information

MAT121: SECTION 2.7 ANALYZING GRAPHS AND PIECEWISE FUNCTIONS

MAT121: SECTION 2.7 ANALYZING GRAPHS AND PIECEWISE FUNCTIONS MAT121: SECTION 2.7 ANALYZING GRAPHS AND PIECEWISE FUNCTIONS SYMMETRY, EVEN, ODD A graph can be symmetric about the x-axis, y-axis, or the origin (y = x). If a mirror is placed on those lines, the graph

More information

Fall Semester (081) Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals

Fall Semester (081) Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals INTERNET PROTOCOLS AND CLIENT-SERVER PROGRAMMING Client SWE344 request Internet response Fall Semester 2008-2009 (081) Server Module 2.1: C# Programming Essentials (Part 1) Dr. El-Sayed El-Alfy Computer

More information

ME 461 C review Session Fall 2009 S. Keres

ME 461 C review Session Fall 2009 S. Keres ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help

More information

CSE 20 DISCRETE MATH. Fall

CSE 20 DISCRETE MATH. Fall CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Final exam The final exam is Saturday December 16 11:30am-2:30pm. Lecture A will take the exam in Lecture B will take the exam

More information

Decision Making in C

Decision Making in C Decision Making in C Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed

More information

Depth First Search. Johan G. F. Belinfante 2007 October 24. summary. a needed definition. dfs algorithm

Depth First Search. Johan G. F. Belinfante 2007 October 24. summary. a needed definition. dfs algorithm Depth First Search Johan G. F. Belinfante 2007 October 24 summary Given an unordered (simple) graph, and a designated vertex, one can obtain a list of the vertices, without repetitions, in the connected

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

LECTURE 5 Control Structures Part 2

LECTURE 5 Control Structures Part 2 LECTURE 5 Control Structures Part 2 REPETITION STATEMENTS Repetition statements are called loops, and are used to repeat the same code multiple times in succession. The number of repetitions is based on

More information

Math Analysis Chapter 1 Notes: Functions and Graphs

Math Analysis Chapter 1 Notes: Functions and Graphs Math Analysis Chapter 1 Notes: Functions and Graphs Day 6: Section 1-1 Graphs Points and Ordered Pairs The Rectangular Coordinate System (aka: The Cartesian coordinate system) Practice: Label each on the

More information

Chapter 1 Histograms, Scatterplots, and Graphs of Functions

Chapter 1 Histograms, Scatterplots, and Graphs of Functions Chapter 1 Histograms, Scatterplots, and Graphs of Functions 1.1 Using Lists for Data Entry To enter data into the calculator you use the statistics menu. You can store data into lists labeled L1 through

More information

Dept. of CSE, IIT KGP

Dept. of CSE, IIT KGP Control Flow: Looping CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of Repeated Execution Loop: Group of

More information

Introduction to Computer Architecture

Introduction to Computer Architecture Boolean Operators The Boolean operators AND and OR are binary infix operators (that is, they take two arguments, and the operator appears between them.) A AND B D OR E We will form Boolean Functions of

More information

Lecture 3: Loops. While Loops. While Loops: Powers of Two. While Loops: Newton-Raphson Method

Lecture 3: Loops. While Loops. While Loops: Powers of Two. While Loops: Newton-Raphson Method While Loops Lecture : Loops The while loop is a common repetition structure. Check loop-continuation condition. Execute a sequence of statements. Repeat. while (boolean expression) statement; while loop

More information

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char Review Primitive Data Types & Variables int, long float, double boolean char String Mathematical operators: + - * / % Comparison: < > = == 1 1.3 Conditionals and Loops Introduction to Programming in

More information

Automating the Tedious Stuff (Functional programming and other Mathematica magic)

Automating the Tedious Stuff (Functional programming and other Mathematica magic) /22 Automating the Tedious Stuff (Functional programming and other Mathematica magic) Connor Glosser Michigan State University Departments of Physics & Electrical/Computer Engineering π, 2014 /22 Table

More information

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017 SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

Lecture 19. Software Pipelining. I. Example of DoAll Loops. I. Introduction. II. Problem Formulation. III. Algorithm.

Lecture 19. Software Pipelining. I. Example of DoAll Loops. I. Introduction. II. Problem Formulation. III. Algorithm. Lecture 19 Software Pipelining I. Introduction II. Problem Formulation III. Algorithm I. Example of DoAll Loops Machine: Per clock: 1 read, 1 write, 1 (2-stage) arithmetic op, with hardware loop op and

More information

Introduction to Microsoft Excel

Introduction to Microsoft Excel Chapter A spreadsheet is a computer program that turns the computer into a very powerful calculator. Headings and comments can be entered along with detailed formulas. The spreadsheet screen is divided

More information

7 Control Structures, Logical Statements

7 Control Structures, Logical Statements 7 Control Structures, Logical Statements 7.1 Logical Statements 1. Logical (true or false) statements comparing scalars or matrices can be evaluated in MATLAB. Two matrices of the same size may be compared,

More information

Reals 1. Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method.

Reals 1. Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method. Reals 1 13 Reals Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method. 13.1 Floating-point numbers Real numbers, those declared to be

More information

Chapter 2: Functions and Control Structures

Chapter 2: Functions and Control Structures Chapter 2: Functions and Control Structures TRUE/FALSE 1. A function definition contains the lines of code that make up a function. T PTS: 1 REF: 75 2. Functions are placed within parentheses that follow

More information

Math Analysis Chapter 1 Notes: Functions and Graphs

Math Analysis Chapter 1 Notes: Functions and Graphs Math Analysis Chapter 1 Notes: Functions and Graphs Day 6: Section 1-1 Graphs; Section 1- Basics of Functions and Their Graphs Points and Ordered Pairs The Rectangular Coordinate System (aka: The Cartesian

More information

Unit 1: Sections Skill Set

Unit 1: Sections Skill Set MthSc 106 Fall 2011 Calculus of One Variable I : Calculus by Briggs and Cochran Section 1.1: Review of Functions Unit 1: Sections 1.1 3.3 Skill Set Find the domain and range of a function. 14, 17 13, 15,

More information

Section 1.6 & 1.7 Parent Functions and Transformations

Section 1.6 & 1.7 Parent Functions and Transformations Math 150 c Lynch 1 of 8 Section 1.6 & 1.7 Parent Functions and Transformations Piecewise Functions Example 1. Graph the following piecewise functions. 2x + 3 if x < 0 (a) f(x) = x if x 0 1 2 (b) f(x) =

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs in MATLAB NOTE: For your

More information

Fathom Dynamic Data TM Version 2 Specifications

Fathom Dynamic Data TM Version 2 Specifications Data Sources Fathom Dynamic Data TM Version 2 Specifications Use data from one of the many sample documents that come with Fathom. Enter your own data by typing into a case table. Paste data from other

More information

YOGYAKARTA STATE UNIVERSITY MATHEMATICS AND NATURAL SCIENCES FACULTY MATHEMATICS EDUCATION STUDY PROGRAM

YOGYAKARTA STATE UNIVERSITY MATHEMATICS AND NATURAL SCIENCES FACULTY MATHEMATICS EDUCATION STUDY PROGRAM YOGYAKARTA STATE UNIVERSITY MATHEMATICS AND NATURAL SCIENCES FACULTY MATHEMATICS EDUCATION STUDY PROGRAM TOPIC 1 INTRODUCING SOME MATHEMATICS SOFTWARE (Matlab, Maple and Mathematica) This topic provides

More information

An introduction to Scheme

An introduction to Scheme An introduction to Scheme Introduction A powerful programming language is more than just a means for instructing a computer to perform tasks. The language also serves as a framework within which we organize

More information

PA Payroll Exercise for Intermediate Excel

PA Payroll Exercise for Intermediate Excel PA Payroll Exercise for Intermediate Excel Follow the directions below to create a payroll exercise. Read through each individual direction before performing it, like you are following recipe instructions.

More information

REPETITION CONTROL STRUCTURE LOGO

REPETITION CONTROL STRUCTURE LOGO CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of

More information

Macro Programming Reference Guide. Copyright 2005 Scott Martinez

Macro Programming Reference Guide. Copyright 2005 Scott Martinez Macro Programming Reference Guide Copyright 2005 Scott Martinez Section 1. Section 2. Section 3. Section 4. Section 5. Section 6. Section 7. What is macro programming What are Variables What are Expressions

More information

1. Practice the use of the C ++ repetition constructs of for, while, and do-while. 2. Use computer-generated random numbers.

1. Practice the use of the C ++ repetition constructs of for, while, and do-while. 2. Use computer-generated random numbers. 1 Purpose This lab illustrates the use of looping structures by introducing a class of programming problems called numerical algorithms. 1. Practice the use of the C ++ repetition constructs of for, while,

More information

CSc 372. Comparative Programming Languages. 36 : Scheme Conditional Expressions. Department of Computer Science University of Arizona

CSc 372. Comparative Programming Languages. 36 : Scheme Conditional Expressions. Department of Computer Science University of Arizona 1/26 CSc 372 Comparative Programming Languages 36 : Scheme Conditional Expressions Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg 2/26 Comparison

More information

GCSE CCEA GCSE EXCEL 2010 USER GUIDE. Business and Communication Systems

GCSE CCEA GCSE EXCEL 2010 USER GUIDE. Business and Communication Systems GCSE CCEA GCSE EXCEL 2010 USER GUIDE Business and Communication Systems For first teaching from September 2017 Contents Page Define the purpose and uses of a spreadsheet... 3 Define a column, row, and

More information

Let s start by examining an Excel worksheet for the linear programming. Maximize P 70x 120y. subject to

Let s start by examining an Excel worksheet for the linear programming. Maximize P 70x 120y. subject to Excel is a useful tool for solving linear programming problems. In this question we ll solve and analyze our manufacturing problem with Excel. Although this problem can easily be solved graphically or

More information

There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:

There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals: Numeric Types There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals: 1-123 +456 2. Long integers, of unlimited

More information

Lecture 3: Loops. While Loops. While Loops: Newton-Raphson Method. While Loops: Powers of Two

Lecture 3: Loops. While Loops. While Loops: Newton-Raphson Method. While Loops: Powers of Two While Loops Lecture 3: Loops The while loop is a common repetition structure. Check loop-continuation condition. Execute a sequence of statements. Repeat. while (boolean expression) statement; while loop

More information

Project 1. due date Sunday July 8, 2018, 12:00 noon

Project 1. due date Sunday July 8, 2018, 12:00 noon Queens College, CUNY, Department of Computer Science Object-oriented programming in C++ CSCI 211 / 611 Summer 2018 Instructor: Dr. Sateesh Mane c Sateesh R. Mane 2018 Project 1 due date Sunday July 8,

More information

Scheme Quick Reference

Scheme Quick Reference Scheme Quick Reference COSC 18 Fall 2003 This document is a quick reference guide to common features of the Scheme language. It is not intended to be a complete language reference, but it gives terse summaries

More information

MathML Editor: The Basics *

MathML Editor: The Basics * OpenStax-CNX module: m26312 1 MathML Editor: The Basics * Natalie Weber This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract This module provides

More information

Lecture-14 Lookup Functions

Lecture-14 Lookup Functions Lecture-14 Lookup Functions How do I write a formula to compute tax rates based on income? Given a product ID, how can I look up the product s price? Suppose that a product s price changes over time. I

More information

Pre-Lab Excel Problem

Pre-Lab Excel Problem Pre-Lab Excel Problem Read and follow the instructions carefully! Below you are given a problem which you are to solve using Excel. If you have not used the Excel spreadsheet a limited tutorial is given

More information

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we should Use better data structures

More information

Sardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES ( ) (ODD) Code Optimization

Sardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES ( ) (ODD) Code Optimization Sardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES (2018-19) (ODD) Code Optimization Prof. Jonita Roman Date: 30/06/2018 Time: 9:45 to 10:45 Venue: MCA

More information

Put the Graphs for Each Health Plan on the Same Graph

Put the Graphs for Each Health Plan on the Same Graph At the conclusion of the technology assignment on graphing the total annual cost, you had a graph of each of health insurance plans you are examining. In this technology assignment, you ll combine those

More information

DM536 / DM550 Part 1 Introduction to Programming. Peter Schneider-Kamp.

DM536 / DM550 Part 1 Introduction to Programming. Peter Schneider-Kamp. DM536 / DM550 Part 1 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk! http://imada.sdu.dk/~petersk/dm536/! RECURSION 2 Recursion a function can call other functions a function can

More information

1.3 Conditionals and Loops

1.3 Conditionals and Loops A Foundation for Programming 1.3 Conditionals and Loops any program you might want to write objects functions and modules graphics, sound, and image I/O arrays conditionals and loops Math primitive data

More information

If statements and For loops

If statements and For loops Advanced Random Simulation 5.1 89 If statements and For loops In order to incorporate more complex aspects into the model, use If statements and For loops. If[condition,t,f] Advanced Random Simulation

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Introduction to the workbook and spreadsheet

Introduction to the workbook and spreadsheet Excel Tutorial To make the most of this tutorial I suggest you follow through it while sitting in front of a computer with Microsoft Excel running. This will allow you to try things out as you follow along.

More information

CS 61A Interpreters, Tail Calls, Macros, Streams, Iterators. Spring 2019 Guerrilla Section 5: April 20, Interpreters.

CS 61A Interpreters, Tail Calls, Macros, Streams, Iterators. Spring 2019 Guerrilla Section 5: April 20, Interpreters. CS 61A Spring 2019 Guerrilla Section 5: April 20, 2019 1 Interpreters 1.1 Determine the number of calls to scheme eval and the number of calls to scheme apply for the following expressions. > (+ 1 2) 3

More information

Computers in Engineering COMP 208 Repetition and Storage Michael A. Hawker. Repetition. A Table of Values 9/20/2007

Computers in Engineering COMP 208 Repetition and Storage Michael A. Hawker. Repetition. A Table of Values 9/20/2007 Computers in Engineering COMP 208 Repetition and Storage Michael A. Hawker Repetition To fully take advantage of the speed of a computer, we must be able to instruct it to do a lot of work The program

More information

8. Control statements

8. Control statements 8. Control statements A simple C++ statement is each of the individual instructions of a program, like the variable declarations and expressions seen in previous sections. They always end with a semicolon

More information

The Fortran Basics. Handout Two February 10, 2006

The Fortran Basics. Handout Two February 10, 2006 The Fortran Basics Handout Two February 10, 2006 A Fortran program consists of a sequential list of Fortran statements and constructs. A statement can be seen a continuous line of code, like b=a*a*a or

More information

1 THE PNP BASIC COMPUTER ESSENTIALS e-learning (MS Excel 2007)

1 THE PNP BASIC COMPUTER ESSENTIALS e-learning (MS Excel 2007) 1 THE PNP BASIC COMPUTER ESSENTIALS e-learning (MS Excel 2007) 2 THE PNP BASIC COMPUTER ESSENTIALS e-learning (MS Excel 2007) TABLE OF CONTENTS CHAPTER 1: GETTING STARTED... 5 THE EXCEL ENVIRONMENT...

More information

Chapter 2 Scatter Plots and Introduction to Graphing

Chapter 2 Scatter Plots and Introduction to Graphing Chapter 2 Scatter Plots and Introduction to Graphing 2.1 Scatter Plots Relationships between two variables can be visualized by graphing data as a scatter plot. Think of the two list as ordered pairs.

More information

Pre-Calculus Mr. Davis

Pre-Calculus Mr. Davis Pre-Calculus 2016-2017 Mr. Davis How to use a Graphing Calculator Applications: 1. Graphing functions 2. Analyzing a function 3. Finding zeroes (or roots) 4. Regression analysis programs 5. Storing values

More information