Assignments | Class Photo | Course Home | Lab Hours/Tutoring | MATLAB info | Schedule | Submit

Saint Louis University

Computer Science 145
Scientific Programming

Michael Goldwasser

Spring 2009

Dept. of Math & Computer Science

Assignment 01

Use of scalars and operator precedence

Contents:


Overview

Topic: Use of scalars and operator precedence
Related Reading: Ch. 2 as well as coverage of scalars from lecture
Due: Wednesday, 21 January 2009, 11:59pm

Please make sure you adhere to the policies on academic integrity.


Problems to be Submitted (20 points)

You are to submit a single m-file that outputs the resulting assignments for each of the following problems, in the given order. Please make sure that your name is given in comments at the beginning of the m-file and ensure that no output is generated by your scripts other than the resulting answers.

Submit your m-file in accordance with cs.slu.edu/~goldwasser/145/submit.

Problem A)
Calculate and display the variable

\begin{displaymath}\mbox{answerA} = \frac{28.5 \cdot 3^3 - \sqrt{1500}}{11^2 + 37.3} \end{displaymath}

Problem B)
Calculate and display the variable

\begin{displaymath}\mbox{answerB} = \left(\frac{7}{3}\right)^2 \cdot 4^3 \cdot 18 -
\frac{6^7}{\left(9^3 - 652\right)}\end{displaymath}

Problem C)
Set the variable $x = 9.75$ and then calculate and display

\begin{displaymath}\mbox{answerC} = 4x^3 - 14x^2 - 6.32x + 7.3\end{displaymath}

Problem D)
The number of ways of choosing $r$ objects out of a set of $n$ objects can be computed as

\begin{displaymath}\frac{n!}{r!(n-r)!}\end{displaymath}

where $n!$ can be computed as factorial(n) in MATLAB. Set the variables $n = 12; r = 5;$ and then compute and display

\begin{displaymath}\mbox{answerD} = \,\, \parbox{4in}{number of ways in which a ...
...oster of
12 players can choose the 5 players who start a game.}\end{displaymath}

Problem E)
An earthquake with magnitude $M$ on the Richter scale releases energy (in Joules) according to the formula,

\begin{displaymath}10^{\left(4.4 + \frac{3M}{2}\right)}\end{displaymath}

Calculate and display the variable

\begin{displaymath}\mbox{answerE} = \frac{\mbox{Energy released by a 7.1 magnitude quake}}{\mbox{Energy released by a 6.9 magnitude quake}}\end{displaymath}

Problem F)
According to the syllabus, late work submitted for this course receives the grade of

\begin{displaymath}R \cdot e^{-\frac{h}{173}},\end{displaymath}

where $R$ represents the grade the work would have recieved had it been on time, and $h$ is the amount of time (in hours) that the work was late. Set the variables $R = 95; h = 20;$ to represent work that would have received a score of 95 if not penalized, but which was turned in 20 hours late. Calculate and display the variable

\begin{displaymath}\mbox{answerF} = \,\, \mbox{Actual credit received for such an assignment}\end{displaymath}

Problem G)
The distance $d$ from a point $(x_0, y_0)$ to a line $Ax + By +
C = 0$ is given by

\begin{displaymath}d = \frac{\left\vert Ax_0 + By_0 + C\right\vert}{\sqrt{A^2 + B^2}}.\end{displaymath}

Set the variables $x0 = 3; y0 = -4; A = 2; B = -7; C = -10;$ and then calculate and display


\begin{displaymath}\mbox{answerG} = \,\, \mbox{Distance between point $(3,-4)$ and line
$2x - 7y - 10 = 0$.}\end{displaymath}

Note: you may use built-in functions sqrt and abs.


Michael Goldwasser
CSCI 145, Spring 2009
Last modified: Monday, 19 January 2009
Assignments | Class Photo | Course Home | Lab Hours/Tutoring | MATLAB info | Schedule | Submit