MathGroup Archive 2009

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

Search the Archive

Re: Applying lists to FindRoot of a NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101330] Re: [mg101284] Applying lists to FindRoot of a NIntegrate
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Wed, 1 Jul 2009 06:36:20 -0400 (EDT)
  • References: <200906301031.GAA10499@smc.vnet.net>
  • Reply-to: drmajorbob at bigfoot.com

I wasn't able to devise data for which the equations seemed solvable, but  
the basic idea would be something like

f[r_] = r^2 + r + 2/(r^2 + r);
g[r_, x_, a_] = Exp[a*Exp[-x*r]];
w[x_?NumericQ, a_?NumericQ] :=
  NIntegrate[f[r]*g[r, x, a], {r, 0.1, 100}]
solve1[x_?NumericQ, y_?NumericQ] :=
  Module[{a}, a /. NSolve[w[x, a] == y, a]]
solve2[a0_?NumericQ][x_?NumericQ, y_?NumericQ] :=
  Module[{a}, a /. FindRoot[w[x, a] - y, {a, a0}]]
  Module[{a}, a /. FindRoot[w[x, a] - y, {a, a0}]]

data = {{1, 2}, {1.1, 3}, {1.2, 5}};

solve1 @@@ data

(* error messages omitted *)

{{InverseFunction[w, 2, 2][1,
    2.0000000000000000000000000000000]}, {InverseFunction[w, 2, 2][1.1,
     3.0000000000000000000000000000000]}, {InverseFunction[w, 2, 2][
    1.2, 5.0000000000000000000000000000000]}}

solve2[1] @@@ data

{-1.75308*10^44, -3.60158*10^48, -7.2559*10^52}

solve2 (and FindRoot) need an initial guess, preferably a good one. (I  
used 1.) Judge for yourself whether those are reasonable results.

OTOH, I doubt that NSolve will work at all. It's intended for polynomial  
equations.

Bobby

On Wed, 01 Jul 2009 01:18:09 -0500, Christian Schneider <Kofferpc at gmx.net>  
wrote:

> Hi Bobby,
>
>
> First of all, thanks a lot for your answer and for your time spent to  
> look
> into my problrm!
>
> Well, the list consists of pairs of data points, something like  
> data={{1,2},
> {1.1,3}, {1.2,5},..., {x[[i]],y[[i]]}}. These are my input for the  
> fitting
> of the corresponding values of a.
>
>
> Chris
>
>
> -----Ursprüngliche Nachricht-----
> Von: DrMajorBob [mailto:btreat1 at austin.rr.com]
> Gesendet: Dienstag, 30. Juni 2009 20:07
> An: Christian Schneider; mathgroup at smc.vnet.net
> Betreff: Re: [mg101284] Applying lists to FindRoot of a NIntegrate  
> function
>
> See the list of data points?
>
> I don't.
>
> Bobby
>
> On Tue, 30 Jun 2009 05:31:56 -0500, Christian Schneider  
> <kofferpc at gmx.net>
> wrote:
>
>> Dear members of the mathgroup email group,
>>
>> I have serious difficulties in solving the following problem in
>> Mathematica
>> (v.6) and would very appreciate it if anyone could give me a helping
>> hand with
>> that.
>>
>> To start with, I have a list of data points {{x[[i]],y[[i]]}}.
>>
>> Also, I have the function W. W consists of two single functions f[r] and
>> g[r,
>> x, a]:
>>
>> f[r_] = r^2+r+2/(r^2+r)
>>
>> g[r_, x_, a_] = Exp[a*Exp[-x*r]]
>>
>> W := NIntegrate[f[r]*g[r, x, a], {r, 0.1, 100}]
>>
>> What I have given for every pair of data is W[x[[i]]] == y[[i]] (see the
>> list
>> of data points). What I do not have  is the corresponding value of
>> a[[i]].
>>
>> So, I want to use FindRoot to give me the value of a[[i]] for each of my
>> data
>> pairs {x[[i]],y[[i]]}.
>>
>>
>> Although I have found many examples quite similar to this problem, I
>> have been
>> unable to adjust those to work in my case.
>>
>> I would be very grateful if somebody could provide me with the proper
>> syntax
>> for this.
>>
>> Thanks very much in advance,
>>
>>
>> Chris
>>
>>
>>
>>
>>
>
>
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Re: Re: Is Orange translucent? - What Methods
  • Next by Date: Re: Manipulate suggestions
  • Previous by thread: Re: Re: Is Orange translucent? - What Methods
  • Next by thread: Re: Manipulate suggestions