(*Assumtion - all files are in the same directory, including this notebook*)

1. The matrix which defines  a set of linear equations (coefficients are Reals) is  in koeficientyReal.xls. Find the solution.

FileNames[]

SetDirectory[NotebookDirectory[]];
data1=Import["koeficientyReal.xls"];
data2=data1[[1]];
matr=data2[[2;;,;;-2]];
rhs=data2[[2;;,-1]];
sol1=LinearSolve[matr,rhs]

2. The matrix defining  a set of linear equations (coefficients are complex numbers ) is  in koeficientyKomplex.xls. Find the solution.

SetDirectory[NotebookDirectory[]];
data1=Import["koeficientyKomplex.xls"];
data2=data1[[1]];
matrRe=data2[[3;;,1;;-3;;2]];
matrIm=data2[[3;;,2;;-3;;2]];
rhsRe=data2[[3;;,-2]];
rhsIm=data2[[3;;,-1]];
matr=matrRe+I*matrIm;
rhs=rhsRe+I*rhsIm;
sol2=LinearSolve[matr,rhs]

3. Solve  5∙y''(t)+11∙y'(t)+2∙y(t)=((sin(t))/(t+1))

a) assuming  y(0)=1 a y'(0)=5

ySol=DSolve[{5*y''[t]+11*y'[t]+2*y[t]==Sin[t]/(t+1),y[0]==1,y'[0]==5},y,t];
ySolFcn=ySolGen[[1,1,2]];
ySolExpr=ySolFcn[t]

b) assuming y(0)=1 a y(1)=5

ySol=DSolve[{5*y''[t]+11*y'[t]+2*y[t]==Sin[t]/(t+1),y[0]==1,y[1]==5},y,t];
ySolFcn=ySolGen[[1,1,2]];
ySolExpr=ySolFcn[t]

4 Evaluate (((({{1, 2}, {7, 13}})))^(1/5))

{{1,2},{7,13}}^(1/5)

5. Find extremes of    assuming the constraint  (x^2)+(y^2)=1

Minimize[{x+2*y,x^2+y^2==1},{x,y}]

Maximize[{x+2*y,x^2+y^2==1},{x,y}]

6. File teploty.xls contains mean daily temperatures . Use power - temperature dependence according  to  table below. Find the total energy  (unit  kWh).

(*definition of the function for power dependance on temperature:*)
pow[T_/;T<-15]:=20; (*applying conditions with /; *)
pow[T_/;-15<=T<-12]:=15;
pow[T_/;-12<=T<-8]:=12;
pow[T_/;-8<=T<-2]:=9;
pow[T_/;-2<=T<5]:=5;
pow[T_/;5<=T<13]:=3;
pow[T_/;13<=T]:=0;

(*evaluation of energy*)
SetDirectory[NotebookDirectory[]];
data1=Import["teploty.xls"];
data2=data1[[1]];
teploty=data2[[All,1]];
pows=pow/@teploty;(*look at help for /@ - it is very usefull thing*)
energykWh=Total[pows]*24

7. File DataStatistika.xls contains equi-distantly  sampled values of electric current. Evaluate standard deviation, mean value and variance of the data. assuming

SetDirectory[NotebookDirectory[]];
data1=Import["DataStatistika.xls"];
data2=data1[[1]];
values=data2[[All,1]];
stdDev=StandardDeviation[values]
mean=Mean[values]
var=Variance[values]

9. Find exponential form of 1+2∙i.

x=1+2*I;
x2=Abs[x]*E^(I*Arg[x])

Expand

10. Find exponential and Cartesian form of ((A∙B)/(A+B))  for A=1+i  and B=1-3∙i.

a=1+I;
b=1-3*I;
r=(a*b)/(a+b)
r2=Abs[r]*E^(I*Arg[r])

11. Evaluate (i^i)

N[I^I]

N[E^(-Pi/2)]

12. Find the root of equation x=1+Tanh(0.5x).

sol=FindRoot[x==1+Tanh[0.5*x],{x,0}]

sol[[1,2]] (*extracts the number from the obtained expression*)

x==1+Tanh[0.5*x]/.sol (*Uses the expression  with an arrow (saved in the variable "sol") to exchange x for the value of the root in the equation*)

13. Coordinates of (Overscript[x, →])  in classical ortho-normal basis are (Overscript[x, →])=(1,2,3)  Find the coordinates with respect of the basis of vectors (Subscript[(Overscript[b, →]), 1])=(0, (1/2),0),(Subscript[(Overscript[b, →]), 2])=(2,0,0),(Subscript[(Overscript[b, →]), 3])=(0, 0,1).

(*classical ortho-normal basis = Euclidean vectors*)
e1={1,0,0};
e2={0,1,0};
e3={0,0,1};

(*new basis vector with restpect to Eubclidean basis *)
b1={0,1/2,0};
b2={2,0,0};
b3={0,0,1};

(*coordinates of Euclidean vectors with respect of new basis*)
eb1=LinearSolve[Transpose[{b1,b2,b3}],e1];
eb2=LinearSolve[Transpose[{b1,b2,b3}],e2];
eb3=LinearSolve[Transpose[{b1,b2,b3}],e3];

(*x with respect of new basis*)
x={1,2,3};
xb=LinearSolve[Transpose[{eb1,eb2,eb3}],x]

14. Evaluate (∫_1^2)((sinx)/x) dx

ClearAll[x];(*clears variable (=symbol) "x"*)
solExact=Integrate[Sin[x]/x,{x,1,2}]

solNumeric=N[solExact]

15. Let f is a function, f(τ)=(∫_(x=1)^(x=τ))((sinx)/x)dx. Plot the graph of f'(τ)  for τ∈(1,2)

Plot[Sin[x]/x,{x,1,2}]

(*Prove:*)

(*Definition of a function of one variable*)
ClearAll[f]; (*just for sure*)
f[tau_]:=Integrate[Sin[x]/x,{x,1,tau}]; 
(*test of the function*)
f[1]

(*plot of derivative*)
Plot[f'[tau],{tau,1,2}]

16. Assume a differential equation  2∙y''(t)+c∙y'(t)+5∙y(t)=0. For which c values is (lim_(t→∞))y(t)=0 ?

sol=DSolve[2*y''[t]+c*y'[t]+5*y[t]==0,y,t]
solFcn=sol[[1,1,2]]
solExpr=solFcn[t]

(*to solve the task: Must be (-c-(Sqrt[-40+(c^2)]))<0 and (-c+(Sqrt[-40+(c^2)]))<0 *)

Reduce[{(-c-(Sqrt[-40+(c^2)]))<0,(-c+(Sqrt[-40+(c^2)]))<0},c]

17. Be  A=(1,2),  B=(-3,5),  C=(0,1), D=(4,-3),  points in 2D Cartesian space. Find the 3rd order fit of the point and evaluate its value for the first coordinate equal 2.

(*Solution*)
points={{1,2},{-3,5},{0,1},{4,-3}};
fcn=Interpolation[points,InterpolationOrder->3];
sol=fcn[2]

(*Visualisation*)
pl1=ListPlot[points,PlotStyle->Red];
pl2=Plot[fcn[t],{t,-3,4}];
pl3=ListPlot[{{2,sol}},PlotStyle->Green];
Show[pl1,pl2,pl3]