Message Boards Message Boards

0
|
4472 Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Mathematica syntax errors

Posted 12 years ago
Identify and correct the syntax errors in the following expression and plot the function a(x,y)
Clear [a]
a[x,y] = ArcTan (x^2 - 2 xy + y^2) +Sin[Pixy]
Plot[a, {x,-1,1},{y, -1, 1}]

how do i correct and plot this!?
POSTED BY: paul robinson
5 Replies
Posted 12 years ago
thank you so much,

does this look better?
Clear[a];

a[x_, y_] = ArcTan [x^2 - 2 x y + y^2] + Sin[Pi x y];

Plot3D[a[x, y], {x, -1, 1}, {y, -1, 1}]
POSTED BY: paul robinson
Clear;
does nothing.  If you want to clear the value of a specific symbol, use
Clear[a];

If you want to clear all values of all user-created symbols, use
Clear["Global`*"]
POSTED BY: Bruce Miller
Sorry.  Formatting glich (being worked on). 
If you put square brackets in regular text, they can disappear.

To make sure thay appear in code, highlight the code and click the little spikey in the
formatting tools above the text input area. This formats the selected text as Mathematica code.

POSTED BY: Bruce Miller
POSTED BY: C ormullion
Presumably you want some hints, rather than the answer (learning is not as effective otherwise)? So:

1 - functions require square brackets, even if there are no arguments
2 - some functions require arguments
3 - Plot plots a function as a function of a single variable (not two)
4 - variables supplied as arguments to a 'function' are bound using patterns with underscore characters on the Left Hand Side
5 - the multiplication sign can be replaced with a space between two operands
6 - Plot3D plots a function as a function of two variables
POSTED BY: C ormullion
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