Sunday, November 4, 2007

deepening understanding of functions

Using SeeLogo to Understand Functions

We can use SeeLogo to create a picture that changes in time. One good reason to do this is so that we can become familiar with using functions and manipulate them to achieve certain desired effects.

In order to carry out this exercise, we need to translate our regular mathematical notation to the language that the SeeLogo program can understand.

Before we do this, let's review what a function is.

A function y=f(x) can be seen as a rule or a formula so that for every number x that we choose to use as input for the formula (and there may be some limitations), we are going to get another number y=f(x) that is called the output. To put it in words, we say, "y equals f of x," or "y is a function of x."

For many students, this seems strange at the beginning, but note that in spoken language, we also use this concept. For example, when we say, "His success in this endeavor depends on how much effort he put into it," or in short: "Success is a function of effort." Furthermore, we can say, "The temperature is a function of time; at night it is usually colder."

We also refer to the input (x in this case) as the "independent variable" and the output as the "dependent variable."

The choice of f x and y to express the function and its input and output is based on tradition and is not really essential. In fact, any symbol, letter, or word can be used. For instance, we could write r=g(t) to or salary=fun(seniority) or x=h(y).

Every function has a domain and a range. The domain of a function is the set of input numbers and the range is the set of output numbers. When we specify a function, we usually have to specify the domain as well, but the range is then determined by the domain.

In algebra and calculus, we use formulas to express functions and one of the simplest examples is y=x^2. If we specify the domain to be all the numbers x between 0 and 2 (0<=x<=2), then the range will turn out to be all the numbers between 0 and 4 (0<=y<=4).

When defining a function in SeeLogo, we usually want to use it to display pictures that change in time . In many situations we choose the symbol t (indicating time) to represent the independent variable. The dependent variable will vary and in most situations we will deal with several functions all of which will be using the same independent variable t. We will use these functions to "do things" graphically. For convenience we also choose the domain of t to be the interval between 0 and 1 (0<=t<=1).
Before going any further, let us study how to relate this information to the current version of SeeLogo.

When we define and use functions with SeeLogo, we need to start by defining a task. A function should have a function :). In other words, it should be functional and do something. For example:

Task: Draw a small circle that moves at a constant speed from the coordinate xmin=20 to xmax=100 where the vertical position is 50 pixels above the x axis.

In order to implement this function we first translate the task to succinct mathematical language:

Move a small circle at a constant rate from the point (20,50) to the point (100,50).

In this case we need to define just two variables: The independent variable with domain 0<=t<=1 and the function x=x(t) with range (20<=x<=100). There are two stages in creating the animation:

1. Finding the function x(t) and
2. Implementing it in seelogo.

The answer to stage 1 is:
The function x(t) = 20 + 80*t. The reason is that for t=0 x is 20 and for t=1 x is 100

