using Interpolation to solve ODEs
- To: mathgroup at smc.vnet.net
- Subject: [mg83165] using Interpolation to solve ODEs
- From: "marchriver at gmail.com" <weibinli at gmail.com>
- Date: Tue, 13 Nov 2007 03:44:39 -0500 (EST)
Dear friends I have a coupled ODEs, In[1]:= e1 = x1[t]* (-27 + 4 x1[t]^2) - 4 (1 + x1[t]^2)* y1'[t]; In[2]:= e2 = y1[t] *(-27+ 4 (x1[t]^2 + y1[t]^2)) + 4 (1 + x1[t]^2 + y1[t]^2) *x1'[t]; Given the initial values of x1[0] and y1[0],we can use NDSolve command to solve them In[3]:= s=NDSolve[{e1==0,e2==0,x1[0]==1,y1[0]==0},{x1,y1},{t,0,20}]; Now I want to solve them using another way( Because they are the simplest cases. The actually form I have to deal with can not be obtained obviously). At first I generate the data for the fist part of right hand side(RHS) of e1 as In[4]:= t1 = Flatten[Table[{{x1[t], y1[t]}, x1[t]* (-27 + 4 x1[t]^2)}, {x1[t], 0.2, 2, 0.01}, {y1[t], -2, 2, 0.01}], 1]; then I use Interpation to get a function of x1[t] and y1[t]; In[5]:= it1 = Interpolation[t1]; For the second part of RHS of e1, I only generate the data of coefficient of y1'[t] as In[6]:= t2 = Flatten[Table[{{x1[t], y1[t]}, -4 (1 + x1[t]^2)}, {x1[t], 0.2, 2, 0.01}, {y1[t], -2, 2, 0.01}], 1]; In[7]:= it2 = Interpolation[t2]; The same procedure can be done for e2. In[8]:= t3 = Flatten[Table[{{x1[t], y1[t]}, y1[t] (-g + 4 \[Pi] + 4 \ [Pi] (x1[t]^2 + y1[t]^2))}, {x1[t], 0.2,2, 0.01}, {y1[t], -2, 2, 0.01}], 1]; In[9]:= it3 = Interpolation[t3]; In[10]:= t4 = Flatten[Table[{{x1[t], y1[t]}, 4 \[Pi] (1 + x1[t]^2 + y1[t]^2)}, {x1[t], 0.2, 2, 0.01}, {y1[t], -2, 2, 0.01}], 1]; In[11]:= it4 = Interpolation[t3]; And I solve them use NDSolve In[12]:= inters = NDSolve[{it1[x1[t], y1[t]] +it2[x1[t], y1[t]]*y1'[t] == 0, it3[x1[t], y1[t]] + it4[x1[t], y1[t]]*x1'[t]== 0], x1[0] == 1, y1[0] == 0}, {x1, y1}, {t, 0, 10}]; But the two results ("s" and "inters") are different. Actually, "inters" is wrong! Any one can help figuring out this problem? Or tell me if mathematica can solve ODE problems using data-interpolating? Thanks a lot Teddy weibinli at gmail.com