       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 and In 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.
> 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, Out 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.
>
>
>
> In:= Duty = .6; SWfreq = 1*10^6; Vin = 3.2; Vout = 1.8; L =
>  4.7*10^-7; R = 0.008;
>
> In:= Dt1 =
>  Duty (1/SWfreq); Dt2 = (1 - Duty) (1/SWfreq); VL2 = - Vout; VL1 =
>  Vin - Vout; T = 1/SWfreq;
>
> In:= it1 =
>  Simplify[DSolve[{L i1'[t] + R i1[t] - VL1 == 0, i1 == 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 == a1}],
i1[t], t]]

>
> Out= {{i1[t] -> 175.+ (-175. + 1. a1) E^(-17021.3 t)}}
>
> In:= it2 =
>  Simplify[DSolve[{L i2'[t] + R i2[t] - VL2 == 0, i2 == a2}, i2[t],
>    t]]
>
> Out= {{i2[t] -> -225. + (225.+ 1. a2) E^(-17021.3 t)}}
>
> In:= i1[t_] = i1[t] /. it1

Try using i1[t_] = i1[t] /. First[it1] here,

>
> Out= {175.+ (-175. + 1. a1) E^(-17021.3 t)}
>
> In:= i2[t_] = i2[t] /. it2

and i2[t_] = i2[t] /. First[it2] here, and everything will work fine.

>
> Out= {-225. + (225.+ 1. a2) E^(-17021.3 t)}
>
> In:= FindRoot[{i1 == i2[T],
>   i1[Dt1] == i2[Dt1]},
>  {a1, 0}, {a2, 0}]
>
> During evaluation of In:= Thread::tdlen: Objects of unequal length \
> in {0,{-0.983123}}+{{1.,0}} cannot be combined. >>
>
> During evaluation of In:= Thread::tdlen: Objects of unequal length \
> in {{1.,0}}+{0,{-0.983123}} cannot be combined. >>
>
> During evaluation of In:= Thread::tdlen: Objects of unequal length \
> in {0,{-0.989839}}+{{0.989839,0}} cannot be combined. >>
>
> During evaluation of In:= General::stop: Further output of \
> Thread::tdlen will be suppressed during this calculation. >>
>
> During evaluation of In:= FindRoot::njnum: The Jacobian is not a \
> matrix of numbers at {a1,a2} = {0.,0.}. >>
>
> Out= {a1 -> 0., a2 -> 0.}
>

```

• Prev by Date: Re: Applying the Integration Function to a List Of Regions
• Next by Date: Re: Asking NonlinearRegression
• Previous by thread: Re: DSolve question
• Next by thread: Re: DSolve question