The way we will program the computer to do this is (our first attempt is to explain it in human language

1.Define the variables t and x and set t=0
Local x t
t=0
2.Next repeat the following process 10000 time (Loop 10000 then open "["and close "]" at the end of the process
Add a small time increment to define a new time (t=t+1/10000)
Define the new value of x(t) (x=20 + 80*t)
Make the cursor (or turtle) jump to the new coordinate
Draw a small circle (circle 3)


The actual seelogo implementation is:
local x t
t=0
loop 10000 [
t=t+1/10000
x=20 + 80*t
JT x 50
circle 3
]

Now we will ask a series of question that will test your understanding and teach you further. Some of the questions are multiple choice:
1. Imagine that you type the following program into seelogo

local t x y
t=0
loop 1000 [t=t+0.001 x=100*t y=50*t]

A. what are the names of the functions involved?
1. x 2. y 3. t 4. x and t 5. x and y

B. What is the domain of the functions? ([a,b] means "all the numbers in between a and b"
1. [0,2] 2. [0,1] 3. [1,2] 4. [1,0]

C. What is the range of the function x?
1. [20,100] 2. [0,50] 3. [0,100] 4. [100,0

D. What is the range of the function y.

E. How will you slow the program by a factor of 100?

2. Write an increasing linear function with name x and domain t from 0 to 1 where x ranges from 50 to 120 (a function is called increasing if the output numbers become bigger as the input numbers increase)

A. x=50 + 70*t B. x=70+50*t C. x=120 D. x=120 - 70*t

3. Write an decreasing linear function with name x and domain t from 0 to 1 where x ranges from 50 to 120 (a function is called decreasing if the output numbers become smaller as the input numbers increase)

A. x=50 + 70*t B. x=70 - 50*t C. x=80 D. x=120 - 70*t

4. Find two linear function x and y so that x with domain t, 0<=t<=1 such that x starts at -100 and ends at 100 and y starts at 90 and ends at 10.
A. x=-100 + 200*t y= 10 + 80*t B. x=-100 + 100*t y=90 - 80*t C. x=-100 + 200*t y = 90 - 80*t

5. Write a small program that makes a small circle move from the point (-100,100) to (90,10)

local t x y
t=0
loop 100000 [t=t+1/100000 x=____ y=_____ JT __ __ ______ 3]
What are the blanks?

6. Now write a program from scratch w/o looking that does the same thing and test it
7. Write a program without looking that makes a small circle move from (120,-100) to (-110,90)

8. A. Find a function x with domain [0,1] and range [-100,100] and another function r with the same domain but range [0,100]
B. Write a program that uses the functions x and r so that a circle of diameter r is placed at the point (x,0).
C, change the program so that the color of the circle will be random.

17 comments:

Unknown said...

A. 5

B. 2

C. 3

D. [0,50]

E. change to loop 100,000 [t=t+1/100,000]

2. A

3. D

4. C

5.
local t x y
t=0
loop 100000 [t=t+1/100000 x=-100 + 190*t y=100-90*t JT x y circle 3]

6. (same)

7.
local x y t
t=0
loop 10000 [t=t+1/10000
x=120-230*t y=-100+190*t
jt x y circle 3]

8. A.
local x t
t=0
loop 10000 [t=t+1/10000
x=-100+200*t
jt t x circle 3]

local r t
t=0
loop 10000 [t=t+1/10000
r=100*t
jt t r circle 3]

B.
local x r t
t=0
loop 10000 [t=t+1/10000
x=-100+200*t
r=100*t
jt x 0 circle r]

C.
local x r t
t=0
loop 10000 [t=t+1/10000
x=-100+200*t
r=100*t
jt x 0 color rnd 500 circle r]

Anonymous said...

1. Imagine that you type the following program into seelogo

local t x y
t=0
loop 1000 [t=t+0.001 x=100*t y=50*t]

A. what are the names of the functions involved?
5. x and y

B. What is the domain of the functions? ([a,b] means "all the numbers in between a and b"
2. [0,1]

C. What is the range of the function x?
3. [0,100]

D. What is the range of the function y.
[0,50]

E. How will you slow the program by a factor of 100?

loop the program by 100000, which is 100x's larger than the loop of 1000 we used previously.

2. Write an increasing linear function with name x and domain t from 0 to 1 where x ranges from 50 to 120 (a function is called increasing if the output numbers become bigger as the input numbers increase)

A. x=50 + 70*t

3. Write an decreasing linear function with name x and domain t from 0 to 1 where x ranges from 50 to 120 (a function is called decreasing if the output numbers become smaller as the input numbers increase)

D. x=120 - 70*t

4. Find two linear function x and y so that x with domain t, 0<=t<=1 such that x starts at -100 and ends at 100 and y starts at 90 and ends at 10.
C. x=-100 + 200*t y = 90 - 80*t

5. Write a small program that makes a small circle move from the point (-100,100) to (90,10)

local t x y
t=0
loop 100000 [t=t+1/100000
x=-100+200*t
y=90-80*t
JT 100 10?
circle 3]

answers in bold^^

6. Now write a program from scratch w/o looking that does the same thing and test it

local t x y
t=0
loop 10000 [t=t+1/10000
x=-100+200*t
y=90-80*t
jt 100 10 <---i dont understand the jt theory...
circle 3]

7. Write a program without looking that makes a small circle move from (120,-100) to (-110,90)

need help, dont understand JT

8. A. Find a function x with domain [0,1] and range [-100,100] and another function r with the same domain but range [0,100]
B. Write a program that uses the functions x and r so that a circle of diameter r is placed at the point (x,0).
C, change the program so that the color of the circle will be random.


need a little bit more explanation to fully understand...how do i know how to determine what the functions are, and how do i determine where to "jt"?


alillie1@ithaca.edu

Unknown said...

Oops! My email is kpinnis1@ithaca.ed

Anonymous said...

reading what kerry wrote, i realized that all i need to do for jt is tell the cmoputer to jump to the x and y functions that i defined. so now i understand a little bit more, but i still am a little shaky on knowing how to write the functions.

Aimee
alillie1@ithaca.edu

Anonymous said...

1)
a. 5
b. 2
c. 3
d. [0,50]
e. You will change loop 1000 to loop 100000 and change t+0.001 to t+0.00001

2) A
3) D
4) C
5)
local t x y
t=0
loop 100000[t=t+1/100000
x=-100=200*t
y=90-80*t
jt x y circle 3]

