Group Abstract Group Abstract

Message Boards Message Boards

Managing graphs and roots of polynomials with Manipulate

Posted 1 year ago
POSTED BY: Pincio Pinci

I don't know what it means, but this does not give errors:

Clear[calculatePolynomial, roots, numericValue]
calculatePolynomial[deg_, x_] := 
  Binomial[deg + 0, 2] + Sum[Binomial[deg + i, 2]  x^i, {i, 1, deg}];
roots[deg_] := x /. NSolve[calculatePolynomial[deg, x] == 0, x];
numericValue[deg_] := 
 Max[1, Round[Min[Abs[roots[deg] - deg]]]]; Manipulate[
 Column[{Show[
    Plot[calculatePolynomial[k, x], {x, 0, 13}, 
     PlotStyle -> Directive[Blue, Dashed, Thickness[thickness]], 
     Ticks -> {Range[0, 13, 1], Range[-2, 2, 1]}, 
     GridLines -> {Range[0, 13, 1], Range[-2, 2, 1]}, 
     GridLinesStyle -> Directive[Gray, AbsoluteDashing[{1, 1}]]], 
    Graphics[{Red, PointSize[pointSize], 
      Table[Point[{i, calculatePolynomial[k, i]}], {i, 0, 13}]}]], 
   Row[{"Per k=", k, ": n=", numericValue[k]}], 
   Row[{"Radici: ", 
     StringJoin@
      Riffle[Table[
        "k=" <> ToString[k] <> ", n=" <> ToString[n], {n, 
         Round[roots[k]]}], ", "]}]}], {{k, 1, "Parametro k"}, 1, 100,
   1, Appearance -> "Labeled"}, {{pointSize, 0.06, "point size"}, 
  0.01, 0.2},
  {{thickness, 0.03}, 0.01, 0.2}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard