Note: this is mathematics question but necessarily involves some non mathematical concepts. I hope that we can consider it to be a good fit for this site. If not, happy to close, and it will still have been a worthwhile exercise to write it all out anyway.
I suddenly have a lot of free time and I feel like making 'something'. I decided to create a simulation of sorts. As part of this I need to model simple people. 3 of the attributes that describe a person are:
- Nutrition ($N$) - passively decays over time but can be increased when a person eats
- Energy ($E$) - passively decays while a person is awake. Can increase when a person is sleeping
- Health ($H$) - can increase or decrease depending on state of $N$ and $E$.
I would like to have a system of differential equations that governs the interaction of these variables. I suspect that I only need help with one of them, and once I have practiced the technique I should be OK to handle the others on my own. So with that in mind, I will focus on $E$ (during the awake state) here. Note: I would prefer to have continuous functions come out of this. So no max or min functions.
Properties
- All variables are strictly between 0 and 1.
- $E$ always decays over time.
- $E$ has a long term upper bound of $H$. A healthier person has a higher capacity for energy reserves. So if a person ends up in a situation when $E>H$ (presumably because $H$ was impacted by some event) then $E$ should decay rapidly.
- A person with high $H$, high $N$ and high $E$ should have a low decay rate.
- A person with low $E$ should have a low decay rate, since $E$ cannot be negative.
- All else being equal, low $N$ leads to higher decay rate of $E$. A starving person runs out of energy faster.
From here on is where I need help
Formal properties (attempted)
- This is already formal enough
- $\frac{\partial E}{\partial t} < 0$ (easy)
- Starts to get tricky. Is this saying something about $\frac{\partial^2E}{\partial t\partial H}$ or $\frac{\partial^2E}{\partial t^2}$? Maybe $\frac{\partial^2E}{\partial t\partial H}\propto H-E = a(H-E)$ so that if $E>H$ then this is negative but otherwise positive. Need to be careful that this doesn't cause a violation of property 2 though.
4, 5 and 6 seem to be related to a single formal property. Are these saying something about $\frac{\partial^3E}{\partial t \partial H \partial N}$ or $\frac{\partial^2E}{\partial t \partial H}+\frac{\partial^2E}{\partial t \partial N}$
I'm hoping that once I can express these formal properties I can then integrate as far as they will go analytically and hopefully end up with an expression for $\frac{\partial E}{\partial t}$.
My candidate answer (I will promote to accepted answer if no-one raises any valid objections after some time).
To satisfy properties 1 and 3, I decided to employ a sigmoid transformation $E=S(F,H)$ so that $F$ can take on any real value and $S$ will convert it to a value between $0$ and $H$. I can then model $F$ as a simpler function $F(t, N, H)$.
Next step is to decompose changes in $F$. $$dF(t,N,H)=\frac{\partial F}{\partial t}dt+\frac{\partial F}{\partial N}dN+\frac{\partial F}{\partial H}dH$$
I can't see how there is any use for the last 2 terms so then I only need to worry about how $\frac{\partial F}{\partial t}$ evolves. Not sure if the following notation is OK but here goes.
$$d\frac{\partial F}{\partial t}(t,N,H)=\frac{\partial^2 F}{\partial t^2}dt+\frac{\partial^2 F}{\partial t \partial N}dN+\frac{\partial^2 F}{\partial t\partial H}dH$$
I don't think I need $\frac{\partial^2 F}{\partial t^2}$ for anything and the other 2 can be constants to be tuned later. $$d\frac{\partial F}{\partial t}(t,N,H)=a.dN+b.dH$$ where $a, b > 0$. To get an expression for $\frac{\partial F}{\partial t}$ I integrate the components
$$\frac{\partial F}{\partial t}=\int a.dN+\int b.dH=aN+bH+c$$ where $c$ is another tune-able parameter.
Then we have
$$\Delta F(t, \Delta t,N,H)=\int_t^{t+\Delta t}(aN+bN+c)dt=(aN+bH+c)\Delta t$$
and finally $$F_{t+\Delta t}=F_t+(aN+bH+c)\Delta t$$