Demandes associées au chapitre-notebook: "Variables"

Pour accéder au code relatif à un exemple, double-cliquer sur le triangle du crochet icônique à droite.

Exemple 1

5 (x^2) - Cos[x] + 3 /. x -> (π/2)

Exemple 2

$Version

Exemple 3

$MachinePrecision

Exemple 4

A = 3

A

Exemple 5

coordonnées[B] ^= {4, 5}

couleur[B] ^= rouge

forme[B] ^= croisillon

B

?B

couleur[B]

?A

couleur[A] ^= rouge

?A

Exemple 6

x

{x + y + z, x y z, ((((x^y)))^z)} /. {x -> 3, y -> 5, 
        z -> 4}

With[{x = 3, y = 5, z = 4}, {x + y + z, x y z, ((((x^y)))^z)}]

{x, y, z}

{A = 10, B = 20}

With[{A = 3, y = 5}, {A + B + y, A B y, A B}]

{A, B}

{A + B + y, A B y, A B} /. {A -> 3, y -> 5}

{A, B}

A = 3

Exemple 7

{X := A + π, Y = A + π};

{X, Y}

A = 5;

{X, Y}

{(((X + B))^2), (((Y + B))^2)}

{(((X + B))^2) /. B -> (1/2), (((Y + B))^2) /. B -> (1/2)}

Exemple 8

(2/3) - (7/(13 5 3))

(1 + (4/3)) 5

Exemple 9

2 (Sqrt[27]) - 8 (Sqrt[48])

N[%]

N[2 (Sqrt[27]) - 8 (Sqrt[48]), 50]

Exemple 10

(17./3)

(17/3)

a = (17./3)

5.666666666666666666

Clear [a]

Exemple 11

N[2 (Sqrt[27.]) - 8 (Sqrt[48]), 50]

Exemple 12

(((2 (Sqrt[3]) - 3 (Sqrt[2])))^2)

Expand[%]

Exemple 13

{(15.5/3), ((2 0.75 * (Sqrt[2]))/(3 3)), ((248 π)/2)}

Exemple 14

1/(1  -  i)  +  1/(1  +  i)

Exemple 15

Re[(1/I)]

Abs[(1/2) + ((I (Sqrt[3]))/2)]

Re[Exp[((I π)/4)]]

Im[Exp[((I π)/4)]]

Exemple 16

Head[3]

Head[(3/2) + (1/3)]

Head[(3/2) + (1/2)]

Head[(Sqrt[2])]

Head[π]

Head[3.]

Head[I]

Head[1 + I]

Head[(1/3)] === Rational

Head[3] === Rational

Head[3] === Real

OddQ[124545454589678512121548632975812458638778454685]

Exemple 17

MachineNumberQ[5]

MachineNumberQ[51256348975129654545455454758965485658921]

MachineNumberQ[512563489751296.54545455454758965485658921]

MachineNumberQ[51256348.5454758]

NumberQ[512563489751296.54545455454758965485658921]

Exemple 18

<< "CountRoots.m"

? CountRoots

CountRoots[(x^4) - 3, {x, -10, 10}]

Exemple 19

{"M"<>"1", "M"<>"2", "M"<>"3"}

Exemple 20

"M1" = 15

"M2" = Bonjour

"M3" = "Bonjour"

Exemple 21

ToExpression[{"M1", "M2"}];

couleur[M1] ^= violet;

coordonnées[M1] ^= {1, 4};

M2 := 2 A Cos[(π/4)] - B Sin[((2 π)/3)];

?M1

?M2

Clear [M1,  M2,  M3]

Exemple 22

Input["Donner un chiffre ou une lettre"]

Exemple 23

?Table

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

Table[(1/(i^2)), {i, 1, 10}]

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

Exemple 24

Table[i, {i, 1, 20, 2}]

Exemple 25

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

Exemple 26

Table[7 i, {i, 1, (100/7)}]

Exemple 27

Table[11 i, {i, 1, 13}]

Exemple 28

Table[(i^2) - ((3 i)/4), {i, 1, 12}]

Exemple 29

Table[Bonjour, {5}]

Exemple 30

Table["fichierRésultats"<>ToString[i], {i, 1, 12}]

Exemple 31

Table["M"<>ToString[i], {i, 1, 15}]

Table[ToExpression["M"<>ToString[i]], {i, 1, 15}]

Exemple 32

Plot[{(x^2) Sin[x], (x^2) Log[x]}, {x, 1, 6}];

