1
$\begingroup$

enter image description here

The following code is from the Mathematica demonstration of Horner's method, I am wondering if anyone can help me remove the 2nd row in the table of the demonstration

Manipulate[
     Module[{examp},
      If[k > n, k = 0]; 
      aa = Join[{RandomInteger[{1, 4}]}, RandomInteger[{-2, 3}, n]]; 
      SeedRandom[ranint]; examp = bb[n, d, aa, k]; 
      Pane[Text@
        Column[{"", 
          TraditionalForm[
           Row[{Style["P", Italic], "(", x, ")"}] == 
            Take[ppp, n + 1].Reverse[aa]], "", 
          Grid[examp, Frame -> All, ItemSize -> 3], "", 
          If[k == n, 
           Column[{TraditionalForm[
              Row[{Style["P", Italic], "(", d, ")"}] == 
               examp[[3, n + 2]]], 
             TraditionalForm[
              Row[{Style["Q", Italic], "(", x, ")"}] == 
               Take[ppp, n].Reverse[Take[examp[[3]], {2, n + 1}]]]}]]}], 
       Alignment -> Center, ImageSize -> {400, 200}]
      ],
     {aa, {RandomInteger[{-5, 5}, 4]}, ControlType -> None},
     {{n, 4, Style["n", Italic]}, 
      Range[2, 6]}, {{d, 1, Style["u", Italic]}, {-3, -2, -1, 1, 2, 3, 4},
       ControlType -> SetterBar}, {ranint, RandomInteger[{1, 19977}], 
      ControlType -> None}, 
     Button["new polynomial", ranint = RandomInteger[{1, 1000}]; 
      aa = Join[{RandomInteger[{1, 4}]}, RandomInteger[{-5, 5}, n]]; 
      k = 0],
     Dynamic@Control[{{k, 0, Style["k", Italic]}, Range[0, n], 
        ControlType -> SetterBar}], SynchronousUpdating -> True, 
     SynchronousInitialization -> True,
     Initialization :> (
       pp[n_] := Table[x^i, {i, 0, n}]; ppp = Table[x^i, {i, 0, 6}]; 
       bb[n_, d_, aa_, 0] := {Join[{"  "}, aa], 
         Join[{"", ""}, Table["", {n}]], 
         Join[{d, aa[[1]]}, Table["", {n}]]};
       bb[n_, d_, aa_, k_] := 
        Module[{bbb = bb[n, d, aa, k - 1], bk, ck}, 
         bk = d  bbb[[3, k + 1]]; ck = bbb[[1, k + 2]] + bk;
         ReplacePart[bbb, {{2, k + 2} -> bk, {3, k + 2} -> ck}]])]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.