# Trouble defining a function

Posted 9 years ago
4333 Views
|
3 Replies
|
4 Total Likes
|
 Hey Can someone tell what I do wrong? Above in line 20 i want to define a function f(x). And then i want to calculate f(2). But nothing happens. Why? 3 Replies
Sort By:
Posted 9 years ago
 You are making progress. That is very good.Here is what I enter into Mathematica In:= f[x_] := x + 1 In:= f Out= 3 In:= f[a] Out= 1 + a The In[ number ] := and Out[ number] = are supplied by Mathematica and I do not type those.At the end of each line I press and hold Shift while pressing Enter. That tells Mathematica to do the work for that line. For the first line that just tells Mathematica to remember your definition and it displays nothing. For the second line you are asking it to calculate f[ 2 ] and it prints the third line of 3. The next two lines are similar.I will try to attach a notebook that you may be able to download and read into Mathematica by double clicking on it or by opening Mathematica and then clicking File and then Open... and selecting the file from where it was downloaded to your computer.If you have more questions then please ask and I will answer later today. Attachments:
Posted 9 years ago
 "=" beginning a line sends the rest of the line to WolframAlpha.com. Mathematica displays the beginning "=" in orange to show the rest of the line was sent to WolframAlpha.com. WolframAlpha.com does not understand or support function definitions.Try the same without pressing "=" at the beginning of the line. That will send the line to Mathematica, which is different, and understands function definitions.
Posted 9 years ago
 Hi BillThx for your answer, but I can not make it work. I am now trying to define a function in first line without starting with a "=". And then in next line i type ind f. How do I make mathematica to respond and calculate f=1+2? 