COSma Coding

COSma Coding

COSma Learning

Changing Quantities

Suppose \( x \) is a variable. Recall that we generally think of \( x \) as representing the *varying* value of some quantity. In math and science, we generally ask questions about how a value *changes* over some interval.

So, suppose \( x \) varies from \( x = 3 \) to \( x = 8 \). By how much did \( x \) change by? Your gut might tell you that \( x \) changed by 5 - which is correct! To represent that "\( x \) changed by 5," we generally write \( \Delta x = 5 \). The triangle, \( \Delta \), is actually the Greek letter "Delta", and we use this symbol to denote a "change".

Now, suppose that \( x \) varies from \( x = 2 \) to \( x = -3 \). By how much did \( x \) change by? In this case, \( x \) changed by 5, but in the *negative* direction! That is, \( x \) *decreased* by 5! To represent this, we would write \( \Delta x = -5 \).

In general, the change in \( x \) is the amount that the final value of \( x \) exceeds the initial value of \( x \), which means that if \( x \) varies from \( x = x_i \) to \( x = x_f \) then the change in \( x \) is \[ \Delta x = x_f - x_i \] Let's write some code to do some computing for us! The code below shows a `change()`

function that takes an initial value and a final value as inputs, and then computes the change in value from the initial value to the final value.

```
function change(initial_value, final_value) {
return final_value - initial_value;
}
print( change(3, 8) );
print( change(2, -3) );
print( change(1.72, 1.834) );
```

In lines (1) - (3) above, we define a function `change()`

that computes a change from `initial_value`

to `final_value`

. Then, lines (5) - (7) use this function. Make sure this makes sense to you! Why does line (6) print a negative value?

Constant Rate of Change: Special Changes

*Constant rate of change* relationships are very important in math! They are a special type of relationship between two quantities where the *change* in one quantity's value is always same number of times as large as the *change* in the value of the other quantity.

For example, if \( x \) and \( y \) vary together at a constant rate of change of 2, it means that whenever \( x \) changes by some amount, \( y \) changes by exactly 2 times as much. So if \( x \) increases by 1, \( y \) will increase by \( 2\cdot 1 = 2 \). If \( x \) increases by 0.5 then \( y \) changes by \( 2 \cdot 0.5 = 1 \). If \( x \) changes by 0.001 then \( y \) changes by \( 2 \cdot 0.001 = 0.002 \). In general, if \( x \) changes by \( \Delta x \) then \( y \) will change by \[ \Delta y = 2\cdot \Delta x \] This is a very useful property! If we know how much \( x \) changes by, we know exactly how much \( y \) will change by!

The code editor below...