ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 29 Jul 2016 04:01:44 -0500using logistic differential equatin (reproducing Ti Nspire CAS code)https://ask.sagemath.org/question/34269/using-logistic-differential-equatin-reproducing-ti-nspire-cas-code/I’m trying to reproduce some results from [Ti Nspire CAS](https://en.wikipedia.org/wiki/TI-Nspire_series#TI-Nspire_CAS) to *use* a differential equation. Only secondarily am I interested to actually solve the differential equation.
My Ti Nspire codes is as follows
deSolve(y’ = 2*10^(-5)*y(1500-y) and y(0) = 50, t, y)
and yields the following result
y = 1500*e^((3*t)/100) / (e^((3*t)/100) + 29)
![image description](http://i.stack.imgur.com/Raz6r.png)
Can anyone give me a hit as to how I can do this in Sagemath?Fri, 29 Jul 2016 02:43:11 -0500https://ask.sagemath.org/question/34269/using-logistic-differential-equatin-reproducing-ti-nspire-cas-code/Answer by mforets for <p>I’m trying to reproduce some results from <a href="https://en.wikipedia.org/wiki/TI-Nspire_series#TI-Nspire_CAS">Ti Nspire CAS</a> to <em>use</em> a differential equation. Only secondarily am I interested to actually solve the differential equation.</p>
<p>My Ti Nspire codes is as follows</p>
<pre><code>deSolve(y’ = 2*10^(-5)*y(1500-y) and y(0) = 50, t, y)
</code></pre>
<p>and yields the following result</p>
<pre><code>y = 1500*e^((3*t)/100) / (e^((3*t)/100) + 29)
</code></pre>
<p><img alt="image description" src="http://i.stack.imgur.com/Raz6r.png"/></p>
<p>Can anyone give me a hit as to how I can do this in Sagemath?</p>
https://ask.sagemath.org/question/34269/using-logistic-differential-equatin-reproducing-ti-nspire-cas-code/?answer=34270#post-id-34270 t = var('t')
y = function('y')(t)
ye = desolve(diff(y,t) == 2*10^(-5)*y*(1500-y), y, ics=[0,50])
ye = ye*3/100
yt = solve(ye.simplify_log(), y)
yt
$$
\newcommand{\Bold}[1]{\mathbf{#1}}\left[y\left(t\right) = \frac{1500 e^{\left(\frac{3}{100} t\right)}}{e^{\left(\frac{3}{100} t\right)} + 29}\right]
$$
*Remark*. Here I multiplied by $3/100$, since otherwise the simplify_log() was not factoring the terms containing $y(t)$. For instance,
f = 2*log(x) - 2*log(x-1)
f.simplify_log()
gives $\log(x^2/(x-1)^2)$, but
f = 1/3*log(x) - 1/3*log(x-1)
f.simplify_log()
gives $-\frac{1}{3}\log(x-1) + \frac{1}{3}\log(x)$, instead of $\frac{1}{3}\log(x/(x-1))$ (and in the first case I would prefer to get rather $2\log(x/(x-1))$; neither factor() nor simplify_full() do it -- why?).Fri, 29 Jul 2016 03:56:16 -0500https://ask.sagemath.org/question/34269/using-logistic-differential-equatin-reproducing-ti-nspire-cas-code/?answer=34270#post-id-34270Comment by etb for <pre><code>t = var('t')
y = function('y')(t)
ye = desolve(diff(y,t) == 2*10^(-5)*y*(1500-y), y, ics=[0,50])
ye = ye*3/100
yt = solve(ye.simplify_log(), y)
yt
</code></pre>
<p>$$
\newcommand{\Bold}[1]{\mathbf{#1}}\left[y\left(t\right) = \frac{1500 e^{\left(\frac{3}{100} t\right)}}{e^{\left(\frac{3}{100} t\right)} + 29}\right]
$$</p>
<p><em>Remark</em>. Here I multiplied by $3/100$, since otherwise the simplify_log() was not factoring the terms containing $y(t)$. For instance, </p>
<pre><code>f = 2*log(x) - 2*log(x-1)
f.simplify_log()
</code></pre>
<p>gives $\log(x^2/(x-1)^2)$, but</p>
<pre><code>f = 1/3*log(x) - 1/3*log(x-1)
f.simplify_log()
</code></pre>
<p>gives $-\frac{1}{3}\log(x-1) + \frac{1}{3}\log(x)$, instead of $\frac{1}{3}\log(x/(x-1))$ (and in the first case I would prefer to get rather $2\log(x/(x-1))$; neither factor() nor simplify_full() do it -- why?).</p>
https://ask.sagemath.org/question/34269/using-logistic-differential-equatin-reproducing-ti-nspire-cas-code/?comment=34271#post-id-34271Thanks a lot. I cannot answer your question, but I'll get back to you here if I find an answer to that.Fri, 29 Jul 2016 04:01:44 -0500https://ask.sagemath.org/question/34269/using-logistic-differential-equatin-reproducing-ti-nspire-cas-code/?comment=34271#post-id-34271