DMUG-Archiv 2003

Frühere   Chronologischer Index   Spätere
Vorherige   Thematischer Index   Nächste

Re: NIntegrate bei einer kompilierten Funktion

Guten Morgen Herr Klamser,
am einfachsten ist es wohl das NIntegrate in die kompilierte Funktion 
hineinzuziehen.
Zum Check habe ich es auch noch mal unkompiliert getestet.
MfG,
Rolf Mertig
Mertig Consulting
http://www.mertig.com


On Tuesday 01 July 2003 23:18, Peter Klamser wrote:
> Hallo,
>
> ich möchte eine kompilierte Funktion numerisch integrieren.
>
> Leider klappt das nicht, weil MMa den Parameter, nach dem integriert werden
> soll, nicht richtig übergibt.
>
> Danke für den Grips.
>
> Mit freundlichen Grüßen
>
> Peter Klamser
(************** Content-type: application/mathematica **************
                     CreatedBy='Mathematica 4.2'

                    Mathematica-Compatible Notebook

This notebook can be used with any Mathematica-compatible
application, such as Mathematica, MathReader or Publicon. The data
for the notebook starts with the line containing stars above.

To get the notebook into a Mathematica-compatible application, do
one of the following:

* Save the data starting with the line of stars above into a file
  with a name ending in .nb, then open the file inside the
  application;

* Copy the data starting with the line of stars above to the
  clipboard, then use the Paste menu command inside the application.

Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode.  Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).

NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing
the word CacheID, otherwise Mathematica-compatible applications may
try to use invalid cache data.

For more information on notebooks and Mathematica-compatible 
applications, contact Wolfram Research:
  web: http://www.wolfram.com
  email: info@XXXXXXX.com
  phone: +1-217-398-0700 (U.S.)

Notebook reader applications are available free of charge from 
Wolfram Research.
*******************************************************************)

(*CacheID: 232*)


(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[      3755,         97]*)
(*NotebookOutlinePosition[      4408,        120]*)
(*  CellTagsIndexPosition[      4364,        116]*)
(*WindowFrame->Normal*)



Notebook[{

Cell[CellGroupData[{
Cell[BoxData[{
    \(\(sf = 
        Compile[{\[Alpha], a, b, l, M, r, H}, 
          Module[{nenner, cosalpha, sinalpha, z1, z2, z3, z4}, 
            If[M \[Equal] 0, 0.0, 
              NIntegrate[\[IndentingNewLine]nenner = 2\ \@2\ \@\(H\/Mi - 1\); 
                cosalpha = Cos[\[Alpha]]; sinalpha = Sin[\[Alpha]]; 
                z1 = 2\ \((l - 2\ r\ Cos[\[Alpha]])\)\ a; 
                z2 = 2\ \((l + 2\ r\ Cos[\[Alpha]])\)\ a; 
                z3 = 2\ \((b + 2\ r\ Sin[\[Alpha]])\)\ a; 
                z4 = 2\ \((b - 
                        2\ r\ Sin[\[Alpha]])\)\ a; \[IndentingNewLine]\
\[IndentingNewLine]\(-\((\((Erf[z1\/nenner] + 
                            Erf[z2\/nenner])\)\ \((Erf[z3\/nenner] + 
                            Erf[z4\/nenner])\))\)\)/\((4. \ \((\(-1\) + \
\[ExponentialE]\^\(\(\ \)\(Mi\ \((\(-H\)\ 2 + 2\ Mi)\)\)\))\))\), {Mi, 0. , 
                  M}]]], {{Mi, _Real}}];\)\), "\[IndentingNewLine]", 
    \(sf[0, 0.1, 100, 1000, 7, 100, 1000]\)}], "Input"],

Cell[BoxData[
    \(2.906998085150298`\)], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[{
    \(\(esf[\[Alpha]_, a_, b_, l_, M_, r_, H_] := 
        Module[{nenner, cosalpha, sinalpha, z1, z2, z3, z4}, 
          nenner = 2\ \@2\ \@\(H\/M - 1\); cosalpha = Cos[\[Alpha]]; 
          sinalpha = Sin[\[Alpha]]; z1 = 2\ \((l - 2\ r\ Cos[\[Alpha]])\)\ a; 
          z2 = 2\ \((l + 2\ r\ Cos[\[Alpha]])\)\ a; 
          z3 = 2\ \((b + 2\ r\ Sin[\[Alpha]])\)\ a; 
          z4 = 2\ \((b - 2\ r\ Sin[\[Alpha]])\)\ a; 
          If[M \[Equal] 0, 
            0.0, \[IndentingNewLine]\(-\((\((Erf[z1\/nenner] + 
                        Erf[z2\/nenner])\)\ \((Erf[z3\/nenner] + 
                        Erf[z4\/nenner])\))\)\)/\((4\ \((\(-1\) + \
\[ExponentialE]\^\(\(\ \)\(M\ \((\(-H\)\ 2 + 2\ M)\)\)\))\))\)]];\)\), "\n", 
    \(NIntegrate[esf[0, 0.1, 100, 1000, x, 100, 1000], {x, 0, 7}]\)}], "Input"],

Cell[BoxData[
    \(2.906998085150298`\)], "Output"]
}, Open  ]]
},
FrontEndVersion->"4.2 for X",
ScreenRectangle->{{0, 1600}, {0, 1200}},
WindowSize->{1240, 1068},
WindowMargins->{{Automatic, 113}, {Automatic, 38}},
Magnification->1.5
]

(*******************************************************************
Cached data follows.  If you edit this Notebook file directly, not
using Mathematica, you must remove the line containing CacheID at
the top of  the file.  The cache data will then be recreated when
you save this file from within Mathematica.
*******************************************************************)

(*CellTagsOutline
CellTagsIndex->{}
*)

(*CellTagsIndex
CellTagsIndex->{}
*)

(*NotebookFileOutline
Notebook[{

Cell[CellGroupData[{
Cell[1776, 53, 997, 17, 343, "Input"],
Cell[2776, 72, 52, 1, 39, "Output"]
}, Open  ]],

Cell[CellGroupData[{
Cell[2865, 78, 819, 13, 264, "Input"],
Cell[3687, 93, 52, 1, 39, "Output"]
}, Open  ]]
}
]
*)



(*******************************************************************
End of Mathematica Notebook file.
*******************************************************************)

Antworten:
Verweise:
Frühere   Chronologischer Index   Spätere
Vorherige   Thematischer Index   Nächste

DMUG DMUG-Archiv, http://www.mathematica.ch/archiv.html