Why doesn't this work:
Manipulate[
Plot[{Normal[Series[Sin[x], {x, 0, n}]], Sin[x]}, {x, -10 Pi,
10 Pi}, PlotRange -> 2], {n, 1, 100, 1}]
I can do this to make it work as intended:
p[x_, n_] := Normal[Series[Sin[y], {y, 0, n}]] /. y -> x
Manipulate[
Plot[{p[x, n], Sin[x]}, {x, -10 Pi, 10 Pi}, PlotRange -> 2], {n, 1,
100, 1}]
Any information would be helpful.
Because the Series commands does not like 'x' to be number. You are
using x in the range, and are also using x inside the series command.
Try something like for now
Manipulate[
Plot[{Normal[Series[Sin[z], {z, 0, n}]] /. z -> x,
Sin[x]}, {x, -10 Pi, 10 Pi}, PlotRange -> 2], {n, 1, 100, 1}, {z,
ControlType -> None}]
--Nasser
Hi Daniel, I try to help you and Mathematica gurus will correct me if
I'm wrong.
The problem is that the Plot function has the attribute HoldHall as
you can see running Attributes[Plot]. Functions with this attribute
receive their arguments unevaluated. This is useful because in this
way you can execute successfully coomands as Plot[Sin[x],{x,0,1}]
though you have previously set e.g x=1. If Plot had not this attribute
the previous command would be equivalent to Plot[Sin[1],{1,0,1}] and
Plot would fail.In your situation Plot will receive
{Normal[Series[Sin[x], {x, 0, 3}]], Sin[x]} and not {x - x^3/6,
Sin[x]} if you set n=3. Presumably in evaluating the value of the
function you passed to it at a particular point,e.g. 0, Plot will
execute {Normal[Series[Sin[x], {x, 0, 3}]], Sin[x]}/.x->0 obtaining
{Normal[Series[Sin[3], {0, 0, 3}]], Sin[0]} that is not what you want
and will cause an error in Series function.
however there is a way to go round HoldHall attribute. You just have
to wrap with Evaluate the argument that you want to be evaluated. So
Manipulate[
Plot[Evaluate@{Normal[Series[Sin[x], {x, 0, n}]],
Sin[x]}, {x, -10 Pi, 10 Pi}, PlotRange -> 2], {n, 1, 100, 1}] will
work fine.
In my experience misunderstaning of the order of evaluation of
expressions in Mathematica is one of the most common source of errors
and programming in Mathematica at a more than trivial level without a
sufficient understanding of this argument can be a nightmare.I
recommend to you the sections of Mathematica guide in the chapter
http://reference.wolfram.com/mathematica/tutorial/EvaluationOfExpressionsOv=
erview.html
hope been useful
Andrea Mercuri
Manipulate[Plot[
Evaluate[{Normal[Series[Sin[x], {x, 0, n}]], Sin[x]}],
{x, -10 Pi, 10 Pi},
PlotRange -> 2],
{n, 1, 100, 1, Appearance -> "Labeled"}]
Bob Hanlon
---- Daniel <brid...@gmail.com> wrote:
=============