1
$\begingroup$

I have this code:

fundamentalSol[p_, q_] := (1/(2 Pi))*Log[Norm[p - q]]
point = {1, 0.5};
GduY0[x_?NumericQ] := D[fundamentalSol[{x, 0} - point], x];
dGduY1[x_?NumericQ] := D[fundamentalSol[{x, 1} - point], x];
dGduX1[y_?NumericQ] := D[fundamentalSol[{1, y} - point], y];
I1 = NIntegrate[dGduY1[x]*x, {x, 0, 1}];
I2 = NIntegrate[dGduX1[y], {y, 1, 0}];
I3 = NIntegrate[dGduY0[x]*x, {x, 1, 0}];
H = -(I1 + I2 + I3);
N[H];

which is supposed to represent

$$H = -\left( \int_{0}^{1} x \frac{\partial{G([x,0] - p)}}{\partial{x}} dx + \int_{1}^{0} \frac{\partial{G([1, y] - p)}}{\partial{x}} dy + \int_{1}^{0} x \frac{\partial{G([x,0] - p)}}{\partial{x}} dx\right)$$

where $G$ is the fundamental solution function described above. However, I get many warning messages:

enter image description here

I tried using NumericQ, but it doesn't seem to fix this issue. The integral doesn't need to be symbolic, I just want a numeric output.

$\endgroup$
1
  • 3
    $\begingroup$ The functions are dGduY0, dGduY1, and dGduX1 do not give numerical results. Those functions use fundamentalSol wrong (with one argument, not two, as defined.) Also, you have to differentiate symbolically first and then evaluate the derivative with a numerical value. $\endgroup$ Feb 17 at 1:32

1 Answer 1

1
$\begingroup$

Consider:

GduY0[0]

what gives an error message:

enter image description here

Now the definition of GduY0 is:

GduY0[x_?NumericQ] := D[fundamentalSol[{x, 0} - point], x];

For GduY0[0] this evaluates to:

D[fundamentalSol[{0, 0} - point], 0]

what explains the error message. To make this work you must introduce a dummy variable for the derivative like e.g.:

GduY0[x_?NumericQ] := D[fundamentalSol[{xx, 0} - point], xx]/. xx->x;

The next problem you have is, that Norm does not have a derivative. I think you mean "RealAbs" in the definition of fundamentalSol.

$\endgroup$

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.