SUNY Geneseo Department of Mathematics

Lab 1—Variables and Expressions

Math 230 02
Spring 2016
Prof. Doug Baldwin

Complete by Tuesday, February 2
Grade by Friday, February 5

Purpose

This lesson develops your ability to (1) use variables to store values, (2) to write calculations as Matlab expressions, and (3) begin using scripts as places to write and save Matlab computations.

Background

This lesson is based on material in chapters 2, 3, and 4 of our textbook. Sections 2.1 and 2.2, 3.1 through 3.4, and 4.1 and 4.2 are particularly relevant. We discussed much of what you really need concerning expressions and variables for this exercise in class on January 25. We will further discuss expressions on January 27, variables on January 29, and scripts on February 1.

The second problem requires some knowledge of counting and statistics that you can find in the following videos.

Activity

Write Matlab scripts that solve each of the following problems. Write a separate script for each problem. I don’t expect these scripts to be much more than series of expressions and comments and assignments to variables, but nonetheless the scripts should help you organize your work and present it to me.

Problem 1

Use the quadratic equation to find the x values at which a polynomial of the form ax2 + bx + c is zero. Store a, b, and c in variables. Recall that the quadratic equation says that the polynomial is 0 at the two values x = (-b ± √(b2 - 4ac)) / 2a. You will probably need several Matlab expressions to calculate both x values. Think about whether there are ways to use Matlab variables to connect these expressions in ways that reduce the amount of redundant code in both of them. Test your Matlab expression(s) on x2 - 2x - 3, which is 0 at x = -1 and x = 3. Now consider the polynomial 3x2 + x + 2. Do you think there are values at which it is 0? What does Matlab say?

Problem 2

The current (as of January, 2016) rules for winning the top two prizes in the Powerball lottery are as follows: each lottery drawing consists of 5 distinct numbers chosen randomly from the set 1 through 69, plus 1 number (the Powerball) chosen from the set 1 through 26. To play the lottery, you basically guess what the numbers will be. If you guess all 6 correctly, you win the jackpot. If you guess the first 5 correctly but not the Powerball, you win a second-place prize of $1,000,000. Note that the order in which you guess the 5 regular numbers relative to the order in which they are drawn doesn’t matter—for example if you pick 1, 2, 3, 4, 5, and the drawing is 5, 4, 3, 2, 1, you still have a match.

Write Matlab expressions to calculate the answers to the following questions. Later questions generally build on the results of earlier ones, so you may find it helpful to save results in variables that you can use in later expressions. For the questions that ask you to compute a probability of winning one of the prizes, you can check your answers against the official odds at http://www.powerball.com/powerball/pb_prizes.asp.

How many possible sets of 5 numbers between 1 and 69 are there?

What is the probability that a player who buys 1 ticket will match the 5 regular numbers?

What is the probability that a player who buys 1 ticket will match the 5 regular numbers and the Powerball, i.e., the probability of winning the jackpot?

What is the probability that a player who buys 1 ticket will win a second-place prize? Warning: this is not quite the probability of matching the 5 regular numbers!

Suppose the jackpot is $500,000,000. What is the expected profit (i.e., winnings in excess of the ticket price) of a player who buys one ticket? Assume that the only ways of winning are to win the jackpot, or to win the second place prize.

What does the jackpot have to be in order for a player who buys one ticket to have a positive expected profit. As above, assume that the only ways of winning are to win the jackpot or to win the second place prize.

Follow-Up

I will grade this exercise in a face-to-face meeting with you. During this meeting I will look at your solution, ask you any questions I have about it, answer questions you have, etc. Please bring your solution on your computer, as that will speed the process along.

Sign up for a meeting via Google calendar. Please make the meeting 15 minutes long, and schedule it to finish before the end of the “Grade By” date above.