6) Yes it works!
7)
local t x y
t=0
loop 100000[t=t+/100000
x=120-200*t
y=-110+200*t
jt x y circle 3]

8)
a.
x=-100+200*t
r=0+100*t
b.
local t x r
t=0
loop 100000[t=t+1/100000
x=-100+200*t
r=0+100*t
jt x 0 circle r]
c.
local t x r
t=0
loop 100000[t=t+1/100000
x=-100+200*t
r=0+100*t
jt x 0 color rnd 511 [circle r]]

cmuldow1@ithaca.ed

V said...

1. A. 5
B. 2
C. 1
D. [0, 50]
E. add two zeros to the "loop" function and following "t" function
2. A
3. D
4. C
5. x=-100+190*t
y=-100-90*t
jt x y
circle 3
6. wouldn't it be the same program?
7. local t x y
t=0
loop 100000 [t=t+1/100000
x=120-230*t
y=-100+190*t
jt x y
circle 3]
8. A. local t x
t=0
loop 1000 [t=t+1/1000]
x=-100+200*t
jt t x
circle 3

B. local t r
t=0
loop 1000 [t=t+1/1000]
r=100*t
jt t r
circle 3

C. local x r t
t=0
loop 1000 [t=t+1/1000
x=-100+200*t
r=100*t
jt x 0
color rnd 1000
circle r]

Anonymous said...

A) 5
B) 2
C) 3
D) [0, 50]
E) change to 100,000
2) A
3) D
4) C
5) local t x y
t=0
loop 10000 [t=t+1/10000
x= -100+200*t
y= 90-80*t
jt x y
circle 3]
6) repeated 5 without looking
7) local x y t
t=0
loop 10000 [t=t+1/10000
x= 120-230*t
y= -100+190*t
jt x y
circle 3]
8a) local x r t
t=0
loop 10000 [t=t+1/10000
x= -100+200*t
r= 100*t
jt x r
circle 3]
b) local x r t
t=0
loop 10000 [t=t+1/10000
x= -100+200*t
r= 100*t
jt x 0
circle r]
c) local x r t
t=0
loop 10000 [t=t+1/10000
x=-100+200*t
r=100*t
jt x 0
color rnd 500 circle r]


therold1@ithaca.edu

Anonymous said...

1. x 2. y 3. t 4. x and t 5. x and y
A=5. x y

B.
A=2. 0,1

C. What is the range of the function x?
1. [20,100] 2. [0,50] 3. [0,100] 4. [100,0
A= 20,100

D. What is the range of the function y.
A=2.0,50

E. How will you slow the program by a factor of 100?
A=loop by 100000

2. Write an increasing linear function with name x and domain t from 0 to 1 where x ranges from 50 to 120 (a function is called increasing if the output numbers become bigger as the input numbers increase)

A.
A= A. x=50+70*t

3.

A= D. x=120-70*t

4.

A= c. -100+200*t y= 90-80*t

5.

local x t y
t=0
loop 100000 [t=t+1/10000 x=-100+200t y= 90-80tJT x y circle 3]

6.
I ended up using the same program as above

7. Write a program without looking that makes a small circle move from (120,-100) to (-110,90)
i think...
local x y t
t=0
loop 100000 [t=t+1/10000 x=120-230*y=-100+190*t
jt x y circle 3

8. I Dont understand number 8. If i understand it i will blog again

Arandel1@ithaca.edu

Unknown said...

a.) 5
b.) 2
c.) 3
d.) [0,50]
e.) loop 100,000
2.)a
3.)d
4.)c
5.)local t x y
t=0
loop 100,000 [t=t+1/100,000 x=-100+200*t y=90-80*t jt x y circle 3]
6.) repeated 5 without looking
7.)loop x y t
t=0
loop 100,000[ t=ty+1/100,000 x=120-230*t y=-100+190*t jt x y circle 3]
8.)
a.) local x t r
t=0
loop 100000 [ t=t+1/100000 x=-100+200*t r= 100*t jt t x r circle 3]
b.) local x r t
t=0
loop 100000 [t=t+ 1/100000 x=-100+200*t r=100*t jt x 0 circle r]
c.) local x r t
t=0
loop 100000 [t=t+1/100000 x=-100+200*t r=100*t jt x 0 color rnd 500 circle r]

