a

1+1

b=3

?b

a=4;
?a

(* ctrl + /*)

(88/22)

(*ctrl ^ *)
(3^3)

(x^4)

(*ctrl + 2*)
(Sqrt[9])

Sin[5]

Sin[5+Pi]

Head[5]

Head[5.]

Head[5+I]

Sin[5.]

Sin[5.]

-0.9589242746631385`

(*enumerate expr*)
N[Pi]

(*overloaded functions*)
N[Pi,100]

α

(*esc a esc gives us α*)
α

α

Integrate[((Sin[2x])/((x^3)+x)),x]

Plot[x*Sin[(x^(-1))],{x,-2Pi,2Pi},PlotRange->Full]

kyncl is a bad man and bad teacher

kyncl*is*a*bad*man*and*bad*teacher

Solve[(x^2)==1]

x=1;
ClearAll[x]
Solve[(x^2)==1]

(x^2)==1

Plot[x*Sin[(x^(-1))],{x,-2Pi,2Pi},PlotRange->Full,PlotStyle->Red]

plt1=Plot[x*Sin[100*Exp[-x]],{x,1,10},PlotRange->All,AspectRatio->1,PlotStyle->Purple,AxesLabel->{"x","f[x]"},GridLines->All];

Plot[x*Sin[100*Exp[-x]],{x,1,10},PlotRange->All,AspectRatio->1,PlotStyle->Purple,AxesLabel->{"x","f[x]"},GridLines->Full]

Show[plt1,Plot[x^2,{x,1,10}]]

{1,2,3}

Table[i,{i,1,10}]

Table[x^i,{i,1,10}]

a=Table[i,{i,1,10}]

?a

Table[ape,{12}]

Table[(i^2),{i,5}]

Table[i,{i,2,5}]

Table[i,{i,0.3,5,0.5}]

exprs=Table[(x^(2i-1)),{i,1,5}]
Plot[exprs,{x,-1,1}];

Plot[{x,(x^3),(x^5),(x^7),(x^9)},{x,-1,1}];

Plot[{Sin[x],Cos[x]},{x,-Pi,Pi},AxesLabel->{"x","Sin[x] Cos[x]"},PlotStyle->{{Red,Dashed},{Blue,Thickness[0.003]}},GridLines->{{((-Pi)/2),0,(Pi/2)}, {((-1)/(Sqrt[2])),0,(1/(Sqrt[2]))}}]

plt1=Plot[x*Sin[100*Exp[-x]],{x,1,10},PlotRange->All,AspectRatio->1,PlotStyle->Purple,AxesLabel->{"x","f[x]"},GridLines->All];

Show[plt1,Plot[Exp[-0.1x],{x,1,10},PlotStyle->Blue],PlotLabel->"2plots"]

data=Table[{x,Sin[x]},{x,0,2Pi,0.2}];
pltdata=ListPlot[data,PlotStyle->{PointSize[0.02],Red}];

Show[Plot[Sin[x],{x,0,2Pi},AxesLabel->{"x","Sin[x]"}],pltdata]

?___

ClearAll[f];
f[x:_]:=(x^2);
{f[x],f[5]}

ClearAll[f];
f[x]:=(x^2);
{f[x],f[5]}

ClearAll[f];
f[x_]:=(x^2);
{f[x],f[5]}

ClearAll[a];
a[n_]:=a[n-1]*n;
a[0]:=1;

Trace[a[3]]

3!

ClearAll[f]
f[x_Integer]:=x^2

f[2.5]

f[2]

ClearAll[f,test]
test[x_]:=x<2;
f[x_]:=x^2;
f[x_?test]:=x;
Plot[f[x],{x,0,4}]

ClearAll[f];
f[x_]:=0.5x;
f[x_Integer]:=(x^2);
f[x_?EvenQ]:=(Sqrt[x]);
f[2]:=0;
{f[2],f[3],f[4],f[Pi]}

ClearAll[f];
f[{x_,y_}]:=(x^y);
f[{x_,y_Integer}]:=(y^x);
f[{1,y_}]:=y;
{f[{Pi,E}],f[{Pi,3}],f[{1,100}]}

Remove["Global`*"]

?:=

?=

a=Random[]

?a

Table[a,{10}]

a:=Random[]

?a

Table[a,{10}]

(*examples of the usage of Set and SetDelayed*)

ClearAll[f];
f[x_]:=Integrate[Sin[x],x];
f[1]

?f

ClearAll[f];
f[x_]=Integrate[Sin[x],x]
f[1]

?f

ClearAll[f];
x=2;
f[x_]:=(x^2);
f[5]
?f

ClearAll[f];
x=2;
f[x_]=(x^2);
f[5]
?f

ClearAll[f,x];
f[x_]=(x^2);
f[5]
?f

ClearAll[f,x,y]
f[{a_,b_,c_,d_}]:=Solve[{a*x+y==b,x+c*y==d}];
f[{1,2,3,4}]
?f

ClearAll[f,x,y,a,b,c,d]
f[{a_,b_,c_,d_}]=Solve[{a*x+y==b,x+c*y==d},{x,y}];
f[{1,2,3,4}]
?f

ClearAll[f];
sin=Sin[x];
f[x_]:=sin

f[1]

f[x_]=sin;

f[1.]

ClearAll[f]
f[x_]:=Module[{round, rest},
round=Round[x];
rest=x-round;
round+3rest
];
f[5.4]

ClearAll[f]
f[x_]:=Module[{round, rest},{round,rest}]
f[5]

(*pure functions*)
(* # is the parameter,  & tells us that expression on lhs of it is a function *)
ClearAll[f];
f[x_]:=(x^2);
f[5]

((#)^2)&[5]

#=5

g:=#*Sin[#]&;
g[2]
Plot[g[x],{x,1,10}];

h:=((#1)^(#2))&
h[E,Pi]

n=1&

sinf=Function[x,Sin[x*#]&]

sinf[5][x]

Plot[sinf[1][x],{x,0,10}];

Select[{1,2,4,7,6,2},#>2&]

test[x_]:=x>2;
Select[{1,2,4,7,6,2},test]

ClearAll[f];
f[x_?(#>2&)]:=x+2;
f[x_]:=(x^2);
Plot[f[x],{x,0,4}]

ClearAll[g,test]

test[x_]:=x>2;
g[x_]:=x^2;
g[x_?test]:=x+2;

Plot[g[x],{x,0,4}]

(#>2&)[3]

(*maping functions*)
list={me,brother, mother, father};
Map[cutHair,list]
cutHair/@list

list=Range[10]
ClearAll[f];
f[x_]:=Sin[x]+x;
f/@list;
Map[f,list];
((#)^2)&/@list
Sin[#]+#&/@list;

0&/@Range[10]

list={1,2,3}
{Apply[function,list],function@@list}

{TreeForm[list],TreeForm[function[1,2,3]]}

Head[function[1,2,3]]

Remove["Global`*"]
list={a,b,c};
{TreeForm[{a,b,c}],TreeForm[a+b+c],TreeForm[a*b*c]}

{Plus@@{a,b,c},Times@@{a,b,c},Power@@{a,b,c}}

Plus@@Range[100]

Times@@Range[100]

Remove["Global`*"]
f[x_]:=(Cos[x]+x)*(Sqrt[1+Sin[x]]);
Plot[{f[(Sqrt[t])+Sin[t]],(Sqrt[t])-f[Cos[t]]},{t,0,12Pi},GridLines->Full,PlotStyle->{Red,{Dashed,Blue}},AxesLabel->{x,y}]

Quiet@Remove["Global`*"]

FindRoot[Cos[x]==x,{x,0}]
TreeForm[%]

(x^2)/.x->2

(x^2)/.{x->2,x->1}

(x^2)+(y^3)/.{x->2,y->Pi}

(x^2)/.{{x->2},{x->3},{x->4}}

FindRoot[(x^5)==1,{x,0.5+I}]

Solve[x==1.]

Solve[(x^5)==1.]

Quiet@Remove["Global`*"]
eqn=(x^2)+a*x+(1-(a^2))==0;
sol=Solve[eqn,x];
x1=x/.sol[[1]];
x2=x/.sol[[2]];
forPlot=Abs[(x1^2)+(x2^2)];
Plot[forPlot,{a,1,100}]

FullForm[eqn]

eqn/.Power[a,2]->2*a

f[x_]:=(x^2)
g[y_]=(y^2)

eqn/.Power[a_,b_]:>a*b

eqn/.Power[a_,b_]->a*b

list={1,1.,Pi,E,5,6,7,8}

f[x_Integer]:=x+100Pi;
f[5]

list/.a_Integer:>a+100Pi

list=Range[10]
test[x_]:=x>5;
list/.a_?test:>0

rule={{a->1},{a->6}}
rule2={a->1,a->6}

a/.rule

a/.rule2

a^12/.rule

Quiet@Remove["Global`*"];
a=4;
{1,2,3,4}/.a_:>(a/2)

Quiet@Remove["Global`*"];
a=4;
{1,2,3,4}/.a_->(a/2)

Quiet@Remove["Global`*"];
{1,2,3,4}/.a_->(a/2)

Quiet@Remove["Global`*"];
x=4;
f[x_]:=(x^2);
f[2]

Quiet@Remove["Global`*"];
x=4;
f[x_]=(x^2);
f[3]

Quiet@Remove["Global`*"];
f[x_]=(x^2);
f[3]

{{a,2},{b,4},{c,5}}/.{a_,b_}:>a+b

{{a,2},{b,4}}/.{x_,y_}:>x+y

FullForm[{{a,2},{b,4}}]

{{a,2},{b,4}}/.{x_,y_?NumericQ}:>x+y

voltagesAndCurrents=Table[{u+Random[],(u/100)+0.05Random[]},{u,100,1500}];
resistances=voltagesAndCurrents/.{u_,i_}:>(u/i);
averageResistance=Mean[resistances]

powers=voltagesAndCurrents/.{u_,i_}:>u*i;
meanPower=Mean[powers]

{{1,2},{4,5,6},{7,9}}/.{a_,b_}:>(b/a)

MatchQ

de=10+2UnitStep[t-1]==5*i'[t]+10*i[t];

steadystate=de/.{t->0,_'[_]->0}
initialCond=Solve[steadystate][[1,1]]/.Rule->Equal

sol=i[t]/.First@NDSolve[{de,initialCond},i,{t,0,10}]

Plot[sol,{t,0,10},PlotRange->{{0,10},{0,1.2}},GridLines->Automatic,PlotStyle->{Blue,Thick}]

{x[0]==(1/2)}

Solve[2x[0]==1]
%/.{a_->b_}:>a==b

Union[{fgf==poiop},{gfhfh==oiu}]

sys={x'[t]==Sin[t]+y[t],y'[t]==x[t]+Tanh[t]}

TreeForm[sys]

der=Cases[sys,_'[t],{0,Infinity}]

der/.f_'[t]:>f[0]==0

inits=Cases[sys,a_'[t]:>a[0]==0,{0,Infinity}]