# How to solve the Gompertz Equation

23 views (last 30 days)
Kailin Johnsson on 29 Sep 2020 at 0:25
Answered: Walter Roberson on 29 Sep 2020 at 2:36
Hi all,
I am trying to run a simple gompertz equation. however when I run the code below only one line generates instead of two. Anyone have any ideas how to fix this?
%Gompertz Equation
% Parameter and intial condtions
r= (0.349)
p= [2.913 3.929 5.308 7.239 9.638 12.866 17.069 23.191]';
k= 451.7
% Time interval
t = (1790:10:1860)';
%Gompertz Equation
E= k.*(p/k).^exp(-r*t);
% Time Interval
a=(1790:10:1860)';
% Population
b= [3.929 5.308 7.239 9.638 12.866 17.069 23.191 31.443]';
% Plot
plot (a,b,'bo');
hold on
plot(t,E,'r');
line_color=['r'];
hold off
legend('Gompertz Model','Census Data');
axis([1790 1860 0 50]);
title('US Population Data');
ylabel('Population (Millions)');
xlabel ('Years');

Star Strider on 29 Sep 2020 at 0:46
The reason the red line does not plot is that ‘b’ goes from about 3 to about 32, however ‘E’ is constant at about 451.7. So ‘E’ is off the scale of the plot as defined by the axis call.
The solution is to re-scale ‘E’ to match the range of ‘b’.
I leave that to you, since I have no idea what you are doing.

Kailin Johnsson on 29 Sep 2020 at 1:47
Hello! Thank you for your tip.
I rescaled 451.7 to 4.517... however, I am still getting a straight line... Shouldnt the equation be resulting in a curve?
I am looking at popualtion data
Star Strider on 29 Sep 2020 at 2:20
Shouldnt the equation be resulting in a curve?
Probably. How did you arrive at those particular parameters?

Walter Roberson on 29 Sep 2020 at 2:36
r= (0.349)
t = (1790:10:1860)';
E= k.*(p/k).^exp(-r*t);
Okay, so -r*t is between -0.349*1790 and -0.349*1860 which is roughly -624 to -649. And when you exp() those you get values like 1E-280. When you raise a value to that power, you are pretty much raising it to 0, so there will be very little variation in the value of the expression after the k.* so the value of the expression will be essentially constant near the value of k.