Message Boards Message Boards

0
|
2616 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Is g a keyword?

Posted 9 years ago

Is g a keyword?

g[x_] := x^2
g[2]

generate an error. But if I replace g with f or h, I'll get 4. Why?

POSTED BY: steve ma
Posted 9 years ago

Perhaps you previously assigned some value to g.

Try

?g

and see what Mathematica has been told about g.

Or click Evaluation on the menu bar, then Quit the Kernel, then Local, then Quit and that should forget any prior assignments. Try your g[x_]:=x^2;g[2] after that.

Note: Sometimes Mathematica will consider two thing next to each other, sometimes even on two adjacent lines, as being multiplied together. Using semicolons to separate things will tell Mathematica those are two separate things and not to be multiplied.

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

Group Abstract Group Abstract