Solving a System of Differential Equations - A Step-by-Step Guide

In summary, the conversation discusses solving differential equations and specifically mentions a decay problem. The conversation covers the attempted solution using the Euler method and the correct analytical solution using the characteristic equation. The conversation also provides a perl script to test and illustrate the solutions.
  • #1
Bill Foster
338
0

Homework Statement



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]

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?
 
Physics news on Phys.org
  • #2
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.
 
  • #3
Bill Foster said:

Homework Statement



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]

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:
  • #4
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.
 
  • #5
I guess it wasn't right. If I use different values for the decay constants my analytic solutions differs from the Euler solution.

HallsofIvy said:
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.
 
  • #6
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:
  • #7
Bill Foster said:
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.
 
  • #8
HallsofIvy said:
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.
 
  • #9
Bill Foster said:
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...
 
  • #10
Shouldn't it be : [tex]N = Ae^{\frac{-t}{\tau_b}} [/tex]?
 
  • #11
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:
  • #12
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
 
  • #13
djeitnstine said:
[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.
 
  • #14
Bill Foster said:
There's a problem with this. If [tex]\tau_a = \tau_b[/tex], it blows up.

Yea cus division by 0 doesn't usually go well in math =\
 
  • #15
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)
 
  • #16
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.
 
  • #17
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.
 

1. What is a system of differential equations?

A system of differential equations is a set of equations that describe the relationship between a set of variables and their rates of change. These equations are used to model dynamic systems in various fields such as physics, biology, and engineering.

2. Why is it important to solve a system of differential equations?

Solving a system of differential equations allows us to understand the behavior and predict the future state of a dynamic system. It is essential in many areas of science and engineering, such as studying population growth, predicting weather patterns, and designing control systems.

3. What is the process of solving a system of differential equations?

The process of solving a system of differential equations involves finding the values of the variables that satisfy all the equations in the system. This is usually done by using mathematical techniques such as separation of variables, substitution, or numerical methods.

4. What are the challenges in solving a system of differential equations?

One of the main challenges in solving a system of differential equations is finding an exact solution, which is often not possible for complex systems. Another challenge is choosing the appropriate method and ensuring accuracy in the solution. Additionally, some systems may have multiple solutions or no solutions at all.

5. How can I use the step-by-step guide to solve a system of differential equations?

The step-by-step guide provides a systematic approach to solving a system of differential equations. It outlines the necessary steps and provides examples for each step. By following the guide, you can learn how to set up and solve a system of differential equations using various methods, such as the elimination method or the substitution method.

Similar threads

  • High Energy, Nuclear, Particle Physics
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
1
Views
363
  • Calculus and Beyond Homework Help
Replies
7
Views
79
  • Calculus and Beyond Homework Help
Replies
6
Views
158
  • Classical Physics
Replies
8
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
520
  • Calculus and Beyond Homework Help
Replies
12
Views
924
  • Calculus and Beyond Homework Help
Replies
7
Views
489
  • Calculus and Beyond Homework Help
Replies
7
Views
623
  • Advanced Physics Homework Help
Replies
14
Views
1K
Back
Top