Creearea funcțiilor în Mathematica: Diferență între versiuni

De la YO3ITI
Sari la navigare Sari la căutare
Fără descriere a modificării
Fără descriere a modificării
Linia 1: Linia 1:
În Mathematica, o funcție se poate defini astfel:
În Mathematica, o funcție se poate defini astfel:
<syntaxhighlight lang="Mathematica">
<syntaxhighlight lang="Mathematica">
f[x_]:=x^2+2 x-4
f[x_]:=x^2+2x-4
 
In[3]:= f[1] Out[3]= -1
In[4]:= f[π]
Out[4]= -4+2π+π2
</syntaxhighlight>
</syntaxhighlight>


<math>d_\text{F} = \frac{2 D^2}{\lambda}</math>
//<math>d_\text{F} = \frac{2 D^2}{\lambda}</math>


You can define your own function in Mathematica like this (use the Basic Math Assistant palette to type x2; see Section 1.6):
You can define your own function in Mathematica like this (use the Basic Math Assistant palette to type x2; see Section 1.6):

Versiunea de la data 25 iulie 2022 22:55

În Mathematica, o funcție se poate defini astfel:

f[x_]:=x^2+2x-4

In[3]:= f[1] Out[3]= -1
In[4]:= f[π]
Out[4]= -4+2π+π2

//dF=2D2λ

You can define your own function in Mathematica like this (use the Basic Math Assistant palette to type x2; see Section 1.6):

Follow these rules when defining a function: $ The name of the function (such as f or inv) should be a lowercase letter, or a word that begins with a lowercase letter. This is because all built-in functions (such as Log and N) begin with capital letters. If your function begins with a lowercase letter, you will never accidentally give it a name that already belongs to some built-in function. $ The function argument (in these examples x) must be followed by an underscore _ on the left side of the definition. $ Use square brackets [ ] to enclose the function argument. $ Use the colon-equal combination := to separate the left side of the definition from the right.