Maureen
mmcalin1@ithaca.edu

Megan said...

1.)
A. 5
B. 2
C. 3
D. [0,50]
E You add two more zeros so:
loop 100000 and [t=t+.00001]

2.)A
3.)B
4.)C
5.)
local t x y
t=0
loop 10000
[t= t+1/10000
x=-100+200*t
y=90-80*t
JT x y
circle 3]

6.)1.)
A. 5
B. 2
C. 3
D. [0,50]
E You add two more zeros so:
loop 100000 and [t=t+.00001]

2.)A
3.)B
4.)C
5.)
local t x y
t=0
loop 10000
[t= t+1/10000
x=-100+200*t
y=90-80*t
JT x y
circle 3]

6.)
local t x y
t=0
loop 10000
[t= t+1/10000
x=-60+200*t
y=90-80*t
JT x y
circle 3]

It works in the program.

7.)
1.)
A. 5
B. 2
C. 3
D. [0,50]
E You add two more zeros so:
loop 100000 and [t=t+.00001]

2.)A
3.)B
4.)C
5.)
local t x y
t=0
loop 10000
[t= t+1/10000
x=-100+200*t
y=90-80*t
JT x y
circle 3]

6.)
1.)
A. 5
B. 2
C. 3
D. [0,50]
E You add two more zeros so:
loop 100000 and [t=t+.00001]

2.)A
3.)B
4.)C
5.)
local t x y
t=0
loop 10000
[t= t+1/10000
x=-100+200*t
y=90-80*t
JT x y
circle 3]

6.)
local t x y
t=0
loop 10000
[t= t+1/10000
x=-100+200*t
y=90-80*t
JT x y
circle 3]

7.)
local t x y
t=0
loop 10000
[t=t+1/10000
x=120-220*t
y= -110+200*t
JT x y
circle 3]

8.) I am not sure how to do this

--Megan Duhancik
mduhanc1@ithaca.ed

Anonymous said...

a. 5
b. 2
c. 3
d.
e. you change the loop by a factor of 100

2. A
3. D
4. A
5. x=-100+200*t
y=10+80*t
jt x y
circle 3
6. local t x y
t=0
loop 10000[t=t+1/10000
x=-100+200*t
y=10+80*t
jt x y
circle 3]
7. Local t x y
t=0
loop 10000[t=t+1/10000
x=120-210*t
y=90-190*t
jt x y
circle 3]
8. x=-100+200*t
r=100*t
b. local t x r
t=0
loop 10000[t=t+1/10000
x=-100+200*t
r=100*t
jt x 0
circle 3]
c. local t x r
t=0
loop 10000[t=t+1/10000
x=-100+200*t
r=100*t
jt x 0
circle 3]

Unknown said...

1A. 5
1B. 2
1C. 4
1D. [1,50]
1E. Loop 100000[t=t+.00001]

2. B

3. D

4. C

5.
local t x y
t=0
loop 100000 [t=t+1/100000
x=-100+(t*190)
y=100+(t*-90)
JT x y
circle 3]

6. (See Above)

7.
local t x y
t=0
loop 100000 [t=t+1/100000
x=120+(t*-210)
y=-100+(t*190)
JT x y
circle 3]

8A.
local x t
t=0
loop 10000 [t=t+1/10000
x=-100+(200*t)
JT t x
circle 3]

local r t
t=0
loop 10000 [t=t+1/10000
r=100*t
JT t r
circle 3]

8B.
local x r t
t=0
loop 10000 [t=t+1/10000
x=-100+(200*t)
r=100*t
JT x 0
circle r]

