Differential equation

1. The problem statement, all variables and given/known data

I'm pretty rusty at these. But given the following:

[tex]\frac{dN_a}{dt}=-\frac{N_a}{\tau_a}[/tex]
[tex]\frac{dN_b}{dt}=\frac{N_a}{\tau_a}-\frac{N_b}{\tau_b}[/tex]

3. The attempt at a solution

The first one, naturally, is easy [tex]N_a(t)=N_a(0)e^\frac{-t}{\tau_a}[/tex]

The second one is giving me a little trouble.

I tried it as such:

[tex]\frac{dN_b}{dt}=\frac{N_a\tau_b-N_b\tau_a}{\tau_a \tau_b}[/tex]

[tex]\frac{dN_b}{N_a\tau_b-N_b\tau_a}=\frac{dt}{\tau_a \tau_b}[/tex]

Let [tex]x=N_a\tau_b-N_b\tau_a[/tex]

[tex]dx=-dN_b\tau_a[/tex]

[tex]\frac{dx}{x\tau_a}=\frac{dt}{\tau_a \tau_b}[/tex]

[tex]\frac{dx}{x}=\frac{dt}{\tau_b}[/tex]

[tex]x(t)=x_0e^\frac{-t}{\tau_b}[/tex]

[tex]N_a\tau_b-N_b\tau_a=x_0e^\frac{-t}{\tau_b}[/tex]

[tex]N_b\tau_a=N_a\tau_b-x_0e^\frac{-t}{\tau_b}[/tex]

[tex]N_b(t)=\frac{N_a\tau_b-x_0e^\frac{-t}{\tau_b}}{\tau_a}[/tex]

Now, at [tex]t=0[/tex], [tex]N_b(t=0)=N_{b0}[/tex]

So [tex]x_0=N_a\tau_b-N_{b0}\tau_a[/tex]

[tex]N_b(t)=\frac{N_a\tau_b-(N_a\tau_b-N_{b0}\tau_a)e^\frac{-t}{\tau_b}}{\tau_a}[/tex]

But I don't think that's right because it blows up. It's supposed to be a decay problem.

Did I solve it correctly?
 
I believe that is right.

Now I'm trying to solve it using the Euler method...

[tex]N_b(t+\Delta{t})=N_b(t)-\Delta{t}*\frac{dN_b}{dt}[/tex]

I get: [tex]N_b(t+\Delta{t})=N_b(t)-\Delta{t}*(\frac{N_a}{\tau_a}-\frac{N_b}{\tau_b})[/tex]

And THAT blows up.
 

HallsofIvy

Science Advisor
41,626
821
1. The problem statement, all variables and given/known data

I'm pretty rusty at these. But given the following:

[tex]\frac{dN_a}{dt}=-\frac{N_a}{\tau_a}[/tex]
[tex]\frac{dN_b}{dt}=\frac{N_a}{\tau_a}-\frac{N_b}{\tau_b}[/tex]

3. The attempt at a solution

The first one, naturally, is easy [tex]N_a(t)=N_a(0)e^\frac{-t}{\tau_a}[/tex]

The second one is giving me a little trouble.

I tried it as such:

[tex]\frac{dN_b}{dt}=\frac{N_a\tau_b-N_b\tau_a}{\tau_a \tau_b}[/tex]
Instead use the solution to the first equation to write the equation as
[tex]\frac{dN_b}{dt}=\frac{N_a(0)}{\tau_a}e^\frac{-t}{\tau_a}-\frac{N_b}{\tau_b}[/tex]
[tex]\frac{dN_b}{dt}+ \frac{N_b}{\tau_b}= \frac{N_a(0)}{\tau_a}e^\frac{-t}{\tau_a}[/tex]

That's a linear non-homogeneous differential equation with constant coefficients. Its characteristic equation is [tex]r+ \frac{r}{\tau_b}= 0[/tex] and you can look for a specific solution of the entire equation of the form [tex]Ae^\frac{-t}{\tau_a}[/tex].

You will find that has solutions with decreasing exponentials.


[tex]\frac{dN_b}{N_a\tau_b-N_b\tau_a}=\frac{dt}{\tau_a \tau_b}[/tex]

Let [tex]x=N_a\tau_b-N_b\tau_a[/tex]

[tex]dx=-dN_b\tau_a[/tex]

[tex]\frac{dx}{x\tau_a}=\frac{dt}{\tau_a \tau_b}[/tex]

[tex]\frac{dx}{x}=\frac{dt}{\tau_b}[/tex]

[tex]x(t)=x_0e^\frac{-t}{\tau_b}[/tex]

[tex]N_a\tau_b-N_b\tau_a=x_0e^\frac{-t}{\tau_b}[/tex]

