Lekcja 3

Funkcje

 f [ x_ ] := ( x + 1 ) ^ 2

Z funkcji mozemy korzystac w dosyc naturalny sposob; na przyklad tak:

 f [ 10 ]

$121$

Albo tak:

 Plot [ f [ x ] , { x , - 3 , 3 } ]

Rowniez takie wykorzystanie jest dopuszczalne

 Integrate [ f [ x ] , x ]

 x + x 2 + x 3 3

 Plot [ f [ x ] x , { x , - 3 , 3 } ]

 Integrate :: ilim : Invalid integration variable or limit(s) in ⁠ - 2.9998774285714287 ⁠. "Invalid integration variable or limit(s) in \[NoBreak]\\!\$$-2.9998774285714287\$$\[NoBreak]. \\!\$$\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/Integrate/ilim\\\", ButtonNote -> \\\"Integrate::ilim\\\"]\$$"  

 

 Integrate :: ilim : Invalid integration variable or limit(s) in ⁠ - 2.877428448979592 ⁠.  "Invalid integration variable or limit(s) in \[NoBreak]\\!\$$-2.877428448979592\$$\[NoBreak]. \\!\$$\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/Integrate/ilim\\\", ButtonNote -> \\\"Integrate::ilim\\\"]\$$"

 Integrate :: ilim : Invalid integration variable or limit(s) in ⁠ - 2.754979469387755 ⁠. "Invalid integration variable or limit(s) in \[NoBreak]\\!\$$-2.754979469387755\$$\[NoBreak]. \\!\$$\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/Integrate/ilim\\\", ButtonNote -> \\\"Integrate::ilim\\\"]\$$"  

  General :: stop : Further output of ⁠ Integrate :: ilim ⁠ will be suppressed during this calculation.  "Further output of \[NoBreak]\\!\$$\\*StyleBox[\\(Integrate :: ilim\$$, \\\"MessageName\\\"]\\)\[NoBreak] will be suppressed during this calculation. \\!\$$\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/General/stop\\\", ButtonNote -> \\\"General::stop\\\"]\$$" Nie jest to chyba to czego oczekiwaliśmy...  Plot [ Evaluate [ ∫ f [ x ] ⁢ ⅆ x ] , { x , - 3 , 3 } ] Teraz lepiej! Ale czemu tak jest? Zdefiniujmy nowa funkcje:  g [ x_ ] := Integrate [ f [ x ] , x ]  Plot [ g [ x ] , { x , - 3 , 3 } ] 

 Integrate :: ilim : Invalid integration variable or limit(s) in ⁠ - 2.9998774285714287 ⁠.  "Invalid integration variable or limit(s) in \[NoBreak]\\!\$$-2.9998774285714287\$$\[NoBreak]. \\!\$$\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/Integrate/ilim\\\", ButtonNote -> \\\"Integrate::ilim\\\"]\$$"

 Integrate :: ilim : Invalid integration variable or limit(s) in ⁠ - 2.877428448979592 ⁠. "Invalid integration variable or limit(s) in \[NoBreak]\\!\$$-2.877428448979592\$$\[NoBreak]. \\!\$$\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/Integrate/ilim\\\", ButtonNote -> \\\"Integrate::ilim\\\"]\$$"  

 

 Integrate :: ilim : Invalid integration variable or limit(s) in ⁠ - 2.754979469387755 ⁠.  "Invalid integration variable or limit(s) in \[NoBreak]\\!\$$-2.754979469387755\$$\[NoBreak]. \\!\$$\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/Integrate/ilim\\\", ButtonNote -> \\\"Integrate::ilim\\\"]\$$"

 General :: stop : Further output of ⁠ Integrate :: ilim ⁠ will be suppressed during this calculation. "Further output of \[NoBreak]\\!\$$\\*StyleBox[\\(Integrate :: ilim\$$, \\\"MessageName\\\"]\\)\[NoBreak] will be suppressed during this calculation. \\!\$$\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/General/stop\\\", ButtonNote -> \\\"General::stop\\\"]\$$"

To moze tak jak poprzednio:

 h [ x_ ] := Evaluate [ Integrate [ f [ x ] , x ] ] ;

 Plot [ h [ x ] , { x , - 3 , 3 } ]

 Clear [ f ]

 ? f

Globalf

  ? h 

Globalh

  h [ x_ ] := x + x 2 + x 3 3

 ? g

Globalg

 g[x_]:=∫f[x]dx  Clear [ g , h ]  ? g 

Globalg

 ? h

Global`h

Polecenie  ? pozwala na sprawdzenie jak zdefiniowany jest dany symbol. Polecenie Clean kasuje wszystkie definicje...