linear functions

```int simple(int x) {
return x;
}
```

And this just means make y equal to whatever x is. If we want y to change at the same speed as x but not have the same value, we can do something like this:

```int fiveMore(int x) {
return (x + 5);
}
```

which means make y equal to whatever x is plus 5. + 5 is referred to as a constant term. We can also make y change at a different speed than x:

```int twice(int x) {
return (x * 2);
}
```

which means make y equal to double what x is. 2 is referred to as a coefficient. We can also combine these, and that's what we'll do in the following applet. Note that the move(...) function's x parameter has nothing to do with horizontal coordinates.

```//----------------------------
// variables
float currY;
int currTime;

//----------------------------
void setup() {
// set up the applet
size(300, 300);
smooth();
frameRate(30);

// reset the animation independent variable (time)
currTime = 0;

// set the ball color
noStroke();
fill(#FF6F00);
}

//----------------------------
void draw() {
// clear the screen
background(0);

// move the ball
currY = move(currTime);

// draw the ball
ellipse(width/2, currY, 20, 20);

currTime++;
}

//----------------------------
void mousePressed() {
// reset the animation independent variable (time)
currTime = 0;
}

//----------------------------
float move(float x) {
return (0.8 * x + 10);
}
```

That's a bit lame, but that's because this function is pretty simple.

Math For Artists Who Now Need to Program

Elie Zananiri
ITP DriveBy
1 Oct 2008