8C.
local x r t
t=0
loop 10000 [t=t+1/10000
x=-100+(200*t)
r=100*t
JT x 0
color rnd 500 [circle r]]

Anonymous said...

1. A. 5
B. 2
C. 3
D. [0, 50]
E. Change it to read loop 100000 and t=t+0.00001

2. A

3. D

4. C

5. The blanks are “-100+190*t”, “100–90*t”, “x”, “y”, and “circle” respectively.

6. local x y t
t=0
loop 1000 [t=t+0.001
x=-100+190*t
y=100-90*t
jt x y circle 3]

7.local x y t
t=0
loop 1000 [t=t+0.001
x=120-230*t
y=-100+190*t
jt x y circle 3]

8. A. x=-100+200*t r=100*t
B. local x r t
t=0
loop 1000 [t=t+0.001
x=-100+200*t
r=100*t
jt x 0 circle r]
C. local x r t
t=0
loop 1000 [t=t+0.001
x=-100+200*t
r=100*t
jt x 0
color rnd 512 [circle r]]
jschult3@ithaca.ed

Anonymous said...

1.
a.5
b.2
c.3
d.[0,50]
e.loop 100,000 [t=t+1/100,000]

2.a

3.d

4.c

5.local x y t
t=0
loop 1000 [t=t+0.001
x=-100+190*t
y=100-90*t
jt x y circle 3]

6.local x y t
t=0
loop 1000 [t=t+0.001
x=-100+190*t
y=100-90*t
jt x y circle 3]

7.local x y t
t=0
loop 10000 [t=t+1/10000
x=120-230*t y=-100+190*t
jt x y circle 3]

8.
a. local x t r
t=0
loop 100000 [ t=t+1/100000 x=-100+200*t r= 100*t jt t x r circle 3]
b. local x r t
t=0
loop 100000 [t=t+ 1/100000 x=-100+200*t r=100*t jt x 0 circle r]
c. local x r t
t=0
loop 100000 [t=t+1/100000 x=-100+200*t r=100*t jt x 0 color rnd 500 circle r]


jwerner1@ithaca.ed

Anonymous said...

A. x and y
B. (0,1)
C. (0,100)
D.
E. Increase loop to 10,000
2. A
3. x=120-70*t
4. C
5. x=-100+200+t y=90-80*t
6. local x t y
t=0
loop 100000 [t=t+1/100000 x=-100+200+t y=90-80*t]
7. x=120-230*t y=-100+190*t
8.A local x r t
t=0
loop 10000 [t=t+1/10000 x=-100+200*t
circle 3]
B.
C. local x r t
t=0
loop 10000 [t=t+1/10000 x=-100=200*t circle 3 color rnd 512]

Anonymous said...

1. A. 5
B. 2
C. 3
D. [0, 50]
E. Change it to read loop 100000 and t=t+0.00001

2. A

3. D

4. C

5. The blanks are “-100+190*t”, “100–90*t”, “x”, “y”, and “circle” respectively.

6. local x y t
t=0
loop 1000 [t=t+0.001
x=-100+190*t
y=100-90*t
jt x y circle 3]

7.local x y t
t=0
loop 1000 [t=t+0.001
x=120-230*t
y=-100+190*t
jt x y circle 3]

8. A. x=-100+200*t r=100*t
B. local x r t
t=0
loop 1000 [t=t+0.001
x=-100+200*t
r=100*t
jt x 0 circle r]
C. local x r t
t=0
loop 1000 [t=t+0.001
x=-100+200*t
r=100*t
jt x 0
color rnd 512 [circle r]]

Unknown said...

1 a) x and y
b) [0,1]
c) (0,100)
d) (0, 50)
e) to slow down the program loop 100000 [t=t+0.00001
2 a) x=50 +70*t
3 d) x=120-70*t
4 c) x=-100+200*t
y= 90-80*t
5 local t x y
t=0
loop 1000[t=t+0.001
x=-100+190*t
y=100-90*t
jt x y
circle 3]
6 same
7 x=120-230*t
y=-100+190*t
8 ok for this one I asked kery for help on day after class. she was very helpful and I know i could do it on my own now! Thank you Kerry!!!

I enjoyed doing this homework very much, I think it was helpful to do a little of it in class with all my classmates around me. I like learning from them. :) my email is cdelval1@ithaca.edu

Contributors