Re: DSolve question
- To: mathgroup at smc.vnet.net
- Subject: [mg88751] Re: DSolve question
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Fri, 16 May 2008 05:27:41 -0400 (EDT)
- Organization: University of Bergen
- References: <g0h82g$mu1$1@smc.vnet.net>
igwood wrote: > Hi everyone. I'm looking for help using the result of DSolve. > In the code below the DSolve statements in In[3] and In[4] find i1[t] and i2[t] respectively in terms of variable t and a constant a1, a2 respectively. Then, numerical values for a1 and a2 will be found by simultaneous equations equating i1[t] and i2[t] in the FindRoot statement in In[7]. > However, I havenâ??t been able to make Mathematica relate the i1[t], i2[t] in FindRoot to the i1[t], i2[t] resulting from DSolve. Iâ??ve tried several ways and finally the way below and always get errors. > On the other hand if I COPY and PASTE the DSolve output Out[3], Out[4] following the -> into the lhs of i1[t] = lhs, then the FindRoot gives me the a1, and similar for a2.. > If anyone can instruct me on how to get the FindRoot to recognize the i1[t], i2[t] found from DSolve I would appreciate it. I guess in other words, how do I get output of DSolve to be a usable function. > > In my own reply to this post I will paste the example of the code where COPY/PASTE has been used as described above to give numerical values for a1, a2. > > Thanks in advance. > > > In[1]:= Duty = .6; SWfreq = 1*10^6; Vin = 3.2; Vout = 1.8; L = > 4.7*10^-7; R = 0.008; > > In[2]:= Dt1 = > Duty (1/SWfreq); Dt2 = (1 - Duty) (1/SWfreq); VL2 = - Vout; VL1 = > Vin - Vout; T = 1/SWfreq; > > In[3]:= it1 = > Simplify[DSolve[{L i1'[t] + R i1[t] - VL1 == 0, i1[0] == a1}, i1[t], > t]] This is unrelated to the question, but it's probably better to work with exact numbers when using DSolve. I don't know if inexact numbers can cause trouble with DSolve, but I know that they can be a problem for Solve when using certain settings and DSolve does use Solve internally (or at least it does emit Solve::* messages sometimes). So this is a bit better/safer: it1 = Simplify[ DSolve[Rationalize[{L i1'[t] + R i1[t] - VL1 == 0, i1[0] == a1}], i1[t], t]] > > Out[3]= {{i1[t] -> 175.+ (-175. + 1. a1) E^(-17021.3 t)}} > > In[4]:= it2 = > Simplify[DSolve[{L i2'[t] + R i2[t] - VL2 == 0, i2[0] == a2}, i2[t], > t]] > > Out[4]= {{i2[t] -> -225. + (225.+ 1. a2) E^(-17021.3 t)}} > > In[5]:= i1[t_] = i1[t] /. it1 Try using i1[t_] = i1[t] /. First[it1] here, > > Out[5]= {175.+ (-175. + 1. a1) E^(-17021.3 t)} > > In[6]:= i2[t_] = i2[t] /. it2 and i2[t_] = i2[t] /. First[it2] here, and everything will work fine. > > Out[6]= {-225. + (225.+ 1. a2) E^(-17021.3 t)} > > In[7]:= FindRoot[{i1[0] == i2[T], > i1[Dt1] == i2[Dt1]}, > {a1, 0}, {a2, 0}] > > During evaluation of In[7]:= Thread::tdlen: Objects of unequal length \ > in {0,{-0.983123}}+{{1.,0}} cannot be combined. >> > > During evaluation of In[7]:= Thread::tdlen: Objects of unequal length \ > in {{1.,0}}+{0,{-0.983123}} cannot be combined. >> > > During evaluation of In[7]:= Thread::tdlen: Objects of unequal length \ > in {0,{-0.989839}}+{{0.989839,0}} cannot be combined. >> > > During evaluation of In[7]:= General::stop: Further output of \ > Thread::tdlen will be suppressed during this calculation. >> > > During evaluation of In[7]:= FindRoot::njnum: The Jacobian is not a \ > matrix of numbers at {a1,a2} = {0.,0.}. >> > > Out[7]= {a1 -> 0., a2 -> 0.} >