Message Boards Message Boards

0
|
5984 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to implement Plot3D on a result of operator?

Posted 10 years ago

Hello

Can you please address the following question?

I would like to implement Plot3D on a result of an operator. Specifically, please find below the following code, which consists of the following:

  • define a Laplacian operator in 2D

  • calculate the result of applying it to the specified function

  • apply Plot3D

        oper = (D[#1, x, x] + D[#1, y, y]) &;
        f[x, y] == oper[Sin[x] Sin[y]];
        Plot3D[oper[Sin[x] Sin[y]], {x, 0, 10}, {y, 0,10}]
    

    The code above fails to plot. However, the following code succeeds

        oper = (D[#1, x, x] + D[#1, y, y]) &;
        f[x, y] == oper[Sin[x] Sin[y]];
        Plot3D[oper[Sin[x] Sin[y]] /. {x -> k, y -> l}, {k, 0, 10}, {l, 0,10}]
    

Can you please indicate why avoiding replacement doesn't work?

POSTED BY: Shimon Rubin
2 Replies

Hello, I am not sure what the purpose of "f[x, y] == oper[Sin[x] Sin[y]];" is for, but this will work:

oper = (D[#1, x, x] + D[#1, y, y]) &

Plot3D[Evaluate[oper[Sin[x] Sin[y]]], {x, 0, 10}, {y, 0, 10}]

Plot and related functions have the property of HoldFirst---the upshot is that you need to Evaluate explicitly.

I think if you google Mathematica and Plot and Evaluate, you will see some excellent discussions of this.

POSTED BY: W. Craig Carter
Posted 10 years ago

Thank you very much for the answer.

POSTED BY: Shimon Rubin
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