1.4 Functions Given by Words

Example 1.9

So the water has 25% of its pollutant removed per hour.  If we start with 9 mg/l, after one hour, 0.25*9  = 2.25 mg/l is removed from the water.  Thus after 1 hour, there is 9-9*0.25 = 9-2.25 = 9*(1-0.25) = 9*0.75 = 6.75 mg/l.  After two hours, 6.75*0.25 = 1.6875 mg/l is removed from the concentration, giving 6.75-6.75*0.25 = 6.75*0.75 = 5.0625 mg/l.  But 6.75 = 9*0.75, so this is really 9*(0.75^2), etc...

Part 1

Using the idea from above, we know after three hours, the concentration of pollutant left should be 9*(0.75^3)mg/l. Which, according to the calculation below is 3.8 mg/l.

9*(0.75^3)

Part 2

Cpol[t_]:= 9*(0.75^t)

Cpol[1]

Cpol[2]

Cpol[3]

From the above computations, C(1 hr) = 6.75 mg/l, C(2 hr) = 5.0625 mg/l, and C(3 hr) = 3.8 mg/l.

Part 3

Cpol[4.25]

The concentration of pollutant after 4.25 hours is 2.65 mg per liter.

Example 1.10

Since the initial investment was $2000 and we lose 7% every month, the approach to the formula is similar to that of Example 1.9.  
Month 1: $2000-2000*0.07 = $2000*(1-0.07) = $2000*(0.93)
Month 2: $2000*(0.93)*(1-0.07) = $2000*(0.93^2)
Month 3: $2000*(0.93^3)
etc...

Part 1

VestData = Table[{t,2000*0.93^t},{t,0,5}]

FancyVestData = MapThread[Prepend,{Transpose[VestData],{"t = Months","V(t) = Investment Value"}}];

Grid[FancyVestData  ,Frame-> All]

Part 2

ListPlot[VestData,AxesOrigin->{0,1200},PlotRange->{{-0.8,5.2},{1200,2100}},PlotStyle->Blue, PlotMarkers->{"▽",16}, Joined-> True]

Part 3

Already verified, that is how we generated the table!

V[t_]:=2000*(0.93^t)

Part 4

V[4.5]

V[9.5]

After 4.5 months, we have $1442.79 cents left of our investment, and after 9.5 months, we have $1003.73.

Part 5

We can run the table out a little further from Part 1 to get an idea:

Table[{t,2000*0.93^t},{t,0,25}]

We can also evaluate the function itself:

V[25]

V[100]

V[1000]

Clearly, as the months go by, the value of the investment continues to decline until it becomes essentially zero.

Example 1.11

Total investment = price of unfinished stone + $40.00 x number of hours gem cutter needs to finish it

Part 1

We will let I be the investment total (in $), c be the cost of the uncut stone (in $), and h be the number of hours the gem cutter takes to finish the gem (in hours): I = I(c,h) = c+40h.
Note that the variable I (much like the variables C and D) is reserved for other purposed by Mathematica, so we will use Inv as the function name instead.

Inv[c_,h_]:=c+40*h

Part 2

The base cost c is $320, and 5 hours and 15 minutes is 5.25 hours. So in function notation: I($320,5.25 hours)= $530, which is computed below.

Part 3

Inv[320,5.25]

Exercise 4

The info:
10 minutes to preheat oven to 325F
Recommended cooking time for turkey @325F is 15 min/lb
T = total cooking time
p = weight of turkey in pounds
T = T(p)
(min/lb)*lb

Part a.

T[p_]:= 10 + 15p

Part b.

T[18]

%/60.0

The cooking time for an 18 pound turkey is 280 minutes, which can be expressed as 4 hours and 40 minutes.

Exercise 12

Cost C of operating a car:
C = C(m,g,d)
m is gas mileage in miles/gal, g is price of gas in $/gal, d is distance driven in miles

(miles/(miles/gallon))= (1/(1/gallon))

Part a.

drive 100 miles, car gets 25 mpg, and gas costs 349 cents/gal
This is a simple exercise in dealing with units, we want a cost, so the result should be in cents, which we can also express in dollars.  So we use this exercise to introduce units in Mathematica!  We will not always use units, but this is a good example to do so with.

Quantity[100, "Miles"]/Quantity[25, "Miles"/"Gallons"]*Quantity[349 ,"USCents"/"Gallons"]

UnitConvert[N[%],"USDollars"]

So the cost was $13.96, we simply used the formula (d/m)*g to end up with cents as a unit.

Part b.

Cost[d_,m_,g_]:=(Quantity[d, "Miles"]/Quantity[m, "Miles"/"Gallons"])*Quantity[g ,"USCents"/"Gallons"]

N[Cost[100,25,349]]

Part c.

Cost[138,28,369]

N[%]

UnitConvert[N[%],"USDollars"]