Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Avoiding divide by zero error in NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62474] Re: Avoiding divide by zero error in NDSolve
  • From: dh <dh at metrohm.ch>
  • Date: Fri, 25 Nov 2005 02:25:29 -0500 (EST)
  • References: <dm49jj$sul$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
the equation for M can be solved at once: M[t]= k1 t
Simplifying your equations by seeting Nsp=1 k1=1 and using M[t]= k1 t= t 
we get:
t0 = 0;
NDSolve[{t y'[t] + y[t] == 1, y[t0] == 1}, y, {t, t0, 10}]
this gives the 1/0 error.
Setting t0 to 10^-6 eliminates the error.

The reason is that most numeric methods calculate the derivative at the 
starting point. You will convince yourself that the derivative at t=0 is 
not determined by the equation
0 y' +y ==1
It looks like Mathematica is simply solving the equation for y' and 
thereby producing 1/0. That is not too clever, but can be remedied by 
starting not exactly at 0 (this is dangerous, see below).

Further, all your equations have the form:

(k1 t y[t])' = k1 y[t] +  k1 t y'[t] == k1/Nsp  what simplifies to:
y[t] + t y'[t] == const

a solution to this equation is:
y[t]= c0 + c1/t

If x=0 is in the definition region, c1 must be 0 and we have c1=0: 
y[t]== constant, a bit boring.

If x=0 is excluded, we have infinitly many solution for every initial 
value. Such a problem is ill posed!

Therefore, I assume that you have the wrong equations for your chemical 
problem. Either you made a real error or you used an unfitting 
simplification.

sincerely, Daniel

pradeep suresh wrote:
> Hi all,
> I am having this problem of mathematica not letting me specify the exact 
> intial values to a differential equation set. a simple example follws
> 
> Simple Mass Balance Equation set in Chemical Systems.
> 
> Nsp = 5;
> k1 = 100;
> For[i = 1, i < (Nsp + 1), i++, k2[i] = k1/Nsp];
> eqn1 = {D[M[t], t] == k1, M[0] == 0};
> eqn2 = Table[{D[M[t]y[i][t], t] == k2[i],y[i][0] ==k2[i]/k1},{i,Nsp}];
> var1 = Table[y[i][t], {i, Nsp}];
> var2 = Join[{M}, var1];
> sol=NDSolve[{eqn1,eqn2},var2,{t,0,10}]
> 
> Mathematica refuses to solve this system showing error messages of 
> encountering 1/0. If i change the initial condition of M to some 
> arbitrary nonzero value, it is able to solve this system although now 
> the set of equations are practically meaningless for me. Is there any 
> way i can retain the meaning of my equations and still get them solved 
> by mathematica? Plz advice!
> 
> Thanks & Happy thanksgiving,
> Pradeep
> 


  • Prev by Date: Re: Re: Types in Mathematica
  • Next by Date: Re: problems with typesetting in packages
  • Previous by thread: Re: Avoiding divide by zero error in NDSolve
  • Next by thread: Problems with brackets when exporting postscript