Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.8K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

[Solved] Apply a List of Functions to Plot[..]

Posted 5 years ago

How do I make (2) Work?

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

diff[f_, n_] := D[f[x], {x, #}] & /@ Range[0, n]

diff[f, 3]

{3 + (2 - x)^2, -2 (2 - x), 2, 0}

**(1)** Plot[{3 + (2 - x)^2, -2 (2 - x), 2, 0}, {x, 0, 4}, PlotLegends -> "Expressions"] -- works

**(2)** Plot[abl[f, 3], {x, 0, 4}, PlotLegends -> "Expressions"] -- doesn't work
POSTED BY: Romeo Disca
2 Replies
Posted 5 years ago

Hi Romeo,

I assume you mean Plot[diff[f, 3], ... not Plot[abl[f, 3], ....

Plot has the HoldAll attribute

Attributes@Plot
(* {HoldAll, Protected, ReadProtected} *)

so none of it's arguments are evaluated. Try

Plot[Evaluate@diff[f, 3], {x, 0, 4}, PlotLegends -> "Expressions"]

enter image description here

POSTED BY: Rohit Namjoshi
Posted 5 years ago

Many Thanks, Roshit

POSTED BY: Romeo Disca
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard