Demandes associées au chapitre-notebook: "calculs usuels"

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

Exemple 1

50!

(2.3^( 50))

(3^( 50))

((((2/3)))^50)

500!

((49!)/(50!))

((500!)/(490!))

(∏_(i = 491)^500) i

Product[i, {i, 491, 500}]

Exemple 2

(3^((3^3)))

((((3^3)))^3)

((((1254/2598)))^3)

((((125.4/2598)))^3)

Exemple 3

(1000/3) - 333

N[(1000/3) - 333]

Rationalize[%]

Rationalize[0.333333]

NestList[N[1000 #1 - 333]&, (1/3), 30]

NestList[1000 #1 - 333&, (1/3), 30]

NestList[N[1000 #1 - 333, 25]&, (1/3), 30]

NestList[N[1000 #1 - 333, 100]&, (1/3), 30]

ListPlot[%, PlotJoined -> True];

NestList[N[1000 #1 - 333, 100]&, (1/3), 50]

NestList[1000 #1 - 333.&, (1/3), 30]

ListPlot[%, PlotJoined -> True];

Exemple 4

(∑_(i = 1)^50) (1/(i^3))

N[%]

NSum[(1/(i^3)), {i, 1, 50}]

Timing [(∑_(i = 1)^50) (1/(i^3))]

Timing [N [(∑_(i = 1)^50) (1/(i^3))]]

Timing [NSum[(1/(i^3)), {i, 1, 50}]]

Timing[(∑_(i = 1)^300) (1/(i^3))]

Timing[N[(∑_(i = 1)^300) (1/(i^3))]]

Timing[NSum[(1/(i^3)), {i, 1, 300}]]

Timing[(∑_(i = 1)^1000) (1/(i^3))]

Timing[N [(∑_(i = 1)^1000) (1/(i^3))]]

Timing[NSum[(1/(i^3)), {i, 1, 1000}]]

valeurExacte  = 
       {{50,  0.0166667},  {300,  0.316667}, {1000,  3.75}}

\(valeurNExacte = 

      	{{50, \ 0.0166667}, \ {300, \ 0.3}, {1000, \ 3.43333}}\)

\(parNSum\  = 
	{{50, \ 0.2}, \ {300, \ 0.233333}, {1000, \ 2}}\)

Needs["Graphics`MultipleListPlot`"]

\(\(MultipleListPlot\ [
	valeurExacte, \ valeurNExacte, \ parNSum, 
	
      PlotJoined\  -> \ True, 
	
      PlotLegend\  -> 
        \ {"Exactes", \ 

          			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
          ColumnForm
            \ [{"Exactes", "puis", \ "approchées"}], 

          			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
          "Avec NSum"\ }, 
	LegendShadow\  -> \ {0.02, \(-0.02\)}, 
	
      LegendPosition\  -> \ {\(-0.5\), \ 0.1}]; \)\)

Clear [valeurExacte,  valeurNExacte,  parNSum]

Petits services &Co

9 (x^4) - (y^4) + 2 (y^2) /. {x -> 10864, y -> 18817}

9 (x^4) + 2 (y^2) - (y^4) /. {x -> 10864, y -> 18817}

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

Expand[(3 (x^2) + (y^2)) (3 (x^2) - (y^2)) + 2 (y^2)]

Exemple 5

x[0] = 0; x[1] = 1;

x[n_] := x[n] = x[n - 1] + x[n - 2]

x[40]

Solve[(x^2) == x + 1]

Solve[{a + b == 0, 
        (1/2) a (1 + (Sqrt[5])) + (1/2) b (1 - (Sqrt[5])) == 1}, {a, b}]

Expand[
      (((((1/2) (1 + (Sqrt[5]))))^40)/(Sqrt[5])) - (((((1/2) (1 - (Sqrt[5]))))^40)/(Sqrt[5]))]

Expand[((((1/2) (1 - (Sqrt[5]))))^40)]

Exemple 6

\(TableForm[
      Table\ [Expand[\((1/2*\((1\  - \ Sqrt[5])\))\)^i], \ 

        \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {i, \ 1, \ 20}], \ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
      TableHeadings\  -> 
        \ {Table["i = " i " -> ", \ {i, \ 1, \ 20}]}, \ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
      TableSpacing\  -> \ {2}]\)

Cases[
      Table[Expand[((((1/2) (1 - (Sqrt[5]))))^i)], {i, 1, 20}], _Integer
         + _Integer (Sqrt[5])]

With[{liste = Table[Expand[((((1/2) (1 - (Sqrt[5]))))^i)], {i, 1, 20}]}, 
      (Position[liste, #1]&)/@Cases[liste, _Integer + _Integer (Sqrt[5])]]

foo[n_] := 
      Cases[Table[Expand[((((1/2) (1 - (Sqrt[n]))))^i)], {i, 1, 20}], _Integer
           + _Integer (Sqrt[n])]

Table[foo[n], {n, 2, 20}]

With[{
        liste = Table[Expand[((((1/2) (1 - (Sqrt[13]))))^i)], {i, 1, 20}]}, 
      (Position[liste, #1]&)/@Cases[liste, _Integer + _Integer (Sqrt[13])]]

Table[foo[n], {n, 20, 30}]

foofoo[n_] := 
      With[{liste = Table[Expand[((((1/2) (1 - (Sqrt[n]))))^i)], {i, 1, 20}]}, 
        (Position[liste, #1]&)/@Cases[liste, _Integer + _Integer (Sqrt[n])]]

foofoo[21]

foofoo[29]

Table[foo[n], {n, 31, 40}]

foofoo[37]

Clear[foo, foofoo]

((a + (Sqrt[2]) b)/(c + (Sqrt[2]) d))

Simplify[
      Expand[(a + b (Sqrt[2])) (c - d (Sqrt[2]))]/Expand[
          (c + d (Sqrt[2])) (c - d (Sqrt[2]))]]

Numerator[%] /. {x_ (Sqrt[2]) + y_ (Sqrt[2]) -> (x + y) (Sqrt[2])}

Exemple 7

$RecursionLimit

x[300]

$RecursionLimit = 400;

Clear[x]

x[0] = 0; x[1] = 1;

x[n_] := x[n] = x[n - 1] + x[n - 2]

x[300]

Clear[x]

$RecursionLimit = 256;

Exemple 8

N[(1/2) (1 - (Sqrt[5])) + (1/2) (1 + (Sqrt[5]))]

N[(((((1/2) (1 + (Sqrt[5]))))^40)/(Sqrt[5])) - 
        (((((1/2) (1 - (Sqrt[5]))))^40)/(Sqrt[5]))]

AccountingForm[%]

N[(((((1/2) (1 + (Sqrt[5]))))^40)/(Sqrt[5])) - 
        (((((1/2) (1 - (Sqrt[5]))))^40)/(Sqrt[5])), 50]

AccountingForm[%]

N[(((((1/2) (1 + (Sqrt[5]))))^40)/(Sqrt[5])) - 
        (((((1/2) (1 - (Sqrt[5]))))^40)/(Sqrt[5])), 5]

AccountingForm[%]

Exemple 9

N[(1/9), 30]

N[(10/99), 30]

N[(100/999), 30]

N[(1000/9999), 30]

N[(2/9), 30]

N[(222/999), 30]

N[(272/999), 30]

N[(26/7), 30]

31.58 + 0.00272272272272272272272272272272272...

\(TraditionalForm
    \`3158\/100 + 0.00272272272272272272272272272272272...\)

(3158/100) + (272/(100 999))

N[(3158/100) + (272/(100* 999)), 30]

27.6345858585858585858585858585858585858...

(27634/1000) + (58/(1000 99))

N[(27634/1000) + (58/(1000* 99)), 30]

((3158/100) + (272/(100 999))) 
      ((27634/1000) + (58/(1000 99)))

N[%, 30]

31.5827227227227227 27.6345858585858

N[(269744893873/309065625), 500]

\(\(aEtudier = 
	ToString\ \ [N[269744893873\/309065625, 500]]; \)\)

aEtudier

StringPosition[aEtudier, "32"]

StringTake[aEtudier, {50, 103}]

StringTake[aEtudier, {104, 157}]

StringPosition[aEtudier, "32"]

First/@%

RotateLeft[%] - 1

MapThread[
      StringTake[aEtudier, {#1, #2}]&, {{50, 104, 158, 212, 266, 320, 374, 
          428}, {103, 157, 211, 265, 319, 373, 427, 481}}]

Print/@%;

Union[%%][[1]]

périodeInitiale = Characters[%]

liste1 = Characters[StringTake[aEtudier, {1, 49}]]

repèreDifférences[liste1_, liste2_] := 
      With[{dernier1 = Last[liste1], dernier2 = Last[liste2]}, 
        If[dernier1 === dernier2, 
          repèreDifférences[Drop[liste1, -1], 
            Drop[liste2, -1]], {Position[liste1, dernier1], 
            Position[liste2, dernier2]}]]

repèreDifférences[liste1, périodeInitiale]

partieIrrégulière = 
      StringTake[aEtudier, 
        %[[1]][[1
            ]][[1]]]

coupure = 
      Last[Last[
            repèreDifférences[liste1, 
              périodeInitiale]]][[1
        ]]

premierBout = Take[périodeInitiale, coupure]

deuxièmeBout = 
      Take[périodeInitiale, {coupure + 1, 
          Length[périodeInitiale]}]

période = Join[deuxièmeBout, premierBout]

Clear[aEtudier, périodeInitiale, liste1, 
      repèreDifférences, partieIrrégulière, 
      coupure, premierBout, deuxièmeBout, période, f]

f[x_][n_] := (∑_(k = 0)^n) (x^k)

TableForm[Table[f[x][n], {n, 1, 10}]]

Plot[
      Evaluate[{(1/(1 - x)), Table[f[x][n], {n, 0, 10}]}], {x, -0.1, 
        0.9}, PlotRange -> {0, 10}, 
      PlotStyle -> {{}, Table[Dashing[{0.008}], {n, 0, 10}]}];

Plot[
      Evaluate[{(1/(1 - x)), Table[f[x][n], {n, 0, 10}]}], {x, -0.1, 
        2}, PlotRange -> {-5, 10}, 
      PlotStyle -> {{}, Table[Dashing[{0.008}], {n, 0, 10}]}];

Plot[
      Evaluate[Table[((x^(n + 1))/(1 - x)), {n, 0, 10}]], {x, -0.1, 
        0.9}, PlotRange -> {0, 1}, 
      PlotStyle -> {{}, Table[Dashing[{0.005}], {n, 0, 10}]}];

(1/0.4) - (1 + 0.6 + (0.6^2) + ... + (0.6^10)) < 0.04

N[(1/0.4) - (∑_(n = 0)^10) (0.6^n)]

Exemple 10

?Sort

Sort[{4, -5, (1/2), N[((Sqrt[2])/2)], -N[(π/2)], 10, 0.1, (1/(10^5))}]

Exemple 11

Sort[{M1, M9, M18, M4, M5, M6, M3, M8, M9, M10, M215, M125, M23}]

Sort[{M1, M2, m2, M5, m1, M237, m0, m125}]

Sort[{"M5", "M10", "M3", "M1"}]

Sort[{M5, M10, M3, M1}]

Sort[{"M5", M10, "M3", "M1", M6, M2, M7}]

Sort[{"M5", M10, "M3", "M1"}]

Sort[{"M5", a, "M3", "M1"}]

Sort[
      ToExpression[
        (StringDrop[#1, 1]&)/@
          ToString/@{M1, M2, M8, M5, M1254, M237, M125}]]

Table["M", {Length[{M1, M2, M8, M5, M1254, M237, M125}]}]

MapThread[StringJoin, {%, ToString/@%%}]

foo[liste__] := 
      With[{l = liste}, 
        MapThread[
          StringJoin, {Table["M", {Length[l]}], 
            ToString/@
              Sort[ToExpression[(StringDrop[#1, 1]&)/@ToString/@l]]}]]

foo[{M1, M2, M8, M5, M1254, M237, M125}]

foo[{"M1", "M12452", "M50", "M8", "M1275", 
        "M237", "M1254"}]

Clear[foo]

Exemple 12

Sort[{4, -5, (1/2), N[((Sqrt[2])/2)], -N[(π/2)], 10, 0.1, (1/(10^5))}, 
      Abs[#1] < Abs[#2]&]

Exemple 13

Sort[
      Select[{"a5", "v", "a1", (9/2), 0.1, jj, "gh", 
          "a3"}, StringMatchQ[ToString[#1], "a*"]&]]

Sort[
      Select[{"a5", "bi", "a1", ((9 a)/2), 0.1 k, jj, 
          "gh", "a3", a10}, StringMatchQ[ToString[#1], "a*"]&]]

Sort[
      Select[{"a5", "bi", "a1", ((9 a)/2), 0.1 k, jj, 
          "gh", "a3", "a10"}, 
        StringMatchQ[ToString[#1], "a*"]&]]

Exemple 14

With[{
        liste = {"a5", "v", 5, "a1", (9/2), 0.1, jj, "gh", 
            "a3"}}, 
      Join[Sort[Select[liste, StringMatchQ[ToString[#1], "a*"]&]], 
        Sort[Select[liste, NumberQ]]]]

Exemple 15

\(foo[couleur_] := 
      With[{liste = {10, 2\/3, N[π], 0.01}}, 
        Switch[couleur, 
rouge, Sort[liste], 
bleu, Sort[ToString/@liste], 
          
vert, Sort[liste, 1\/#1 < 1\/#2&], 
_, auRevoir]]\)

foo[rouge]

foo[bleu]

foo[vert]

foo[bonjourChezVous]

Exemple 16

?Abs

Abs[-1]

Abs[1 - (Sqrt[3])]

Abs[1 - N[(Sqrt[3])]]

Abs[1 + I]

Abs[Exp[-((I π)/4)]]

Abs[(((1 - I) Exp[-((2 I π)/3)])/(1 + I))]

Select[{I, 1 - I, 1 + I, (1/2) (1 + I (Sqrt[3])), -(5/3), 
        2 - (a/5) /. a -> 5, Exp[0]}, Abs[#1] == 1&]

{I, 1 - I, 1 + I, (1/2) (1 + I (Sqrt[3])), -(5/3), 
      2 - (a/5) /. a -> 5, Exp[0]}

z[n_] := (((n^2) Exp[(((n + 1) I π)/n)])/(n + 2))

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

(Re[#1]&)/@%

(Im[#1]&)/@%%

imagesPoints = 
      Show[Graphics[Point/@MapThread[List, {%%, %}]], Axes -> True, 
        DisplayFunction -> Identity, 
        PlotLabel -> "Images des points"];

Abs/@Table[z[i], {i, 1, 10}]

modules = 
      ListPlot[%, DisplayFunction -> Identity, 
        PlotLabel -> "Modules", PlotRange -> {0, 10}];

Show[
      GraphicsArray[{{imagesPoints}, {modules}}, 
        DisplayFunction -> $DisplayFunction]];