Day One - Functions

A function is a relationship between two sets of numbers, where the second number depends on (and is determined by) the first number.

Example 1  The temperature at a given time of the day.   For example we might have Temp[7:00] = 63  and Temp[13:30] = 89.

If we know the time of day (and the location) then the temperature is determined.

Example 2  The Dow Jones average at closing on a given date.  So we might have DOW[ 8/24] = 9505.

Example 3 The log key on your calculator :

log[x_]:=Log[10,x]

log[5.]

log[5.]

Plot[log[x],{x,1,10}]

Plot[log[x],{x,1,10}]

The output is determined by the input.

Example 4  From within Wolfram Alpha search on " temperature Highland Heights, ky "

Look over 1 week and 5 years.   How would we 'model' the temperature as a first step to understanding and predicting weather?

Example 5  From within Wolfram Alpha search on " unemployment rate US by year "

Example 6  With y depending on x, if y= 3(x^3)-1, then y is a function of x.  

Why?  If we know x, we can obtain y by cubing x and subtracting 1.  So, knowing x determines the value of y.

Example 7  Income tax is figured as 10% on the first $ 8, 025, 15% on your income between $ 8, 025 and  $32, 550, 25% from $32, 550 to  $65, 725, 28% from $65, 725 to $171,550, and so forth..

The tax rate, TR(x),  is a function  - one that is fairly complicated.

TR(65,984)=0.28  and TR(4,687.50)=0.15.

For example, a person making $100,000 would be taxed

($ 8, 025 minus 0) x .10 : $ 802.50
(32, 550 minus 8, 025) x .15 : 3, 678.75
(65, 725 minus 32, 550) x .25 : 8, 293.75
(100, 000 minus 65, 725) x .28 : 9, 597.00
Total : $ 22, 

The amount of tax you pay is a fairly complicated function of the money you make.

Things that are not functions.

Example 1   With y depending on x the circle of radius 5:  (x^2)+(y^2)=25.
This is not a function, because knowing x does not tell us y:  For example,  if  x=3, what is y?

Plot[{Sqrt[25-x^2],-Sqrt[25-x^2]},{x,-5,5},AspectRatio->1]

ran[x_]:=Random[Real,x];

Example 2:  Consider the "function" ran which I have defined inside this program.  Is it really a function?

ran[3]

ran[3]

2.2 The Zoo of Functions

Manipulate[ Plot[ a x + b,{x,-5,5},PlotRange->{-10,10}],{a,-5,5},{b,-4,4,1}]

Plotting ax + b

Manipulate[Plot[ (x^n),{x,-5,5},PlotRange->{-100,100}],{n,2,10,1}]

Plotting f[x]=(x^n)

Manipulate[Plot[ (x^n),{x,-5,5},PlotRange->{-100,100}],{n,2,10,2}]

Even powers of x :

Manipulate[Plot[ (x^n),{x,-5,5},PlotRange->{-100,100}],{n,3,11,2}]

Odd Powers of x:

Manipulate[Plot[ (x^(1/n)),{x,0,10},PlotRange->{0,5}],{n,2,10,2}]

y=(x^(1/n)), n even

y=(x^(1/n)), n odd

Manipulate[Plot[If[ x>0,(x^(1/n)),-(((Abs[x]))^(1/n))],{x,-10,10},PlotRange->{-5,5}],{n,3,9,2}]

Manipulate[Plot[1/(x^n),{x,-10,10},PlotRange->{-10,10}],{n,1,7,2}]

Manipulate[Plot[1/(x^n),{x,-4,4},PlotRange->{0,50}],{n,2,8,2}]

A final example (see section 2.4).  Plot f(x)= a (((x-b))^2)+c

Manipulate[Plot[ a (x-b)^2 +c,{x,-10,10},PlotRange->{0,50}],{a,1,4},{b,-2,2,1},{c,0,100}]