From: dh on
Hi,
the variable "test" contains differences of nearly identical huges
terms. Therefore, machine accuracy is not good enough, your results are
simply calculation errors. You must increase the accuracy.
Daniel


On 07.03.2010 10:04, DOD wrote:
> I have an integral I need to calculate, with one variable left
> symbolic, and then use the result to find a numerical solution to an
> equation, and the result of the integration is not giving me what I
> need:
> ------
> d = .7;
> v = .05;
> a = .1;
> nk = (a + (1 - a) k v t)/(d + a + (1 - a) k v t);
>
> pg[k_] = Exp[1-k];
> gavg = Integrate[k pg[k], {k, 1, \[Infinity]}]; (* This is just 2 *)
> result = 1/gavg Integrate[nk k pg[k], {k, 1, \[Infinity]},
> Assumptions -> 0< t< 1];
> test = FullSimplify[result]
>
> FindRoot[test == t, {t, .1}]
>
> -----
> This code always gives up and stays at the initial guess. So, I look
> at the result of the integration, "result" (or it's simplified
> version, test2) and calculated it for various values of t, and it is
> always zero.
> ----
> test/.t->{.1,.2,.3}
> ----
> Output:{3.36999*10^66, 0., 0.}
> -----
>
> So that's a problem. If I set t=.3, say, and the beginning, and
> calculate the integral, I get 0.160047, which is clearly not zero.
> -----
> d = .7;
> v = .05;
> a = .1;
> t = .3;
> nk = (a + (1 - a) k v t)/(d + a + (1 - a) k v t);
>
> pg[k_] = Exp[1 - k];
> gavg =Integrate[k pg[k], {k, 1, \[Infinity]}];(*This is just 2*)
>
> result = 1/gavg Integrate[nk k pg[k], {k, 1, \[Infinity]}]
> ----
> Output=0.160047
> -----
>
> So there is a problem in the Integrate step. So I want to find a
> point where the output of that integral (result), as a function of t,
> satisfies result=t. Is there anyway to do this using built-in
> functions?
>
>


--

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh(a)metrohm.com>
Internet:<http://www.metrohm.com>


From: DOD on
Thanks for all the tips and explanations. As shown, these methods
work. I actually finally got decent results by doing the integration/
root solving simultaneously:

---
result=NMinimize[{ (1/gavg Integrate[nk k pg[k], {k, 1, \[Infinity]},
Assumptions -> 0 < t < 1] - t)^2,0<t<1} , t];
answer = t/.result[[2]]
---

And this found the t I wanted. This was after haphazard reformulation
of the problem into various forms amenable to various built-in
functions Thanks for these methods and insight into what the problem
was; I need to do this calculation for various parameters (d,v,a), so
any increase in speed is key.




On Mar 8, 5:16 am, DrMajorBob <btre...(a)austin.rr.com> wrote:
> Try this:
>
> {d, v, a} = Rationalize@{.7, .05, .1};
> nk = (a + (1 - a) k v t)/(d + a + (1 - a) k v t);
>
> pg[k_] = Exp[1 - k];
> gavg = Integrate[k pg[k], {k, 1, \[Infinity]}]
>
> 2
>
> result = 1/gavg Integrate[nk k pg[k], {k, 1, \[Infinity]},
> Assumptions -> 0 < t < 1]
>
> (9 t (-70 + 9 t) -
> 11200 E^(1 + 160/(9 t)) ExpIntegralEi[-1 - 160/(9 t)])/(81 t^2)
>
> test = FullSimplify[result]
>
> 1 - 70/(9 t) - (
> 11200 E^(1 + 160/(9 t)) ExpIntegralEi[-1 - 160/(9 t)])/(81 t^2)
>
> FindRoot[test == t, {t, .1}]
>
> {t -> 0.142045}
>
> Bobby
>
>
>
>
>
> On Sun, 07 Mar 2010 03:03:39 -0600, DOD <dco...(a)gmail.com> wrote:
> > I have an integral I need to calculate, with one variable left
> > symbolic, and then use the result to find a numerical solution to an
> > equation, and the result of the integration is not giving me what I
> > need:
> > ------
> > d = .7;
> > v = .05;
> > a = .1;
> > nk = (a + (1 - a) k v t)/(d + a + (1 - a) k v t);
>
> > pg[k_] = Exp[1-k];
> > gavg = Integrate[k pg[k], {k, 1, \[Infinity]}]; (* This is just 2 *)
> > result = 1/gavg Integrate[nk k pg[k], {k, 1, \[Infinity]},
> > Assumptions -> 0 < t < 1];
> > test = FullSimplify[result]
>
> > FindRoot[test == t, {t, .1}]
>
> > -----
> > This code always gives up and stays at the initial guess. So, I look
> > at the result of the integration, "result" (or it's simplified
> > version, test2) and calculated it for various values of t, and it is
> > always zero.
> > ----
> > test/.t->{.1,.2,.3}
> > ----
> > Output:{3.36999*10^66, 0., 0.}
> > -----
>
> > So that's a problem. If I set t=.3, say, and the beginning, and
> > calculate the integral, I get 0.160047, which is clearly not zero.
> > -----
> > d = .7;
> > v = .05;
> > a = .1;
> > t = .3;
> > nk = (a + (1 - a) k v t)/(d + a + (1 - a) k v t);
>
> > pg[k_] = Exp[1 - k];
> > gavg =Integrate[k pg[k], {k, 1, \[Infinity]}];(*This is just 2*)
>
> > result = 1/gavg Integrate[nk k pg[k], {k, 1, \[Infinity]}]
> > ----
> > Output=0.160047
> > -----
>
> > So there is a problem in the Integrate step. So I want to find a
> > point where the output of that integral (result), as a function of t,
> > satisfies result=t. Is there anyway to do this using built-in
> > functions?
>
> --
> DrMajor...(a)yahoo.com