2
$\begingroup$

Here is a minimal working example:

f = FunctionInterpolation[
  Evaluate[Table[D[Sin[x - y], {{x, y}, k}], {k, 0, 1}]], {x, 0., 
   20.  Pi}, {y, 0., 20.  Pi}]
Plot3D[{f[x, y] - Sin[x - y]}, {x, 0, 20 Pi}, {y, 0, 20 Pi}]

I don't know whether this is a maths problem or MMA problem, but MMA cannot capture the fact that the function is only a function of the difference of two variables. This thing can of course still be redundantly expressed as a function of two variables, so FunctionInterpolation should be able to handle it anyways.

(The actual example has a function which is approximately dependent only on the difference and I do care about the deviance from this behaviour.)

$\endgroup$

1 Answer 1

6
$\begingroup$

The spacing of points in Table[...] is 1. For function like Sin with a period of 2Pi the resolution is too small. Increase the point density and it will work.

f = FunctionInterpolation[
  Evaluate[Table[D[Sin[x - y], {{x, y}, k}], {k, 0, 1}]], {x, 0, 
   20   Pi, Pi/5}, {y, 0, 20   Pi, Pi/5}]
Plot3D[{f[x, y] - Sin[x - y]}, {x, 0, 20  Pi}, {y, 0, 20  Pi}]

enter image description here

$\endgroup$
5
  • $\begingroup$ Thanks! Clarify please what you mean "the spacing of points in table is 1". The only table I use explicitly is the one for the derivative. I did not even know MMA used a table in Functioninterpolation, much less 1 as a step size. It should depend on the range specified no? $\endgroup$ Commented Jul 30 at 7:54
  • 1
    $\begingroup$ @DanielHuber Where did you find information concerning increment -option of the grid x,y? $\endgroup$ Commented Jul 30 at 10:43
  • 1
    $\begingroup$ Alternatively, you can also increase the order of derivatives, for example {k, 0, 3}. $\endgroup$
    – Domen
    Commented Jul 30 at 11:10
  • $\begingroup$ @Ulrich Neumann I made a guess and tried it and it worked. $\endgroup$ Commented Jul 30 at 19:43
  • $\begingroup$ @DanielHuber Very clever! $\endgroup$ Commented Jul 31 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.