DMUG-Archiv 2006

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

Re: Erf für grosse Zahlen

Hallo Peter,

Mathematica is an infinite evaluation system. When you enter an expression, Mathematica will keep on using definitions it knows until it gets a result to which no definitions apply. (§ 2.6.1 Principles of Evaluation, vgl. auch § 2.6.13)

Auf das Erf[] im If[] wendet Mma die Definition wieder an. Andere Systeme haben diese Eigenschaft nicht, sie wenden eine Definition nur genau einmal an. Eine Regel modifiziert Erf[] wie gewünscht:.

In[3]:= Unprotect[Erf];
Erf[x_] := Sign[x] /; Abs[x] > 6
Protect[Erf]
Out[5]= {Erf}

In[6]:= ??Erf

Erf[z] gives the error function erf(z). Erf[z0, z1] gives the generalized error function erf(z1) - erf(z0). Mehr&
Attributes[Erf] = {Listable, NumericFunction, Protected}
Erf[x_] := Sign[x] /; Abs[x] > 6

er hat es zur Kenntnis genommen und plottet dann in Spitzengeschwindigkeit.

In[7]:= Plot[Erf[n], {n, -10, 100000}, Frame -> True, PlotRange -> All]

Das funktioniert wg. § 2.6.4 The Standard Evaluation Procedure: The next step in the standard evaluation procedure is to use definitions that Mathematica knows for the expression it is evaluating. Mathematica first tries to use definitions that you have made, and if there are none that apply, it tries built-in definitions.

Gruss
Udo.


klamser wrote:

Diese "eigene" Errorfunktion würde ich gerne im Rahmen einer Unprotect[Erf] Protect[Erf] Definition in die Erf einbauen, was aber in einer unendliche Iteration endet:




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

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