Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: DSolve question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88764] Re: DSolve question
  • From: dh <dh at metrohm.ch>
  • Date: Fri, 16 May 2008 05:30:11 -0400 (EDT)
  • References: <g0h82g$mu1$1@smc.vnet.net>


Hi,

DSolve always gives a list of possible solutions, even if there is only 

one. Therefore, your functions are lists and not scalars. E.g. look at 

Out[5]. You can fix this by taking the first elemenbt. E.g.:

i1[t_] = (i1[t] /. it1)[[1]]

or you can pick the first element when you define it1.

With this fix, everything should work as expected.

hope this helps, Daniel



ood 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]]

> 

> 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

> 

> Out[5]= {175.+ (-175. + 1. a1) E^(-17021.3 t)}

> 

> In[6]:= i2[t_] = i2[t] /. it2

> 

> 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.}

> 




  • Prev by Date: Re: Linking EventHandler to a Control Object
  • Next by Date: Re: Expression manipulation
  • Previous by thread: Re: DSolve question
  • Next by thread: Re: DSolve question