Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'How to convert the expression 3*x to a function?' topicStudent Support Forum > General > "How to convert the expression 3*x to a function?"

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
Peter Pein
10/21/12 5:19pm

Hi,

Bill's solution works of course but i guess you wanted to know why your attempt did not.

In[1]:= f = 3 x
Out[1]= 3 x
In[2]:= Function[x, f][Pi]
Out[2]= 3 x
does not work because Function does not evaluate its arguments:
In[3]:= Attributes[Function]
Out[3]= {HoldAll, Protected}

In[4]:= Function[x, Evaluate[f]][Pi]
Out[4]= 3 Pi

does what you expect.

Peter

URL: ,

Subject (listing for 'How to convert the expression 3*x to a function?')
Author Date Posted
How to convert the expression 3*x to a function? Pedro 10/20/12 07:07am
Re: How to convert the expression 3*x to a func... Bill Simpson 10/20/12 2:37pm
Re: How to convert the expression 3*x to a func... Peter Pein 10/21/12 5:19pm
< Previous CommentHelp | Reply To Comment | Reply To Topic