1
$\begingroup$

From the documentation:

Manipulate[Plot[f[x], {x, 0, 2 Pi}], {f, {Sin, Cos, Tan, Cot}}]

How do I include a function like $1/x$ or $x^2$, etc. in that list?

I (unsuccessfully) tried 1/# and #^2.

$\endgroup$
2
  • $\begingroup$ Maybe #^2 & -> x^2, 1/# & -> 1/x, as you also might want the labels for the pure functions? $\endgroup$ Feb 1, 2013 at 16:12
  • 1
    $\begingroup$ @PinguinDirk: ugh, I had forgotten my closing &. Thanks. If you post as an answer, I can accept. $\endgroup$
    – JohnD
    Feb 1, 2013 at 16:18

2 Answers 2

7
$\begingroup$

As discussed in comments, here's a possible approach:

Manipulate[
Plot[f[x], {x, 0, 2 Pi}], {f, {Sin, Cos, Tan, Cot, #^2 & -> x^2, 
1/# & -> "1/x"}, ControlType -> SetterBar}]

Which results in:

enter image description here

$\endgroup$
1
$\begingroup$

This works.

Manipulate[Plot[f[x],{x,0,2 Pi}],{f,{Sin[#]^2 &,#^2&,Cos,Tan,Cot}}]

David.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.