Sei sulla pagina 1di 16

Solve[x ^ 2 - 3 x + 2 ⩵ 0, x]

{{x → 1}, {x → 2}}

Solve[x ^ 2 - 4 x + 5 ⩵ 0, x]
{{x → 2 - ⅈ}, {x → 2 + ⅈ}}

For[i = 1, i ≤ 5, i ++, Print[i]];


1

i = 1;

Whilei ≤ 5, Print[i]; i ++;


1

i = 1;

Do[Print[i], {i, 5}]


1

a := i ^ 2
Do[Print[a], {i, 1, 5}]
1

16

25

Clear[a]
2 sablitehai.nb

Join[{a, b, c}, {d, e, f}]

{a, b, c, d, e, f}

Intersection[{a, b, c}, {c, d, e}]


{c}

Complement[{a, b, c, d, e, f}, {a, b}, {d, e}]


{c, f}

Sort[{a, b, w, e, r, t, y, u, z, j, k, l, q, o, p, v, n, m, j, t}]
{a, b, e, j, j, k, l, m, n, o, p, q, r, t, t, u, v, w, y, z}

f[x_] := x ^ 3;

{f[a], f[Pi], f[Einstein]}


a3 , π3 , Einstein3 

f[x] := x ^ 3;

{f[a], f[Pi], f[Einstein]}


a3 , π3 , Einstein3 

Clear
Clear

i
1

a
a

Clear[f, x]

f[x] := x ^ 3;

{f[a], f[Pi], f[Einstein]}


{f[a], f[π], f[Einstein]}

Integrate[Sqrt[1 + z ^ 2], {z, 0, x}]

ConditionalExpression 1 x 1 + x2 + ArcSinh[x] , Re[x] ≠ 0 || - 1 < Im[x] < 0 || 0 < Im[x] < 1


2

Clear[x]
sablitehai.nb 3

Integrate[Sqrt[1 + z ^ 2], {z, 0, x}]

ConditionalExpression 1 x 1 + x2 + ArcSinh[x] , Re[x] ≠ 0 || - 1 < Im[x] < 0 || 0 < Im[x] < 1


2

Clear[z, x]

Inte
Inte

