Monday, February 17, 2020

Mathematica Notes: Input & Define a Function

Input

ac\frac{a}{c}
Press [Ctrl]+[/]
xax^a
Press [Ctrl]+[^]
x\sqrt{x}
Press [Ctrl]+[@]

Define a function

f(x)=x2+x+1 f(x)=x^2+x+1

Input:
f[x_] := x^2 + x + 1
f[1]
Output:
3

What difference between f[x_]:= and f[x_]= ?

:= means delayed assignment, the value will recompute everytime it needed.
= means assign value immediately
** =. means clear assignment

What difference between f[x_] and f[x] ?

input:
f[x_] := x^2 + x + 1
f[1]
g[y] := x^2 + x + 1
g[1]

output:
3
g[1]