Message Boards Message Boards

Interpolating functions as output for NDSolve[ ]

Posted 2 years ago

Working with the pde numeric solvers.

If I use a statement like:

sol = NDSolveValue[{op == 0, pbc, Subscript[\[CapitalGamma], Dc]}, 
  u, {x, y} \[Element] \[CapitalOmega]]

I will get back an interpolating function and I can do things like sol[3,4] to pull values from the function.

If I use the form

sol = NDSolveValue[{op == 0, pbc, Subscript[\[CapitalGamma], Dc]}, 
  u[x, y], {x, y} \[Element] \[CapitalOmega]]

I get back an interpolating function with [x,y] appended at the end. If I try sol[3,3] the output just appends [3,3] to the end.

How ever statements like: ContourPlot[sol, {x,-1,4},{y,0,4}] still work.

Can someone point me in the right place to understand why the two outputs are different?

Thanks

POSTED BY: Edward Davis

In the second form to get the values at specific points you can write sol/.{x->3,y->3}, or else redefine sol with arguments:

sol[x_,y_] = NDSolveValue[{op == 0, pbc, Subscript[\[CapitalGamma], Dc]}, 
  u[x, y], {x, y} \[Element] \[CapitalOmega]]

It is similar to the difference between f = Function[x,x^2] and f=x^2. With the former you can call f[1], but not with the latter.

POSTED BY: Gianluca Gorni
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