Prev: LaplaceTransform for integrodifferential equation with unit step
Next: Mathematica function to calculate correlation coefficient?
From: DOD on 7 Mar 2010 04:04 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?
From: Bob Hanlon on 8 Mar 2010 06:13 d = 7/10; v = 5/100; a = 1/10; nk = (a + (1 - a) k v t)/(d + a + (1 - a) k v t) // Simplify (9*k*t + 20)/(9*k*t + 160) 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*(9*t - 70) - 11200* E^(160/(9*t) + 1)*ExpIntegralEi[ -1 - 160/(9*t)])/(81*t^2) test = FullSimplify[result] -((11200*E^(160/(9*t) + 1)* ExpIntegralEi[-1 - 160/(9*t)])/ (81*t^2)) - 70/(9*t) + 1 root = FindRoot[test == t, {t, .1}] {t -> 0.1420452943881465} Plot[{t, test}, {t, 0, .3}, Epilog -> {Red, AbsolutePointSize[4], Point[{t, t} /. root]}] test - t /. root -4.973799150320701*^-14 Bob Hanlon ---- DOD <dcodea(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?
From: danl on 8 Mar 2010 06:15 > 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? One simple method is to use NIntegrate, restricted so it does not try to evaluate for nonnumeric input. res[t_?NumberQ] := NIntegrate[nk k pg[k], {k, 1, \[Infinity]}]/gavg In[150]:= FindRoot[res[t] == t, {t, .1}] Out[150]= {t -> 0.142045} Can also do this using the original approach with Integrate. In that case I recommend using exact values for the parameters. In[159]:= d = 7/10; v = 1/20; a = 1/10; 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]}]; result = 1/gavg Integrate[nk k pg[k], {k, 1, \[Infinity]}, Assumptions -> 0 < t < 1] FindRoot[result == t, {t, .1}] Out[165]= ( 9 t (-70 + 9 t) - 11200 E^(1 + 160/(9 t)) ExpIntegralEi[-1 - 160/(9 t)])/(81 t^2) Out[166]= {t -> 0.142045} Daniel Lichtblau Wolfram Research
From: David Park on 8 Mar 2010 06:15 This goes much better if you use exact values: d = 7/10; v = 1/20; a = 1/10; nk = (a + (1 - a) k v t)/(d + a + (1 - a) k v t) // Simplify (20 + 9 k t)/(160 + 9 k 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]; f[t_] = result (9 t (-70 + 9 t) - 11200 E^(1 + 160/(9 t)) ExpIntegralEi[-1 - 160/(9 t)])/(81 t^2) Plot[f[t] - t, {t, 0, 0.2}, PlotRange -> Automatic] FindRoot[f[t] == t, {t, .15}] {t -> 0.142045} I tried solving the integral with a, d and v as parameters, and accepting the conditions but that did not work. David Park djmpark(a)comcast.net http://home.comcast.net/~djmpark/ From: DOD [mailto:dcodea(a)gmail.com] 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?
From: DrMajorBob on 8 Mar 2010 06:16
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 <dcodea(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? > > -- DrMajorBob(a)yahoo.com |