8 Pages

lab2a

Course: CS 034, Fall 2009
School: Sanford-Brown Institute
Rating:
 
 
 
 
 

Word Count: 2735

Document Preview

to CS034 Intro Systems Programming Doeppner & Van Hentenryck Lab 2.1 Out: 9 February 2005 What youll learn. In the rst part of this lab, you will practice using bitwise operators. In the second part, you will open an image and read formatted data from it. The le format you will be reading is an image format called PPM (Portable PixMap). You can view any .ppm le by typing: xv <filename>...

Register Now

Unformatted Document Excerpt

Coursehero >> Georgia >> Sanford-Brown Institute >> CS 034

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
to CS034 Intro Systems Programming Doeppner & Van Hentenryck Lab 2.1 Out: 9 February 2005 What youll learn. In the rst part of this lab, you will practice using bitwise operators. In the second part, you will open an image and read formatted data from it. The le format you will be reading is an image format called PPM (Portable PixMap). You can view any .ppm le by typing: xv <filename> How youll do it. First, youll be reusing your code from Lab 1 in order to get input from the user. Remember that a string in C is really just an array of chars. Youll be printing out the chars in binary form, using bitwise operators. In the second part of the lab, you will treat the string of user input as a lename. You will use the fopen() function, giving it the user input as the lename. Once you have opened the le, you will read in the data from the le and output it as a binary representation. Task 1: Print out a binary representation of user input Data Types We need to understand exactly how C stores values in memory so that we will know what a string actually looks like in binary. In C, there are several basic data types for representing values. char is probably the simplest of all the data types. The length of a char is one byte, which is equivalent to eight bits of information. Because it has eight bits, a char can take on any of 256 possible values. There is a standardized mapping (called ASCII) of each of these values to one particular letter or symbol. Just as an int can be either signed or unsigned, so can a char. The most common ASCII symbols fall in the range of 0 to 127, however, there are other symbols in the 128 to 255 range which can be represented only by unsigned chars. Here are a few useful ASCII conversions. These binary representations are each 8 bits long with the least signicant bit on the right: CS034 value 0 10 32 48 65 97 binary 00000000 00001010 00100000 00110000 01000001 01100001 character \0 \n 0 A a Lab 2.1 9 February 2005 meaning null character represents the end of a string) newline space zero (the digits range from 48 to 57) Capital A (capital letters range from 65-90) lowercase a (lowercase letters range from 97-122) Here is a simple string translated into binary: Hello world. 01001000 01100101 01101100 01101100 01101111 00100000 01110111 01101111 01110010 01101100 01100100 00101110 00000000 Bitwise Operators Now that we know what a string should look like in binary, we need to know how to extract each binary bit one at a time. To accomplish this, we will use bitwise operators. Bitwise operators get their name because they apply to each bit of the data individually. When you use ordinary operators, such as the binary operators +, -, *, /, and %, it is possible to mix and match dierent data types in a single expression. For example, it is possible to multiply an int by a float and then place the result in an int (this is really done by rst converting the int to a float, multiplying the two floats, and then truncating the result back to an int). However, when you use bitwise operators, these semantics are thrown out the window. You have direct control over the bits of data. Furthermore, data types are sometimes represented dierently depending on which architecture or compiler you are using, so you have to be very careful when using bitwise operators. Here are some of the commonly used bitwise operators performed on four bit numbers (remember that a char is actually eight bits): A = 5 = 0101, operator << >> & | ^ ~ B = 1 = 0001, n = 1 example A << n A >> n A&B A|B A^B ~B result 1010 = 0010 = 0001 = 0101 = 0100 = 1110 = meaning left shift right shift AND OR XOR complement 10 2 1 5 4 14 Left Shift (A << n): The result is equal to A shifted n bits to the left. This is equal to A 2n Right Shift (A >> n): The result is equal to A shifted n bits to the right. This is equal to A/2n AND/OR/XOR (A & B, A | B, A ^ B): Each resulting bit is determined by the logical AND/OR/XOR of the corresponding bit in the left and right operands. 2 CS034 Lab 2.1 9 February 2005 Complement ( A): This is a unary operator. Each resulting bit is the opposite of the corresponding bit in the operand. Each of these operators (except complement) can also be used in a compound assignment statement, similar to the += operator. For instance: A &= B is equivalent to A = A & B A |= B is equivalent to A = A | B A <<= B is equivalent to A = A << B Here are some useful techniques to use in conjunction with bitwise operators. Note that for an unsigned char, n should range from zero to seven: Creating a mask: A mask is a dummy value with a particular bit or combination of bits set explicitly to one. We will see later how this can be used. Heres how to create a mask with only the nth bit set to one: mask = 1 << n Setting a bit to one: We can explicitly set a bit to 1 without changing the value of the other bits. Note that if the bit happened to have been set already, this operation has no eect. mask = 1 << n value |= mask Clearing a bit to zero: We can explicitly clear a bit to zero without changing the value of the other bits. If the bit happened to have already been zero, this operation would have no eect. mask = 1 << n value &= ~mask Testing a bit: We can also use bitwise operations in conjunction with conditional statements. Heres how to set up a conditional statement that only succeeds if the nth bit is set to 1. mask = 1 << n if(value & mask) ... Task: Create a le called print bits.c. As you did in Lab1, read in a maximum of 100 characters of input from the user. Make sure that you remove any trailing newline character, and that the string is terminated with a null character (\0). Now, for each char in the string, print out the component bits of the char. Make sure that you print the most signicant bit rst for each character. Adding a space between each set of eight bits will make your output more readable. 3 CS034 Lab 2.1 9 February 2005 Task 2: Open a PPM le, read the data, and print it out in binary. File Operations Before we can use a le in any way, we must rst open the le. The C language provides some standard functions for dealing with les, using the FILE struct. There are other methods for dealing with les including le descriptors in UNIX, and le streams in C++, but the FILE semantics are very easy to use, and are guaranteed to work with any architecture for which you happen to be compiling. Opening the le gives you a pointer to a FILE struct, which you can later use to read or write to the open le. Make sure to always close your open les before exiting the program. What follows is a very brief introduction to the most common le operations. For more information, see the manpages. FILE *fopen(const char *path, const char *mode); Attempts to open the le at the specied path with the permissions specied by mode. Upon success, a pointer to a FILE struct is returned, otherwise, the function returns NULL1 . There are several options for mode. The most useful ones are r (read only) and r+ (read and write). int fclose(FILE *stream); Closes the le that was previously opened using fopen(). You should call this function once for each le you open before exiting your program. int fseek(FILE *stream, long offset, int whence); Sets the oset into the le at which subsequent writes/reads will happen. See man fseek for info on parameters. Formatted Files In its simplest form, a le can be thought of as an array of chars. To make this more useful, a le often is formatted so that discrete values can be extracted from it. You have already seen the printf() function. printf() is for formatting output so that it is presented to the user in an organized fashion. printf() has a cousin called fprintf() which operates on les rather than terminal output. 2 If fopen() returns NULL, you can print a nice error message using the perror() function. See man perror for more info. 2 In fact, you can also use fprintf() to write to the terminal by using a special global FILE * called stdout. This is what printf() does under-the-hood. 1 4 CS034 Lab 2.1 9 February 2005 int fprintf(FILE *stream, const char *format, ...); fprintf() takes as parameters a le, a format string, and then some number of values determined by the format string. The values are inserted into the format string. The return value is the number of bytes actually written to the le. The le position is also automatically advanced by this amount. [f]printf() also has a relative that is able to read in from a le based on a specied format string: int fscanf(FILE *stream, const char *format, ...); fscanf() uses the same style of formatting string as the printf() family of functions. To fully understand how it works, youll need to read the man page, but here is one example to get you started: #include <stdio.h> int main() { FILE* file = fopen("filename", "r"); int grade; char gradeLetter; char name[11]; fscanf(file, "%10s %d %c", name, &grade, &gradeLetter); printf("name = %s\ngrade = %d (%c)\n", name, grade, gradeLetter); return 0; } The code fragment above rst opens the le called lename. Then, it tries to read values from the le in the following order: an arbitrary amount of whitespace (implicit at the beginning of any scanf format string), a string having up to 10 characters, more whitespace, an int, more whitespace, and a character. For example, if the le contains the following string: wgates 34 F The program will output: name = wgates grade = 34 (F) 5 CS034 Lab 2.1 9 February 2005 PPM File Format There are literally hundreds of image le formats out there, but weve chosen to work with PPM because its one of the easiest to parse. Heres an example of a valid PPM le: P3 22 255 200 2 1 199 0 56 81 0 174 16 0 239 The rst two characters of the le must be P3. These two characters serve no purpose other to ensure that we are actually looking at a color PPM le. The next two elds are integers. The rst species the width of the image, and the second species the height. The next eld is an integer representing the maximum value. In this case, the maximum is 255. Zero is black and white is the maximum value. All the values in between are shades with varying intensity. Following that is some number of triplets, each representing one pixel. The number of triplets should be width height. The pixels are in row-major order. That is, all the pixels in the top row come rst, from left to right, then the pixels in the second row, and so on. Each triplet consists of three integers. The rst integer is the red channel, the second is the green channel, and the third is the blue. All the color values must fall in the range of [0, max] inclusive, so [0, 255] in this case. Note that the le above has newlines inserted for clarity. In an actual le, newlines are entirely optional, and are treated as whitespace. Lucky for us, fscanf() treats a in the formatting string as an undetermined amount of arbitrary whitespace (including newlines), and will automatically skip any whitespace at the beginning of lines. There are several PPM les for your enjoyment in /course/cs034/images/. To view a PPM le: xv <filename> Structs A struct is a simple construct in C for collecting several basic data types into one concise unit, similar to a Java class without any methods. Often, we dene structs to group related data together. structs not only make for cleaner and more organized code, but they allow us to pass these bundles of data around using only a single pointer instead of the many pointers that would be required to pass each piece of data separately. We often 6 CS034 Lab 2.1 9 February 2005 put struct denitions within a header le so that many C programs can make use of the same kind of struct simply by including the corresponding header le. Heres an example of how to dene a new type, called color t as a struct that would be useful for keeping track of a single pixel in an image: typedef struct color { unsigned char r; unsigned char g; unsigned...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab2b.dvi %Pages: 6 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMTT10 CMSY10 CMTI10 %EndComments %DVIPSWebPage: (www.radi
Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab3a.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMTT10 CMTI10 %EndComments %DVIPSWebPage: (www.radicaleye.
Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab3b.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMR8 CMTT10 CMR6 CMR9 %EndComments %DVIPSWebPage: (www.rad
Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab4.2.dvi %Pages: 5 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMTT10 CMMI10 CMR8 CMR6 CMR9 %EndComments %DVIPSWebPage:
Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab5-1.dvi %Pages: 5 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMTT10 CMTT12 CMR8 CMR6 CMR9 %EndComments %DVIPSWebPage:
SUNY Stony Brook - MAT - 125
MAT125.R92: QUIZ 6SOLUTIONSName: Using linear approximation, estimate3 8.1. (Hint: 3 8.1 = f (8.1), where f (x) = 3 x.) f (x) f (a) + f (a)(x a) for a close to x. Specically, f (8.1) = f (8) + f (8)(8.1 8) (we choose a = 8 because its close t
Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab5-2.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMTT10 %EndComments %DVIPSWebPage: (www.radicaleye.com) %
Sanford-Brown Institute - CS - 034
CS034Intro to Systems ProgrammingDoeppner &amp; Van HentenryckLab 5.2Out: Thursday, March 3rd, 2005 What youll learn.In this lab, you will learn how to subclass in C+ and how to override methods.How youll do it.You will subclass from your Imag
SUNY Stony Brook - MAT - 125
MAT125.R92: QUIZ 2SOLUTIONS2x + 5 . Find the inverse function of f (x). x3 2x + 5 The function f (x) is given by the equation y = . We need to solve x3 for x: 2x + 5 y= x3 (x 3)y = 2x + 5 xy 3y = 2x + 5 xy 2x = 5 + 3y (y 2)x = 3y + 5 3y + 5 x=
Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab6.dvi %Pages: 6 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMTT10 CMTT12 CMSY10 %EndComments %DVIPSWebPage: (www.radic
Sanford-Brown Institute - CS - 034
CS034Intro to Systems ProgrammingDoeppner &amp; Van HentenryckLab 6Out: Wednesday 9 March 2005 What youll learn.Modern C+ comes with a powerful template library, the Standard Template Library, or STL. The STL is based on the independent concepts
SUNY Stony Brook - MAT - 125
MAT125.R91: QUIZ 5SOLUTIONS3x + 1 . Evaluate the following limits: x3 3x + 1 (a) lim f (x) = lim . x3+ x3+ x 3 When x approaches 3 from the right, 3x + 1 is close to 3(3) + 1 = 10 and x 3 is a small positive number. 3x + 1 is 10 divided by a sma
Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab7a.dvi %Pages: 4 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMTT10 CMTT12 CMMI10 CMSY10 %EndComments %DVIPSWebPage: (w
SUNY Stony Brook - MAT - 125
MAT 125: MIDTERM I PRACTICESOLUTIONSChapter 1 2. (a) g(2) = 3 (b) passes horizontal line test (c) g1 0.2 (d) (1, 3.5), same as range of g(x) (e)15. domain: 4 3x2 0 4 3x2 4 or x2 3 22 , 33 range: from 0 to 4 3 0 2; [0, 2] 6. domain:
SUNY Stony Brook - MAT - 125
MAT125.R91: QUIZ 2SOLUTIONS Let f (x) = 2 x2 + 5, x 0. Find the inverse function of f (x). The function f (x) is given by the equation y = 2 x2 + 5. We need to solve for x: y = 2 x2 + 5 y 2 = x +5 2 y2 = x2 + 5 2 y2 5 = x2 2 y2 5 x= 2 y2 Hence
SUNY Stony Brook - MAT - 125
MAT125.R91: QUIZ 9SOLUTIONSFind the absolute maximum and absolute minimum values of f (x) = x4 2x2 + 3 on the interval [1, 1]. f (x) = (x4 2x2 + 3) = 4x3 4x Critical points: The derivative exists everywhere, so we only need to check where it is
SUNY Stony Brook - MAT - 125
MAT125.R92: QUIZ 0SOLUTIONSNo score will be assigned for this quiz. The graph of the function f (x) is given below:11(a) Determine the domain and range of f (x). Domain: 4 &lt; x &lt; 1 and 1 &lt; x &lt; 4 (or, in other notations, (4, 1) and (1, 4). We
Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab7b.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMSY10 CMMI12 CMTT10 %EndComments %DVIPSWebPage: (www.radi
Sanford-Brown Institute - CS - 034
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: lab8b.dvi %Pages: 5 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMBX10 CMR10 CMBX12 CMTI12 CMTT10 CMSY10 CMMI10 CMTI10 %EndComments %DVIPSWebPage: (w
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
Team Number: Week: Program Size (SLOC) Base Added Deleted Modified Reused # of COTS Total New SLOC Effort (Hours) Project Mgmt. Requirements COTS Assessment Design Life Cycle Planning Configuration Mgmt. Feasibility Analysis Code COTS Tailoring COTS
USC - CSCI - 577
ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15Task Name Inception First Team Interaction Members' time preferences Assigning Roles Project Detail discussion Client meeting preperation First Client Meeting Team &amp; Client Introduction Project Overview Collabo
USC - CSCI - 577
ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27Task Name Inception First Team Interaction Members' time preferences Assigning Roles Project Detail discussion Client meeting preperation First Client Meeting Team &amp; Client I
USC - CSCI - 577
ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32Task Name Inception First Team Interaction Members' time preferences Assigning Roles Project Detail discussion Client meeting preperation First Client Meeting
USC - CSCI - 577
ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32Task Name Inception First Team Interaction Members' time preferences Assigning Roles Project Detail discussion Client meeting preperation First Client Meeting
USC - CSCI - 577
ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32Task Name Inception First Team Interaction Members' time preferences Assigning Roles Project Detail discussion Client meeting preperation First Client Meeting
SUNY Stony Brook - MAT - 127
Answers to the MAT127 Homework No.12 Chapter 7 Section 4 Problem 2-4,7,10 &amp; Section 5 Problem 2,5,7,8,11,13,14,15 Section 7.4 2.(a) Let P (t) be the population of bacteria w.r.t. time t in the unit of hour, and let k be the relative growth rate in th
SUNY Stony Brook - MAT - 127
1 Show thatf (x) =n=0(1)n x2n (2n)!is a solution of f + f = 0. Solution. Writef (x) =n=0 2n(1)n x2n1 (2n)!f (x) =n=02n(2n 1)(1)n x2n2 = (2n)!n=02n(2n 1)(1)n x2(n1) (2n)!Notice that we can begin the above sum by n = 1 since
UCSC - CHEM - 112
Chemistry 112B: Organic Chemistry Winter 2008 Professor Rebecca Braslau Assigned Homework Problems The following problems are required, and must be turned in. Problems are to b e done without looking at the answers as much as possible, then corrected
SUNY Stony Brook - MAT - 126
Quiz 4 - Solutionsdx Question 1. The integral 0 2x1 is improper because 2x1 1 is not dened at 1 . 2 1 Question 2. Notice that e2x + 3 &gt; e2x , so e2x1+3 &lt; e2x . We then obtain: 0 1ex dx &lt; e2x + 3 0ex dx = e2x 0ex dxThis last integral is
SUNY Stony Brook - MAT - 126
Quiz 3 - Solutions Question 1. We want to compute x2 dx+a2 using the substitution x2 x = a tan , &lt; &lt; ; a is some positive real number. 2 2 From x = a tan we get dx = a sec2 d and x2 + a2 = a2 + a2 tan2 = a 1 + tan2 . Recalling that 1 + tan2
SUNY Stony Brook - MAT - 125
1 Problem 37 section 4.1. We have the situation shown in the gure, where v is the velocity, (xb , yb ) are the coordinates of the runner, xa is the x-coordinate of the runners friend (we do not show the y -coordinate of the runners friend since it is
SUNY Stony Brook - MAT - 211
MAT211 - Introduction to Linear Algebra SUMMER 07 Practice Final Question 1. Find 1 0 A= 0 the rank of the 23 1 B = 1 22 01 1 matrices: 11 147 1 1 C = 2 5 8 11 369Question 2. Is the matrix below invertible? In case yes, nd its inverse: 100
SUNY Stony Brook - MAT - 127
Answers for HW 1 9. 3 + 5 n2 lim = lim n n + n2 n 10. 1+ n+1 = lim n 3 n 3n 1 lim 11. 12 2n = lim ( )n = 0. n 3 3 n 3n+1 lim 12. lim 1 n n 19. Consider f (x) = x2 ex =x2 ex . 1 n 1 n 3 +5 n2 1 n +1=0+5 = 5. 0+1=1+0 1 =. 30 31 1 = = 1. 0
SUNY Stony Brook - MAT - 127
Answers for HW 11 2.Since ey dy = we get ey = 2 x 2 + C . 3 3. If y = 0, then 1 dy = y which means ln |y | = So nally y = A x2 + 1, A R. 5. From 1+ x2 x dx, +13x dx,1 ln(x2 + 1) + C. 2sin y dy = cos yx2 + 1 dx,we get (since sin ydy = d
SUNY Stony Brook - MAT - 127
Answers to the MAT127 Homework No.2 Chapter 8 Section 2 Problem 5, 7, 9, 19, 20, 25-28, 33, 36, 43 5. Divergent. Because tan n does not convergent to 0. 7. Convergent. SinceNn=11 1 1.5 n (n + 1)1.5 1 21.5 1 1 1.5 + 1.5 2 3 1 1 N 1.5 (N + 1)1.
SUNY Stony Brook - MAT - 126
Solutions for the second quizQuestion 1. We have:2 1x 3 x4 dx = x222 1x dx + x212 13x4 dx = x22 11 dx 3 x2x2 dx =1ln |x|13x3 2 3= ln 2 ln 1 (23 13 ) = ln 2 7xa+1 a+1Remember that the formula xa dx = case we
SUNY Stony Brook - MAT - 123
MAT123 - Introduction to calculus Second Practice Midterm The Second Midterm will be on Tuesday 11/11 at 8:30pm at Harriman 137. Important: check the webpage to get a copy of Second Midterm of Fall 2007! Question 1. Compute: (a) log2 (16) (b) ln e3 +
SUNY Stony Brook - MAT - 126
MAT126 Calculus B Solutions to some practice problems sec 4.9, problem 24. Find f if f (x) = 4 6x 40x3 and f (0) = 2, f (0) = 1. Computing the antiderivative: f (x) = f (x)dx = (4 6x 40x3 )dx = 4x 6 x2 x4 40 + C 2 4= 4x 3x2 10x4 + C f (0)
SUNY Stony Brook - MAT - 127
Math 127 - S2008 Practice Test for the Final Examination1. Show that the function y =Ccos(x) x2is a solution of the dierential equationx2 y + 2xy = sin(x). For what value of C does the solution satisfy the initial condition y(2) = 0? 2. Find th
SUNY Stony Brook - MAT - 126
MAT 126 Summer 08 Practice Final Question 1. Compute the derivative of the given functions: (a) f (x) = (b) g (x) =x (sin(2t) 4+ et cos t)dt6x3 esin u du x sec u+Question 2. Evaluate the indenite integrals: (a) (3x 5.73)13 dx (c) (e) a+b
SUNY Stony Brook - MAT - 126
MAT 126 Summer 08 Practice Midterm NAME: Question 1. Estimate the area under the graph of f (x) = 36 x2 from x = 0 to x = 5 using ve approximating rectangles and right endpoints. Is your estimate an underestimate or an overestimate? Question 2. Exp
SUNY Stony Brook - MAT - 127
Answers to the MAT127 Homework No.8 Chapter 8 Section 8 Problem 1-3, 9, 10, 13, 14 1. 1 21+x =n=0nxn11 ( 22 1 1)( 2 n) ( 1 n + 1) n 2 x n!= 1+n=1 = 1+n=1(1)n1 1 3 5 (2n 3) n x 2n n!So an =(1)n1 135(2n3) , 2n n!t
SUNY Stony Brook - MAT - 127
Answers for HW 9 3. Usually, one may compute the 1st, 2nd and 3rd derivatives of f at to get the 6 T3 . For this problem, one may also use sin(y + z ) = sin y cos z + cos y sin z to get the whole Taylor series of f. Just take y = x and z = .(Sinc
SUNY Stony Brook - MAT - 127
Math 127 - Spring 2008 Practice for First Examination1. Calculate the following limit if it exists. e2n + n5 e5n . n n4 (3ne2n + 1)(4e3n + 5n) lim 2. Determine whether the seriesn=11 + ln(n) (1+ln(n)2 e nis convergent or divergent. Justify yo
SUNY Stony Brook - MAT - 127
Answers to the MAT127 Homework No.6 Chapter 8 Section 6 Problem 3-6, 9, 10, 17, 18-20, 30 3. 1 1 f (x) = = = 1+x 1 (x) (x) =n=0 n=0n(1)n xnThe series converges when |x| &lt; 1, so the the interval of convergence is (1, 1). 4. 1 f ( x) = 3 =
SUNY Stony Brook - MAT - 127
Math 127 - Spring 2008 Practice for Second Examination1. Find the interval of convergence for the power series(1)n+1n=2(x 6)2n . n12 3n2. Find the MacLaurin series for the function ex 1 f (x) = . x3 3. Find the sum of the innite series 2 3
Virgin Islands - FT - 20080521
Third Annual Forum Targeting Faculty Teaching Full Time (FT3) May 22, 2008 University of Victoria Department of Computer Science Engineering / Computer Science Room 660 Agenda Commence by 10:00 AM (Mike Z) SIGCSE in Portland: individual highlig
SUNY Stony Brook - MAT - 131
MAT131 Review for the final1. Evaluate the integral8a. b. c. (t12/3- 2 t 4 / 3 ) dtp (- sin x + cos x )dx0 0 -17 1- x2dx2. A rectangular playground is to be fenced off and divided into two by another fence parallel to one s
SUNY Stony Brook - MAT - 131
Review exercises for midterm I 1. Find the limit a. b. c.x+3 lim x 2- x - 2 x3 lim ex - x x lim e 3 2. If an arrow is shot upward on the moon with a velocity of 70m/s, its height (in meters) after t seconds is given by H(t)=70t-0.83t2. a. F
SUNY Stony Brook - MAT - 131
Calculus Early Exam February 5, 2003Instructions: The exam consists of 15 multiple choice questions. You have 90 minutes to answer all fteen questions. Be sure to record your answers on the opscan form. You are not allowed to use any books, notes, o