g[x_] := Integrate[Sqrt[1 + z ^ 2], {z, 0, x};


Table[g[i], {i, 1, 10}] // Timing

Clear[g]

g[x_] := Integrate[Sqrt[1 + z ^ 2], {z, 0, x}];


Table[g[i], {i, 10}] // Timing
1.54688,
 1  2 + ArcSinh[1], 5 + ArcSinh[2] , 1 3 10 + ArcSinh[3], 1 4 17 + ArcSinh[4],
2 2 2 2
1 5 26 + ArcSinh[5], 1 6 37 + ArcSinh[6], 1 35 2 + ArcSinh[7],
2 2 2
1 8 65 + ArcSinh[8], 1 9 82 + ArcSinh[9], 5 101 + ArcSinh[10] 
2 2 2

clear[z, x]
clear[z, x]

Clear[z, x, g]

g[x_] := Integrate[z + 2, {z, 0, x}];


Table[g[i], {i, 0, 5}] // Timing

0.015625, 0, 5 , 6, 21 , 16, 45 


2 2 2

Clear[f, x, y]

f[x_List] := Power[x[[1]], x[[2]]];

{f[{2, 3}], f[{5, 2}], f[{4, 3}]}


{8, 25, 64}

Clear[g, y]

g[y_List] := y[[1]] ^ 2 + y[[2]] * 3 + y[[3]];

{g[{1, 1, 1}], g[{0, 0, 1}]}


{5, 1}

Clear[f, x, y, g]

f[x_, y_] := Power[x, y];


4 sablitehai.nb

{f[2, 3], f[3, 2]}


{8, 9}

{f[a, b, c]}
{f[a, b, c]}

ClearSystemCache
ClearSystemCache

clear[f, x, u, y, g]
clear[f, x, u, y, g]

u[x_] := x ^ 2  x - 2;
1
c[i_] :=  u[y] * Cos[i * Pi * y] ⅆ y;
-1

1
s[k_] :=  u[z] * Sin[k * Pi * z] ⅆ z;
-1

ffourier = c[0]  2 + c[1] * Cos[Pi * x] + s[1] * Sin[Pi * x] +


c[2] * Cos[2 * Pi * x] + s[2] * Sin[2 * Pi * x] + c[3] * Cos[3 * Pi * x] +
s[3] * Sin[3 * Pi * x] + c[4] * Cos[4 * Pi * x] + s[4] * Sin[4 * Pi * x];
sablitehai.nb 5

Plot[{u, ffourier}, {x, - 1, 1}]

1.0

0.5

-1.0 -0.5 0.5 1.0

-0.5

-1.0

Plot[u[x], {x, - 1, 1}]

-1.0 -0.5 0.5 1.0

-0.2

-0.4

-0.6

-0.8

-1.0

Plot[{u[x], ffourier}, {x, - 1, 1}]

-1.0 -0.5 0.5 1.0

-0.2

-0.4

-0.6

-0.8

-1.0

c[1]
4 CosIntegral[π] - CosIntegral[3 π]
6 sablitehai.nb

N[4 - Log[81]]
- 0.394449

u[1]
-1

ffourier[1]
- 0.449415

1
N u[p] * Cos[Pi * p] ⅆ p
-1

0.252191

N4 CosIntegral[π] - CosIntegral[3 π]

0.25219083632470174`
0.252191

ffour
4 Cos[π x] CosIntegral[π] - CosIntegral[3 π] +
1 4 - Log[81] + Sin[π x]  2 - 4 SinIntegral[π] + 4 SinIntegral[3 π]
2 π

ffourier2[n_] :=
c[0]  2 + Sumc[i] * Cos[i * Pi * x], {i, n} + Sums[i] * Sin[i * Pi * x], {i, n}

ffourier2[1]
4 Cos[π x] CosIntegral[π] - CosIntegral[3 π] +
1 4 - Log[81] + Sin[π x]  2 - 4 SinIntegral[π] + 4 SinIntegral[3 π]
2 π

Plot[{u[x], t}, {x, - 1, 1}]

-1.0 -0.5 0.5 1.0

-0.2

-0.4

-0.6

-0.8

-1.0

t = ffourier2[30]
4 Cos[π x] CosIntegral[π] - CosIntegral[3 π] +
4 Cos[2 π x] CosIntegral[2 π] - CosIntegral[6 π] +
4 Cos[3 π x] CosIntegral[3 π] - CosIntegral[9 π] +
sablitehai.nb 7

4 Cos[4 π x] CosIntegral[4 π] - CosIntegral[12 π] +


4 Cos[5 π x] CosIntegral[5 π] - CosIntegral[15 π] +
4 Cos[6 π x] CosIntegral[6 π] - CosIntegral[18 π] +
4 Cos[7 π x] CosIntegral[7 π] - CosIntegral[21 π] +
4 Cos[8 π x] CosIntegral[8 π] - CosIntegral[24 π] +
4 Cos[9 π x] CosIntegral[9 π] - CosIntegral[27 π] +
4 Cos[10 π x] CosIntegral[10 π] - CosIntegral[30 π] +
4 Cos[11 π x] CosIntegral[11 π] - CosIntegral[33 π] +
4 Cos[12 π x] CosIntegral[12 π] - CosIntegral[36 π] +
4 Cos[13 π x] CosIntegral[13 π] - CosIntegral[39 π] +
4 Cos[14 π x] CosIntegral[14 π] - CosIntegral[42 π] +
4 Cos[15 π x] CosIntegral[15 π] - CosIntegral[45 π] +
4 Cos[16 π x] CosIntegral[16 π] - CosIntegral[48 π] +
4 Cos[17 π x] CosIntegral[17 π] - CosIntegral[51 π] +
4 Cos[18 π x] CosIntegral[18 π] - CosIntegral[54 π] +
4 Cos[19 π x] CosIntegral[19 π] - CosIntegral[57 π] +
4 Cos[20 π x] CosIntegral[20 π] - CosIntegral[60 π] +
4 Cos[21 π x] CosIntegral[21 π] - CosIntegral[63 π] +
4 Cos[22 π x] CosIntegral[22 π] - CosIntegral[66 π] +
4 Cos[23 π x] CosIntegral[23 π] - CosIntegral[69 π] +
4 Cos[24 π x] CosIntegral[24 π] - CosIntegral[72 π] +
4 Cos[25 π x] CosIntegral[25 π] - CosIntegral[75 π] +
1 4 - Log[81] + Sin[π x]  2 - 4 SinIntegral[π] + 4 SinIntegral[3 π] +
2 π
1
Sin[2 π x] - - 4 SinIntegral[2 π] + 4 SinIntegral[6 π] +
π
Sin[3 π x]  2 - 4 SinIntegral[3 π] + 4 SinIntegral[9 π] +

Sin[4 π x] - 1 - 4 SinIntegral[4 π] + 4 SinIntegral[12 π] +

Sin[5 π x]  2 - 4 SinIntegral[5 π] + 4 SinIntegral[15 π] +

Sin[6 π x] - 1 - 4 SinIntegral[6 π] + 4 SinIntegral[18 π] +

Sin[7 π x]  2 - 4 SinIntegral[7 π] + 4 SinIntegral[21 π] +

Sin[8 π x] - 1 - 4 SinIntegral[8 π] + 4 SinIntegral[24 π] +

Sin[9 π x]  2 - 4 SinIntegral[9 π] + 4 SinIntegral[27 π] +

Sin[10 π x] - 1 - 4 SinIntegral[10 π] + 4 SinIntegral[30 π] +

Sin[11 π x]  2 - 4 SinIntegral[11 π] + 4 SinIntegral[33 π] +
11 π
Sin[12 π x] - 1 - 4 SinIntegral[12 π] + 4 SinIntegral[36 π] +

Sin[13 π x]  2 - 4 SinIntegral[13 π] + 4 SinIntegral[39 π] +
13 π
Sin[14 π x] - 1 - 4 SinIntegral[14 π] + 4 SinIntegral[42 π] +

Sin[15 π x]  2 - 4 SinIntegral[15 π] + 4 SinIntegral[45 π] +
15 π
Sin[16 π x] - 1 - 4 SinIntegral[16 π] + 4 SinIntegral[48 π] +

8 sablitehai.nb

Sin[17 π x]  2 - 4 SinIntegral[17 π] + 4 SinIntegral[51 π] +


17 π
Sin[18 π x] - 1 - 4 SinIntegral[18 π] + 4 SinIntegral[54 π] +

Sin[19 π x]  2 - 4 SinIntegral[19 π] + 4 SinIntegral[57 π] +
19 π
Sin[20 π x] - 1 - 4 SinIntegral[20 π] + 4 SinIntegral[60 π] +
10 π
Sin[21 π x]  2 - 4 SinIntegral[21 π] + 4 SinIntegral[63 π] +
21 π
Sin[22 π x] - 1 - 4 SinIntegral[22 π] + 4 SinIntegral[66 π] +
11 π
Sin[23 π x]  2 - 4 SinIntegral[23 π] + 4 SinIntegral[69 π] +
23 π
Sin[24 π x] - 1 - 4 SinIntegral[24 π] + 4 SinIntegral[72 π] +
12 π
Sin[25 π x]  2 - 4 SinIntegral[25 π] + 4 SinIntegral[75 π]
25 π

Fori = 1, i ≤ n; i ++,  sum = sum + c[i] * Cos[i * Pi * x] + s[i] * Sin[i * Pi * x]

sum
0

n=2

ff
ff

ffourier2[10]

Null + 4 CosIntegral[π] - CosIntegral[3 π] + 1 4 - Log[81]


2

Sum[c[i], {i, 4}]


4 CosIntegral[π] - CosIntegral[3 π] + 4 CosIntegral[2 π] - CosIntegral[6 π] +
4 CosIntegral[3 π] - CosIntegral[9 π] + 4 CosIntegral[4 π] - CosIntegral[12 π]

clear;

clear ff, cc, ss, fFourier;

Clear ff, cc, ss, fFourier;

ff[x_] = x ^ 2  x - 2;
cc = Range[20];
ss = Range[20];
1
Docc[[i]] =  ff[x] Cos[i * Pi * x] ⅆ x, {i, 20};
-1
sablitehai.nb 9

1
Doss[[i]] =  ff[x] Sin[i * Pi * x] ⅆ x, {i, 20};
-1

1
cc[[0]] =  ff[x] ⅆ x;
-1

20
fFourier = cc[[0]]  2 +  cc[[i]] * Cos[i * Pi * x] + ss[[i]] * Sin[i * Pi * x];
i=1

Plot[{ff[x], fFourier}, {x, 1, - 1}]

-1.0 -0.5 0.5 1.0

-0.2

-0.4

-0.6

-0.8

-1.0

Clear x, a, b, c, d, e, f, g, h, i, j, k, l;

m = {{a, b}, {c, d}}


{{a, b}, {c, d}}

MatrixForm[m]

a b
c d

Transpose[m]
{{a, c}, {b, d}}

MatrixForm[Transpose[m]]

a c
b d

MatrixForm[Inverse[m]]
d b
- -b c+a
-b c+a d d
c
- -b c+a a
d -b c+a d

m^2
a2 , b2 , c2 , d2 
10 sablitehai.nb

Det[m]
-b c + a d

mm = {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}};

Eigenvalues[mm]

 1 9 + 105 , 1 9 - 105 , 0
2 2

Eigen
Eigen

Eigenvectors[mm]

- - 19 - 105 , 2 11 + 105 


, 1, - 19 - 105 , 2 - 11 + 105 
, 1, {1, - 2, 1}
25 + 3 105 25 + 3 105 - 25 + 3 105 - 25 + 3 105

det[m]
det[{{a, b}, {c, d}}]

det[mm]

det[{{1, 2, 3}, {2, 3, 4}, {3, 4, 5}}]

det[{{1, 2, 3}, {2, 3, 4}, {3, 4, 5}}]

det[MatrixForm[mm]]
1 2 3
det 2 3 4 
3 4 5

Det[mm]
0

MatrixForm[Inverse[mm]]

Inverse: Matrix {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}} is singular.

Inverse[{{1, 2, 3}, {2, 3, 4}, {3, 4, 5}}]

mm ^ 3
{{1, 8, 27}, {8, 27, 64}, {27, 64, 125}}

Det[mm ^ 3]
- 756

MatrixForm[mm]
1 2 3
2 3 4
3 4 5

j
sablitehai.nb 11

MatrixForm[Inverse[mm ^ 2]]
31 - 11 17
8 2 8
- 11
2
7 - 52
17 - 52 7
8 8

PositiveDefiniteMatrixQ[mm]
False

Linea
Linea

LinearSolve[{{2, 3}, {4, 1}}, {11, 17}]


{4, 1}

In[96]:= ClearAll["Global`*"]

u[x_] = c0 + c1 * x + c2 * x ^ 2 + c3 * x ^ 3;

- u ''1  5 - u1  5 + 1  5 ^ 2
1 - c0 - c1 - 51 c2 - 151 c3
25 5 25 125

u[0]
c0

u '[1]
c1 + 2 c2 + 3 c3

- u ''1  2 - u1  2 + 1  2 ^ 2
1 - c0 - c1 - 9 c2 - 25 c3
4 2 4 8

- u ''1  4 - u1  4 + 1  4 ^ 2
1 - c0 - c1 - 33 c2 - 97 c3
16 4 16 64

m = {1, 0, 0, 0}, {0, 1, 2, 3}, - 1, - 1  2, - 9  4, - 25  8, - 1, - 1  4, - 33  16, - 97  64;

b = 0, 1, - 1  4, - 1  16;

LinearSolve[m, b]

0, - 7 , - 13 , 88 
93 217 651

poly = LinearSolve[m, b]

0, 583 , - 29 , - 8 
405 405 81
12 sablitehai.nb

poly[1]

0, - 7 , - 13 , 88 [1]
93 217 651

poly[[1]]
0

f[x_] = poly[[1]] + poly[[2]] * x + poly[[3]] * x ^ 2 + poly[[4]] * x ^ 3;

Plo
Plo

Plot[{f[x], g[x]}, {x, 0, 1}]

1.2

1.0

0.8

0.6

0.4

0.2

0.2 0.4 0.6 0.8 1.0

DSolve[y ''[x] + y[x] ⩵ x ^ 2, y[x], {x, 0, 1}]


y[x] → - 2 + x2 + C[1] Cos[x] + C[2] Sin[x]

DSolve[{y ''[x] + y[x] ⩵ x ^ 2, y[0] ⩵ 0, y '[1] ⩵ 1}, y[x], {x, 0, 1}]


y[x] → - 2 + x2 + 2 Cos[x] + Sec[1] - 1 + 2 Sin[1] Sin[x]

g[x_] = - 2 + x2 + 2 Cos[x] + Sec[1] - 1 + 2 Sin[1] Sin[x];

In[1]:= ClearAll["Global`*"]

f[u_] = + u;

In[74]:= g[x_] := x ^ 2;

In[91]:= k[y_] = y + c1 y * 2 - y + c2 y ^ 2 * 1 - 2 y  3;


sablitehai.nb 13

1
In[76]:=  x 2 - x * k ''[x] + k[x] - g[x] ⅆ x
0

Out[76]=
7 - 4 c1 - 17 c2
60 5 90

7 4 c1 17 c2
- -
60 5 90
1
In[77]:=  x ^ 2 1 - 2 * x  3 * k ''[x] + k[x] - g[x] ⅆ x
0

Out[77]=
1 - 17 c1 - 29 c2
36 90 315

1
2 ′′
In[20]:=  2 - x x - x + u_bar + u_bar  ⅆ x
0
1
2 ′′
Out[20]=  2 - x x - x + u_bar + u_bar  ⅆ x
0

In[72]:= Clear c1, c2;

In[43]:= u_bar[2]

In[55]:= k ''

In[56]:= g ''
Out[56]= 2&

In[58]:= g '[x]
Out[58]= 2x

In[78]:= LinearSolve4 / 5, 17  90, 17  90, 29  315, 7  60, 1  36

Out[78]=  623 , 21 
4306 4306

In[79]:= c1 = 623  4306;


c2 = 21  4306;
14 sablitehai.nb

In[95]:= Plotk[x], - 2 + x2 + 2 Cos[x] + Sec[1] - 1 + 2 Sin[1] Sin[x], {x, 0, 2}

2.0

1.5

Out[95]=
1.0

0.5

0.5 1.0 1.5 2.0

In[112]:= ClearAll["Global`*"]

In[113]:= n1[x_] = 1 - 2 x;

In[114]:= n2[x_] = 2 x;

In[115]:= u[x_] = n1[x] * u1 + n2[x] * u2;

In[101]:= u '[x]
Out[101]= - 2 u1 + 2 u2

In[102]:= n1 '[x]
Out[102]= -2

0.5
In[103]:=  n1 '[x] * u '[x] - n1[x] * u[x] + n1[x] * x ^ 2 ⅆ x
0

Out[103]= 0.0104167 + 1.83333 u1 - 2.08333 u2

0.5
In[104]:=  n2 '[x] * u '[x] - n2[x] * u[x] + n2[x] * x ^ 2 ⅆ x
0

Out[104]= 0.03125 - 2.08333 u1 + 1.83333 u2

In[132]:= m = {{1.83333, - 2.08333}, {- 2.08333, 1.83333}};

In[133]:= b = {- 0.0104167, - 0.03125};

In[107]:= LinearSolve[m, b]

{0.0859929747397016`, 0.08067382526029823`}

In[116]:= u1 = 0.0859929747397016;
u2 = 0.08067382526029823;
sablitehai.nb 15

In[118]:= Plot[u[x], {x, 0, 0.5}]


0.086

0.085

0.084

Out[118]=
0.083

0.082

0.081

0.1 0.2 0.3 0.4 0.5

In[119]:= u[x]
Out[119]= 0.085993 1 - 2 x + 0.161348 x

In[120]:= n3[x_] = 2 - 2 x;

In[121]:= n4[x_] = 2 x - 1;

In[123]:= unext[x_] = n3[x] * u3 + n4[x] * u4;

1
In[124]:=  n3 '[x] * unext '[x] - n3[x] * unext[x] + n3[x] * x ^ 2 ⅆ x
0.5

Out[124]= 0.114583 + 1.83333 u3 - 2.08333 u4

1
In[125]:=  n4 '[x] * unext '[x] - n4[x] * unext[x] + n4[x] * x ^ 2 ⅆ x
0.5

Out[125]= 0.177083 - 2.08333 u3 + 1.83333 u4

In[126]:= m1 = {{1.83333, - 2.083333}, {- 2.08333, 1.83333}};

In[127]:= b1 = {- 0.114583, - 0.177083};

In[134]:= MatrixForm[m]
Out[134]//MatrixForm=

 1.83333 - 2.08333 
- 2.08333 1.83333

In[135]:= MatrixForm[m1]
Out[135]//MatrixForm=

 1.83333 - 2.08333 
- 2.08333 1.83333

In[131]:= m
Out[131]= m
16 sablitehai.nb