Plot[Evaluate[Table[Sin[a x], {a, 1, 5}]], {x, 0, 2 π}];

Exemple 33

Solve[(x^4) - (x^3) + (x^2) - x + 1 == 0]

\(TraditionalForm
    \`{{x -> \@\(-1\)\%5}, {x -> \(-\((\(-1\))\)\^\(2/5\)\)}, {
        x -> \((\(-1\))\)\^\(3/5\)}, {
        x -> \(-\((\(-1\))\)\^\(4/5\)\)}}\)

{x1, x2, x3, x4} = x /. %;

x3

Clear[x1, x2, x3, x4]

Exemple 34

Solve[(x^4) - (x^3) + (x^2) - x + 1 == 0][[3
      ]]

Solve[{2 x + 3 y - 5 z == 1, 5 x + 7 y + 8 z == (1/3), 
        7 x + 2 y - 4 z == 5}, {x, y, z}]

{x, z} /. %

Exemple 35

matrice = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

MatrixQ[matrice]

MatrixQ[{{1, 2, 3}, {4, {3, 5}, 6}, {7, 8, 9}}]

Det[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}]

Det[Table[(1/(i (i + 1))), {i, j, j + 3}, {j, 2, 5}]]

Exemple 36

Table[(1/(i (i + 1))), {i, 2, 5}]

Table[(1/(i (i + 1))), {i, 3, 6}]

Table[(1/(i (i + 1))), {i, 4, 7}]

Table[(1/(i (i + 1))), {i, 5, 8}]

Table[(1/(i (i + 1))), {i, j, j + 3}, {j, 2, 5}]

\({{1\/6, 1\/12, 1\/20, 1\/30}, {1\/12, 1\/20, 1\/30, 1\/42}, 

      	{1\/20, 1\/30, 1\/42, 1\/56}, {1\/30, 1\/42, 1\/56, 1\/72}}\)

TableForm[%]

MatrixForm[%%]

Exemple 37

MatrixForm [Table[Prime[10 i + j], {i, 0, 20}, {j, 1, 10}]]

ListPlot[Table[Prime[i], {i, 1, 200}]];

Exemple 38

DSolve[{x'[t]==2 x[t] + 3 z[t] - 1,y'[t]==x[t] - 7 y[t] + z[t] - 6 u[t],z'[t]==-2 x[t] - 3 z[t] + 1,u'[t]==-2 x[t] + 12 y[t] - 2 z[t] + 10 u[t],x[0] == 1,y[0] == -1,z[0] == 1,u[0] == 1},{x[t], y[t], z[t], u[t]},t]

\({{x[t] -> E\^\(-t\)\ \((\(-4\) + 5\ E\^t)\), 
        y[t] -> 2 - 9\ E\^t + 6\ E\^\(2\ t\), 
		
        z[t] -> \(-E\^\(-t\)\)\ \((\(-4\) + 3\ E\^t)\), 
        u[t] -> \(-2\) + 12\ E\^t - 9\ E\^\(2\ t\)}}\)

3 Exp[t] y[t] + (t^2) u[t] /. %

Plot[%, {t, 0, 1}];

Exemple 39

Table[i, {i, 1, 12}] + 15

Exemple 40

liste1 = {x, y, z};liste2={x',y',z'};

a liste1 + b liste2

Exemple 41

Position[{1, (5^m), 2, 0, 3 a + (b^5), 0, (4^a), 0, 5, 0, 8, 71, 10}, 0]

Exemple 42

\(Cases[{1, 5\^m, 2, 0, 3\ a + b\^5, 0, 4\^a, 0, 5, 0, 8, 71, 10}, _\^_]
      \)

\(Cases[{1, 5\^m, 2, 0, 3\ a + b\^5, 0, 4\^a, 0, 5, 0, 8, 71, 10}, _
         + _\^_]\)

Exemple 43

Length[Characters[ToString[14587965321985642]]]

Length[Characters[ToString[50!]]]

Exemple 44

Reverse[Table[p, {p, 1, 15}]]

Exemple 45

salaire[1, 1] = 6578;

salaire[1, 2] = 6689;

salaire[1, 3] = 6950;

salaire[2, 1] = 7000;

salaire[2, 2] = 7000;

salaire[2, 3] = 7200;

salaire[3, 1] = 7300;

salaire[3, 2] = 7500;

salaire[3, 3] = 7985;

salaire[3, 2]

salaire[5, 3]

Table[salaire[i, j], {i, 1, 3}, {j, 1, 3}]

TableForm[Table[salaire[i, j], {i, 1, 3}, {j, 1, 3}]]

Flatten[Table[salaire[i, j], {i, 1, 3}, {j, 1, 3}]]

Table[salaire[x, y], {x, 1, 1}, {y, 1, 3}]

Table[salaire[x, y], {x, 1, 3}, {y, 2, 2}]

N[(103/100) Table[salaire[x, y], {x, 1, 3}, {y, 2, 2}]]

Table[salaire[i, j], {i, 1, 3}, {j, 1, 3}] - 200

Position[Table[salaire[x, y], {y, 1, 3}, {x, 1, 3}], 7300, 2]

Solve[(x^6) - 8 (x^5) + 26 (x^4) - 44 (x^3) + 39 (x^2) - 14 x == 0]

Map [Print, %];

Exemple 46

TableForm[
      Solve[(x^6) - 8 (x^5) + 26 (x^4) - 44 (x^3) + 39 (x^2) - 14 x == 0]]

Exemple 47

MapThread[
      StringJoin, {{"Jean", "Marie", "Paul", "Pierre"}, {
          " Dupont", " Duval", " Martin", " Lacour"}}]

TableForm[
      MapThread[
        StringJoin, {{"un ", "deux", "trois", "quatre", 
            "cinq", "six", "sept", "huit"}, {" <-> one", 
            " <-> two", " <-> three", " <-> four", 
            " <-> five", " <-> six", " <-> seven", 
            " <-> eight"}}]]

Exemple 48

bonhommeSignalisation[feuVert] = rouge;

bonhommeSignalisation[feuRouge] = vert;

bonhommeSignalisation[feuVert]

Exemple 49

homothétie[I_, k_][M_] := k (M - I) + I

homothétie[{1, -2}, 3][{2, 5}]

homothétie[{1, -2}, 3][{1, -2}]

homothétie[{1, -2}, 3][{-(2/3), 7.1}]

Exemple 50

f[x_] := (x^2) - ((3 x)/4)

f[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]

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

Array[f, 10]

Array[f[x], 4]

Exemple 51

TableForm[Table[{i + 5 (j^2)}, {i, 1, 6}, {j, 1, 5}]]

TableForm[Table[{i + 5 (j^2)}, {i, 1, 6}, {j, 1, 5}], 
      TableHeadings -> Automatic]

tableau = Table[f[i], {i, 1, 10}];

tableau[[9]]

tableau = Array[f, 10];

tableau[[3]]

tableau[[50]]

Exemple 52

n = 5;

Table[(i^2) - ((3 i)/4), {i, 1, n}]

n = 10;

Table[(i^2) - ((3 i)/4), {i, 1, n}]

Exemple 53

borne[variable_] := 3 /; OddQ[variable]

borne[variable_] := variable

Table[(i^2) - ((3 i)/4), {i, 1, borne[51]}]

Table[(i^2) - ((3 i)/4), {i, 1, borne[10]}]

Exemple 54

Union[{1, 1, 2, 1, 3, 5, 8}]

Intersection[{1, 1, 2, 1, 3, 5, 8}]

Exemple 55

liste1 = 
      Union[Characters[
          "les étudiants doivent savoir utiliser ces \
résultats pour le        dénombrement des p-listes \
d'éléments (des p-listes d'éléments        \
distincts deux à deux) d'un ensemble fini."]]

liste2 = 
      Union[Characters[
          "les étudiants doivent connaître les relations \
suivantes         ainsi que leur interprétation ensemblistes"]]

liste1 ⋂ liste2

liste1 ⋃ liste2

Length[liste1 ⋃ liste2] == 
      Length[liste1] + Length[liste2] - 
        Length[liste1 ⋂ liste2]

Exemple 56

IntervalIntersection[Interval[{-10 (Sqrt[2]), 25 (Sqrt[2])}], 
      Interval[{-((5 π)/3), 40}]]

IntervalUnion[Interval[{-10 (E^2), ((25 (Sqrt[2]))/7)}], 
      Interval[{-((25 π)/3), 40.56}]]

Exemple 57 & 58

((2 (x^3) - 3 (x^2) + 5)/(2 x + 1))

Simplify[
      (((((a + b))^4) - (((a - b))^4))/((((a + b))^2) - 
          (((a - b))^2)))]

Exemple 59

FullForm[2 (x^3) - 3 (x^2) + 5]

TreeForm[2 (x^3) - 3 (x^2) + 5]

TreeForm[((2 (x^3) - 3 (x^2) + 5)/(2 x + 1))]