Patrick B. answered • 06/18/19

Math and computer tutor/teacher

y = c * B^x

takes the log of both sides:

log y = log C + logB^x

log y = log C + x * log B <--- this is linear with slope m=logB and intercept k=log C

Then you do the LINEAR REGRESSION on x vs. log Y.

Once done, you have base B = 10^m and intercept k= 10^c

========================================================

There are MANY online calculators and hand-held calculators that will do these

calculations for you. It is a shame you have to "REINVENT the Wheel" by having to

implement it yourself. It would probably be easier to do it with the spreadsheet (Excel/google sheets).

Oh well... I have uploaded the source code written in Java for you. The filename is REGRESSION.java

in the RESOURCES section under the TOOLKIT menu. THe code is too long to display here.

You need to create the input file like this:

N=6

X y

0 , 3

1 , 6

2 , 12

3 , 24

4 , 48

5 , 96

The equal sign in the first line states there are six ordered pairs. The equal sign is REQUIRED.

It then reads the ordered pairs, loads the data into memory arrays, sets up the table, calculates, and

outputs the results.

The output is correct here at y = 3*2^x

You will also need to change the filename in the Go() routine. I hard-coded the filename because you need to translate this code into another script language anyway. Just take the algorithm and "heart and soul" or "meat and potatoes" out of the code, use what you need, and discard the rest...

Good Luck