+1 Daumen
2,1k Aufrufe

Situation:

Es gibt zwei Wege die zahl e zu approximieren, einmal als Folge und ein mal als Reihe. 

Folge:

$$\mathrm { e } = \lim _ { n \rightarrow \infty } \left( 1 + \frac { 1 } { n } \right) ^ { n } \quad \Longrightarrow \quad \mathrm { e } _ { L } ( n ) = \left( 1 + \frac { 1 } { n } \right) ^ { n }$$


Reihe: 
$$ \mathrm { e } = \sum _ { k = 0 } ^ { \infty } \frac { 1 } { k ! } \Longrightarrow \mathrm { e } _ { S } ( n ) = \sum _ { k = 0 } ^ { n - 1 } \frac { 1 } { k ! } $$

Aufgabe:
Schreibe Folgende "MATLAB-functions":

(i) calcEulerLimit(n) das e_(L)(n) berechnet. 
(ii) calcEulerSum(n) das e_(S)(n) mit der MATLAB-Funktion f a c t o r i a l berechnet. 
(iii) calcEulerSum2(n) das e_(S)(n) ohne MATLAB-Funktion f a c t o r i a l berechnet. 

Danach sollte ich mit "tic" "toc" die Laufzeiten der drei Funktionen schreiben. 


Frage
Ich habe einen Code geschrieben der mir (i) liefert aber ich weiss nicht was gemeint ist mit schreibe Matlab-Funktion.
Heisst das, dass ich ein Skript schreiben muss?

Ich habe es lediglich im command window eingegeben und so 
bin ich auf e_(L)(n) gekommen. 

Mein Code (nur für command window):

%First I have to define a function.
%With its independent variable n.

eL=inline('(1+1/n)^n','n')

eL =

    Inline function:
    eL(n) = (1+1/n)^n

>> pretty(eL(n))
/ 1    \n
| - + 1 |
\ n    /

>> %Now lets try to take its limit when n approaches 1.
>> limit(eL(n),n,1)

ans =

2

>> %The function works and the output is as it was expected.
%Now, in the second step, lets take the limit and see what happens when n approaches infinity.

limit(el(n),n,Inf)
Undefined function or variable 'el'.

Did you mean:
>> limit(eL(n),n,Inf)

ans =

exp(1)

>> %Well the output is the exponential function itself
Avatar von

Ein anderes Problem?

Stell deine Frage

Willkommen bei der Stacklounge! Stell deine Frage einfach und kostenlos

x
Made by a lovely community