```Path: news.mathworks.com!not-for-mail
From: "rasika " <n.rasika@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solving eqn in matlab
Date: Thu, 10 Nov 2011 07:45:14 +0000 (UTC)
Organization: Missouri University of Science &#38; Technology
Lines: 118
Message-ID: <j9fvea\$pn3\$1@newscl01ah.mathworks.com>
References: <j9ac4r\$6b3\$1@newscl01ah.mathworks.com> <4EB9281A.9070102@mathworks.com> <90bc76a0-d5d0-49fc-b8a4-9ec56d4079c5@l24g2000yqm.googlegroups.com> <j9d9qt\$s2a\$1@newscl01ah.mathworks.com> <4EBA7765.6050601@mathworks.com> <j9f80a\$j0q\$1@newscl01ah.mathworks.com>
Reply-To: "rasika " <n.rasika@gmail.com>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1320911114 26339 172.30.248.35 (10 Nov 2011 07:45:14 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 10 Nov 2011 07:45:14 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:748938

Can anyone please let me know how to solve the following using lambertw.. it is the same expression, just unsimplified version
exp(K1*X)+b*X^K2(1-K3)=K3*exp(K4)
and K1=3.5*10^-10*(50-R)
K2=-2.5
K3=(Is/Intensity)
K4=-0.079*(50-R)
Can you tell me how to solve this using lambertw?
Is=260
I=[111 8.6 8.4 8.3]';
R=[0:1:37]';
are the values in actual problem,
But for single values like

"rasika " <n.rasika@gmail.com> wrote in message <j9f80a\$j0q\$1@newscl01ah.mathworks.com>...
> Hello Christopher,
> Sorry for not putting in the complete variables,
> this the code which is currently working for me
> syms con
> A=0.079;
> B=6*10^-9;
> C=3.5*10^-10;
> R=37;
> Is=260;
> Intensity=8.6
> v=1+C*(50-37)*con+((C^2*(50-R)^2*con^2)/2)+((C^3*(50-R)^3*con^3)/6)+B*con^-2.5*(1-(Is/Intensity))-(Is/Intensity)*exp(-A*(50-R));
>
> solve(v,con)
> but it is giving out all the possible roots like this
> ans =
>
>                                                 596301325.91576234164749415177267
>                                                 596301325.91576234164749415177148
>                                             0.00079574777275045645780180143342736
>           802746443.11830032332298137638464*i - 627820992.62821082772870512092314
>         - 802746443.11830032332298137638456*i - 627820992.62821082772870512092287
>           802746443.11830032332298137638455*i - 627820992.62821082772870512092287
>   0.00024589958501577221974263913391303 - 0.00075680110460163359394390295539747*i
>  - 0.0004677288053671182188217140940646*i - 0.00064377347139100044864353985062671
>    0.0004677288053671182188217140940646*i - 0.00064377347139100044864353985062671
>   0.00075680110460163359394390295539747*i + 0.00024589958501577221974263913391303
>         - 802746443.11830032332298137638464*i - 627820992.62821082772870512092314
>
> >> double(ans)
>
> ans =
>
>   1.0e+008 *
>
>    5.9630
>    5.9630
>    0.0000
>   -6.2782 + 8.0275i
>   -6.2782 - 8.0275i
>   -6.2782 + 8.0275i
>    0.0000 - 0.0000i
>   -0.0000 - 0.0000i
>   -0.0000 + 0.0000i
>    0.0000 + 0.0000i
>   -6.2782 - 8.0275i
>
> >> real(ans)
>
> ans =
>
>   1.0e+008 *
>
>     5.9630
>     5.9630
>     0.0000
>    -6.2782
>    -6.2782
>    -6.2782
>     0.0000
>    -0.0000
>    -0.0000
>     0.0000
>    -6.2782
>  Now what i need is a a single value of con for a single value of Intensity I.
> Intensity can be a vector like = [111 8.6 8.5 8.4]'
>
> but for one single value it is giving out so many roots,
>  and I have like 100-1000s of values of Intensity, like a bulk data set. Hence I wish to write a code where
> 1. It will store ans in an array
> 2.check each element for double and change datatype
> 2. check for real roots ( and not the real part of the complex roots as it has done for me above)
> 3. Check for positive roots
> 4. Check for repeated values
> 5. Except for the first value check for >10^8 range
>  apply all these filters and just get me one value.
>  Please help me with that , this would almost be the exact algo i need to follow.
>  Thanks
>
> Christopher Creutzig <Christopher.Creutzig@mathworks.com> wrote in message <4EBA7765.6050601@mathworks.com>...
> > On 09.11.11 08:24, rasika wrote:
> > > also I need only real values and most of them above 10^8 range, how should I set a loop for that?
> >
> > syms con real
> >
> > will tell the system to only consider real values.
> >
> > syms con positive
> >
> > will do the same to restrict to positive values.
> >
> > evalin(symengine, 'assume(con > 10^8)')
> >
> > will limit con to real numbers larger than 1e8.
> >
> >
> > Invoking real() on a solution set will not remove the complex solutions,
> > but project them onto the real axis, which hardly ever results in a
> > solution. That's probably not useful.
> >
> >
> > Christopher
```