[tex]N_b\tau_a=N_a\tau_b-x_0e^\frac{-t}{\tau_b}[/tex]

[tex]N_b(t)=\frac{N_a\tau_b-x_0e^\frac{-t}{\tau_b}}{\tau_a}[/tex]

Now, at [tex]t=0[/tex], [tex]N_b(t=0)=N_{b0}[/tex]

So [tex]x_0=N_a\tau_b-N_{b0}\tau_a[/tex]

[tex]N_b(t)=\frac{N_a\tau_b-(N_a\tau_b-N_{b0}\tau_a)e^\frac{-t}{\tau_b}}{\tau_a}[/tex]

But I don't think that's right because it blows up. It's supposed to be a decay problem.

Did I solve it correctly?
 
Last edited by a moderator:
Finally got it right. I was right with my analytical solution, except for some sign errors. And it checks out with the Euler method solution. Here's a perl script that I wrote to test and illustrate:

Code:
#!/usr/bin/perl 

$dt=0.01;
$t=0;
$ta=1;
$tb=2;
$Na0=100;
$Nb0=0;
$Nae=$Na0;
$Nbe=$Nb0;
$i=0;
$imax=20;

for($i=0;$i<=$imax/$dt;$i++)
{
	$t=$i*$dt;
	$Na=$Na0*exp(-$t/$ta);
	$Nb=-($Na*$tb-($Na0*$tb+$Nb0*$ta)*exp(-$t/$tb))/$ta;
	if($i > 0)
	{
		$Nae=$Nae-$dt*$Nae/$ta;
		$Nbe=$Nbe+($Nae/$ta-$Nbe/$tb)*$dt;
	}
	printf("%f %f %f %f %f\n",$t,$Na,$Nae,$Nb,$Nbe);
}
Thanks for your input.
 
I guess it wasn't right. If I use different values for the decay constants my analytic solutions differs from the Euler solution.

Instead use the solution to the first equation to write the equation as
[tex]\frac{dN_b}{dt}=\frac{N_a(0)}{\tau_a}e^\frac{-t}{\tau_a}-\frac{N_b}{\tau_b}[/tex]
[tex]\frac{dN_b}{dt}+ \frac{N_b}{\tau_b}= \frac{N_a(0)}{\tau_a}e^\frac{-t}{\tau_a}[/tex]

That's a linear non-homogeneous differential equation with constant coefficients. Its characteristic equation is [tex]r+ \frac{r}{\tau_b}= 0[/tex] and you can look for a specific solution of the entire equation of the form [tex]Ae^\frac{-t}{\tau_a}[/tex].

You will find that has solutions with decreasing exponentials.
I don't know how to solve that.
 

djeitnstine

Gold Member
614
0
The solution to the characteristic equation posted is the argument of an exponential [tex]e^{\frac{1}{\tau_{b}}}[/tex]. This added with the particular solution of the form [tex]Ae^{\frac{-t}{\tau_{a}}}[/tex] will give you your general solution.

Solving for the particular. Simply take the solution of the form [tex]Ae^{\frac{-t}{\tau_{a}}}[/tex], differentiate it, add them together and solve for the coefficients.

I'll get you started:

[tex]N = Ae^{\frac{-t}{\tau_a}}[/tex]
[tex]N'= \frac{-1}{\tau_{a}}Ae^{\frac{-t}{\tau_{a}}}[/tex]

Sum them [tex]N'+\frac{N}{\tau_{b}} = \frac{-1}{\tau_{a}}Ae^{\frac{-t}{\tau_{a}}}+\frac{1}{\tau_{b}}Ae^{\frac{-t}{\tau_{a}}}[/tex]

Solve for coefficients [tex]A(\frac{-1}{\tau_{a}}+\frac{1}{\tau_{b}})= \frac{N_{a}(0)}{\tau_{b}}[/tex] and
 
Last edited:

HallsofIvy

Science Advisor
41,626
821
I guess it wasn't right. If I use different values for the decay constants my analytic solutions differs from the Euler solution.



I don't know how to solve that.
What course is this for then? It is now a single non-homogeneous linear equation with constant coefficients. Much simpler than the original problem and much simpler than what you were trying to do.
 
What course is this for then? It is now a single non-homogeneous linear equation with constant coefficients. Much simpler than the original problem and much simpler than what you were trying to do.
Computational Physics.

The problem is to approximate the original system of differential equations using the Euler method, which I can do.

I am now trying to solve it analytically so I can compare it with the Euler solution.
 

djeitnstine

Gold Member
614
0
Computational Physics.

The problem is to approximate the original system of differential equations using the Euler method, which I can do.

I am now trying to solve it analytically so I can compare it with the Euler solution.
Take a look at how I solved it...
 
Shouldn't it be : [tex]N = Ae^{\frac{-t}{\tau_b}} [/tex]?
 

