Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

If & NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg72573] If & NIntegrate
  • From: "Jouvenot, Fabrice" <F.Jouvenot at liverpool.ac.uk>
  • Date: Thu, 11 Jan 2007 02:08:16 -0500 (EST)

Hi all !

I have a problem that I cannot resolve, so I hope some one here will be able to help me.

I am doing many calculus and some of them takes very very long time and other never converged. The fact is that I integrate (NIntegrate (1 or 2 dimensional)) functions that contains a IF.

These functions calculated a result and at some point I test if one part of the calculus is either positive or negative. If it is negative, I want the result to be equal to 0.

They have this pattern :
function[x_]:==Module[{},
  (different calculus to calculate f)
  If[func[a]<0, 0, func[a]];
];

And after :
 b==NIntegrate[function[x],{...

So I am looking for a solution to have a quick integration of this function

If this is not explicit enough, I paste an excerpt of my code at the end of this email.
Thanks for your help,
Cheers,

F.

 ---------------------------------------
\!\(\*
  RowBox[{
    RowBox[{
      RowBox[{
        RowBox[{\(d\[Sigma]bremd\[Epsilon][Emu_, Egam_]\), ":==",
          RowBox[{"Module", "[",
            RowBox[{\({}\), ",", "\[IndentingNewLine]",
             
              RowBox[{\(\[Epsilon]max[E\[Mu]_] :== E\[Mu] - m\_\[Mu]\), ";"
,
                "\[IndentingNewLine]", \(\[Epsilon]max2[E\[Mu]_] :==
                  E\[Mu]/\((1 + m\_\[Mu]\^2/\((2\ \(m\_e\) E\[Mu])\))\)\),

                ";", "\[IndentingNewLine]",
                "\[IndentingNewLine]", \(D\_n == 1.54\ A\^0.27\), ";",
                "\[IndentingNewLine]", \(D\_np == D\_n\^\(1 - 1/Z\)\), ";",

                "\[IndentingNewLine]",
                StyleBox["\[IndentingNewLine]",
                 
                  FontSize->14], \(v[E\[Mu]_, \[Epsilon]_] :== \[Epsilon]/
                    E\[Mu]\), ";",
                "\[IndentingNewLine]", \(\[Delta][
                    E\[Mu]_, \[Epsilon]_] :== \(m\_\[Mu]\^2\ v[E\[Mu], \
\[Epsilon]]\)\/\(2 \((E\[Mu] - \[Epsilon])\)\)\), ";", "\[IndentingNewLine]
",
                "\[IndentingNewLine]", \(\[CapitalPhi]nTemp[
                    E\[Mu]_, \[Epsilon]_] :==
                  Log[\(B\ Z\^\(\(-1\)/3\)\ \((m\_\[Mu] + \[Delta][E\[Mu], 
\
\[Epsilon]] \((D\_np\ \@\[ExponentialE] - 2)\))\)\)\/\(\(D\_np\) \((m\_e + 
\
\[Delta][E\[Mu], \[Epsilon]] \(\@\[ExponentialE]\) B\ Z\^\(\(-1\)/3\))\)\)]
\),
                 ";", "\[IndentingNewLine]",
                "\[IndentingNewLine]", \(\[CapitalPhi]n[
                    E\[Mu]_, \[Epsilon]_] :==
                  If[\[CapitalPhi]nTemp[E\[Mu], \[Epsilon]] < 0,
                    0, \[CapitalPhi]nTemp[E\[Mu], \[Epsilon]]]\), ";",
                "\[IndentingNewLine]", "\[IndentingNewLine]",
                " ", \(\[CapitalPhi]eTemp[E\[Mu]_, \[Epsilon]_] :==
                  Log[\(B\ Z\^\(\(-2\)/3\)\ m\_\[Mu]\)\/\(\((1 + \(\[Delta]
\ \
[E\[Mu], \[Epsilon]] m\_\[Mu]\)\/\(\(m\_e\^2\) \@\[ExponentialE]\))\) \((m\
_e \
+ \[Delta]\ [E\[Mu], \[Epsilon]] \(\@\[ExponentialE]\) \(B\_p\) Z\^\(\(-2\)
/3\
\))\)\)]\), ";",
                "\[IndentingNewLine]", \(\[CapitalPhi]e[
                    E\[Mu]_, \[Epsilon]_] :==
                  If[\[CapitalPhi]eTemp[E\[Mu], \[Epsilon]] <
                        0 || \((\[Epsilon] >== \ \[Epsilon]max2[E\[Mu]])\),

                    0, \[CapitalPhi]eTemp[E\[Mu], \[Epsilon]]]\), ";",
                "\[IndentingNewLine]", "\[IndentingNewLine]",
                "\[IndentingNewLine]", \(dsbremdE[E\[Mu]_, \[Epsilon]_] :==

                  16\/3\ \[Alpha]\ \(\((r\_e\ m\_e\ /m\_\[Mu])\)\^2\ Z\ \((
Z\ \
\[CapitalPhi]n[E\[Mu], \[Epsilon]] + \[CapitalPhi]e[E\[Mu], \
\[Epsilon]])\)\)\/\[Epsilon]\ \((1 -
                        v[E\[Mu], \[Epsilon]] + \(3  v[E\[Mu], \[Epsilon]]\
^2\
\)\/4)\)\), ";", "\[IndentingNewLine]", \(dsbremdE[Emu, Egam]\)}]}],
            "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]",

      "\[IndentingNewLine]",
      StyleBox[\( (*\ Total\ cross\ section\ \[Sigma]\_Brem\ /m\ *) \),
        FontColor->RGBColor[0, 0, 1]],
      StyleBox["\[IndentingNewLine]",
        FontSize->14], \(sectionbrem[E\[Mu]_] :==
        Module[{},
          NIntegrate[
              d\[Sigma]bremd\[Epsilon][E\[Mu], \[Epsilon]], {\[Epsilon],
                Eminbrem, E\[Mu] - m\_\[Mu]}]*unit]\)}], ";"}]\)



  • Prev by Date: Re: ListDimension function
  • Next by Date: Re: ListDimension function
  • Previous by thread: Re: Problem with Position applied on 2D list?
  • Next by thread: Re: If & NIntegrate