# simple function problem

I was just trying to eliminate a set of 142 variables by using a function.
142 day feeding schedule for 100 Tilapia.
So I came up with this:
f(x) = 84.0726 exp (0.0147 x ) with R^2=0.9999. Nice right?

So x= the day in the feeding schedule 1-142. Enter the day as x and out poops feed in grams.
It works flawlessly using a calculator.
This is my first sketch and my math skills are atrophy at best.

First I tried that which is not blocked out as it runs now. Or rather does not even compile, giving me the error ‘expression can not be used as a function’ on this line ‘optionally=pow(82.8554,.0148(currentDay));’. This seems the simplest way.

Then I tried the longer way that failed do to my math skills, I’m pretty sure. Not working the problem correctly. Probably something very simple. Math tutor please.

Here it is without stepper motors, sensors or RTC, the short version:

`````` double optionally=0;
float clockDay=1;
double currentDayFeed=0;
float currentDay = 0;
float exponent=0;
float base=82.8554;
float expCon=.0148;
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (currentDay<143)
{
currentDay++;
Serial.println("Current day");
Serial.println(currentDay,DEC);
//This was my failed attempt to make this work,
//it's mathmatically incorrect and probably will work
//Serial.println("expCon= ");
//Serial.println(expCon,DEC);
//Serial.println("expCon*currentDay = ");
//exponent=(expCon*currentDay);
//Serial.println("Exponent = ");
//Serial.println(exponent,DEC);
//currentDayFeed=pow(base,exponent);
//Serial.println("Current day feed ");
//Serial.println(currentDayFeed,DEC);
optionally=pow(82.8554,.0148(currentDay));
Serial.println (optionally)
}
else
{
Serial.println ("This is the end,...my friend... The end... woooe...");
delay (10000);
}
}
``````

`=pow(82.8554,.0148(currentDay));`Are you missing one of these '*' ?

``````     optionally=pow(82.8554,.0148(currentDay));
``````

I have no idea what you expect the compiler to do with 0.0148 and currentDay, but that looks like you are trying to call a function names .0148() which is obviously not a valid name for a function.

You can NOT just invent syntax.

got it.
Natural log.

Think I would just have used an array how ever many days long with the food amount in it, call it say, food.

So then when you want food for day 16 , you’d just look at the contents of food

FeedMe = food;

If you need to work out your array contents in a speadsheet, I don’t like big maths in Arduino