djeitnstine

Gold Member
614
0
No. Halls of Ivy showed you this result,

[tex]
\frac{dN_b}{dt}=\frac{N_a(0)}{\tau_a}e^\frac{-t}{\tau_a}-\frac{N_b}{\tau_b}
[/tex]

Which in turn becomes

[tex]
\frac{dN_b}{dt}+ \frac{N_b}{\tau_b}= \frac{N_a(0)}{\tau_a}e^\frac{-t}{\tau_a}
[/tex]

using this result, we get a non-homogeneous [tex]2^{nd}[/tex] order differentual equation with a particular solution [tex] Ae^{\frac{-t}{\tau_{a}}}[/tex]

So we get a particular solution [tex]N_{p} = Ae^{\frac{-t}{\tau_{a}}}[/tex]

then, [tex]N'=\frac{-1}{\tau_{a}}Ae^{\frac{-t}{\tau_{a}}} [/tex]

We sum the 2 with your coefficient: [tex]N'+\frac{N}{\tau_{b}} = \frac{-1}{\tau_{a}}Ae^{\frac{-t}{\tau_{a}}}+\frac{1}{\tau_{b}}Ae^{\frac{-t}{\tau_{a}}} [/tex]

Of course we solve for the coefficient A: [tex] A(\frac{-1}{\tau_{a}}+\frac{1}{\tau_{b}})= \frac{N_{a}(0)}{\tau_{b}} [/tex]

Lets get a decent looking fraction first [tex] A(\frac{\tau_{a} - \tau_{b}}{\tau_{a} \tau_{b}})= \frac{N_{a}(0)}{\tau_{b}} [/tex]

[tex] A = \frac{N_{a}(0)\tau_{a} \tau_{b}}{\tau_{b} (\tau_{a} - \tau_{b})} [/tex]

[tex]N_{p}=\frac{N_{a}(0) \tau_{a} \tau_{b} e^{\frac{-t}{\tau_{a}}}}{\tau_{b} (\tau_{a} - \tau_{b})}[/tex]
We have only solved the particular equation. Now we have to add it to the homogeneous equation.

The characteristic is as Ivy showed is [tex] r+ \frac{1}{\tau_b}= 0 [/tex] Thus your [tex]N_{h} [/tex] homogeneous is [tex] N_{h}= C_{1}e^{\frac{-t}{\tau_{b}}[/tex]

Now summing them to get a general solution...[tex]N_{g}=N_{h}+N_{p}[/tex] gives

[tex]N_{g}= C_{1} e^{\frac{-t}{\tau_{b}}} + \frac{N_{a}(0) \tau_{a} \tau_{b} }{\tau_{b} (\tau_{a} - \tau_{b})}e^{\frac{-t}{\tau_{a}}}[/tex]

Now use your initial conditions to find [tex]C_1[/tex]
 
Last edited:
Well, that's quite a bit different than what I just got:

[tex]N_b(t)=[N_b(0)-\tau_aN_a(0)]e^{-\frac{t}{\tau_b}}-\tau_aN_a(0)e^{-\frac{t}{\tau_a}}[/tex]

Hmmm
 
[tex]N_{g}= C_{1} e^{\frac{-t}{\tau_{b}}} + \frac{N_{a}(0) \tau_{a} \tau_{b} }{\tau_{b} (\tau_{a} - \tau_{b})}e^{\frac{-t}{\tau_{a}}}[/tex]

Now use your initial conditions to find [tex]C_1[/tex]
There's a problem with this. If [tex]\tau_a = \tau_b[/tex], it blows up.
 

djeitnstine

Gold Member
614
0

djeitnstine

Gold Member
614
0
Oh man I got mixed up with all these tau sub a's and tau sub b's the final answer is
[tex]N_{g}= C_{1} e^{\frac{-t}{\tau_{b}}} + \frac{N_{a}(0) \tau_{a} \tau_{b} }{\tau_{a} (\tau_{a} - \tau_{b})}e^{\frac{-t}{\tau_{a}}}[/tex]

(its the little [tex]\tau_{b}[/tex] before the bracket in the denominator that's wrong)
 
Final solution that matches the Euler solution:

[tex]N_b(t)=(N_b(0)-\frac{\tau_b}{\tau_a-\tau_b}N_a(0))e^{-\frac{t}{\tau_b}}+\frac{\tau_b}{\tau_a-\tau_b}N_a(0))e^{-\frac{t}{\tau_A}}[/tex]

But what can I do about that condition when [tex]\tau_a=\tau_b[/tex]?

The function should not blow up.
 

djeitnstine

Gold Member
614
0
Check that condition on your original DE, then compare that result with the actual answers. Basically check to see if any other solutions were lost.
 

The Physics Forums Way

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top