Original Post
Ok so I am currently working on a complex console game in which the player takes on the role of an all powerful AI which controls the subconscious of a humanoid population. Many factors will be simulated in this game which will directly or indirectly effect birth/death-rate. This humanoid population will start at 1000 and increase until it reaches 15 billion when the game ends.
I wish to create a function in which a user input time increment and a global variable that represents yearly population increase can define the exponential population growth.
Ok so here is my formula (written in purely mathematical syntax no c++)
P = Ip(e^-kt)
Where
P = population
Ip = initial population
k = exponential constant
t = time
So inputing my numbers into this I get:
15,000,000,000 = 1000(2.718281828^-kt)
Or
15,000,000 = 2.718281828^-kt
ln(15,000,000) = k.t (ln e)
ln e = 16.524...
So
t=(16.524/k)(ln 15,000,000)
What I need to know is
1. Is this formula correct?
2. How can I make it so that t is the subject?
3. How can I best write this in C++ as a function or class with k as a global variable?
Thankyou for any help in advance, I am 15 and this maths is way beyond what I do in school.
I wish to create a function in which a user input time increment and a global variable that represents yearly population increase can define the exponential population growth.
Ok so here is my formula (written in purely mathematical syntax no c++)
P = Ip(e^-kt)
Where
P = population
Ip = initial population
k = exponential constant
t = time
So inputing my numbers into this I get:
15,000,000,000 = 1000(2.718281828^-kt)
Or
15,000,000 = 2.718281828^-kt
ln(15,000,000) = k.t (ln e)
ln e = 16.524...
So
t=(16.524/k)(ln 15,000,000)
What I need to know is
1. Is this formula correct?
2. How can I make it so that t is the subject?
3. How can I best write this in C++ as a function or class with k as a global variable?
Thankyou for any help in advance, I am 15 and this maths is way beyond what I do in school.