0
$\begingroup$

I am starting to use Mathematica. I wanted to compute $$\nabla F*\phi(x),\;x\in\mathbb{R^2}$$ where $F(x)=\ln\|x\|$ and $\phi(x)=\chi_{B(0,2)}(x)$.

I am a new user of this software, so I don't know advanced commands yet. The code that I have used is:

F[x_, y_] = 1/2*Log[x^2 + y^2];
g[x_, y_] = Piecewise[{{1, x^2 + y^2 <= r}, {0, True}}]
C[z1_, z2_] = Convolve[Grad[F[x, y], {x, y}], g[x, y]

The problem is that this doesn't return any value after two hours of computation. Could someone tell me how can I solve this?

EDIT: I add some information about what I want to do, expecting that this can help to get a way to make this convolution.

After that I will need to compute the integral of the product of $C$ and certain function. Concretely, I want to compute the following line integral over the border of the disk $D(0,2)$

$$\int_{C(0,2)}F*g(x)\nabla F *g(x)\cdot n(x), $$ where $n$ denotes the normal vector. The only way that I know to compute this is:

    F[x_, y_] = 1/2*Log[x^2 + y^2];
    g[x_, y_] = Piecewise[{{1, x^2 + y^2 <= r}, {0, True}}]
    C[z1_, z2_] = Convolve[Grad[F[x, y], {x, y}], g[x, y]
    C1[z1_, z2_] = Convolve[F[x, y], g[x, y], {x, y}, {z1, z2}]
    NIntegrate[ C1[r*Cos[s], r*Sin[s]]* Dot[C[r*Cos[s], r*Sin[s]], {r*Cos[s], r*Sin[s]}]  , {s, 0, 2*Pi}]
$\endgroup$
7
  • $\begingroup$ A big edit to the question should be described. $\endgroup$
    – user64494
    Commented Feb 27, 2022 at 16:02
  • $\begingroup$ Sorry, it is my first question here. I hope it is better now $\endgroup$
    – prosep
    Commented Feb 27, 2022 at 16:05
  • $\begingroup$ Please, indicate the substantial change you made in the question. $\endgroup$
    – user64494
    Commented Feb 27, 2022 at 16:10
  • $\begingroup$ Done! Sorry. I hope this helps to get an answer to my question $\endgroup$
    – prosep
    Commented Feb 27, 2022 at 16:20
  • $\begingroup$ 1. The functions $w,n$ and the integral $$\int_{C(0,2)}F*w(x)\nabla F *w(x)\cdot n(x) $$ are not defined. 2. Ask a separate question instead of your edit. $\endgroup$
    – user64494
    Commented Feb 27, 2022 at 16:23

1 Answer 1

0
$\begingroup$

First, the convolution is defined for functions, but Grad[F[x, y], {x, y}] is a vector. Second,

F[x_, y_] := 1/2*Log[x^2 + y^2];
g[x_, y_,r_] := Piecewise[{{1, x^2 + y^2 <= r}, {0, True}}];
Convolve[Grad[F[x, y], {x, y}][[1]], g[x, y,r], {x, y}, {z1, z2}, 
Assumptions -> r > 0]

returns the input. Therefore, the convolution should be realized numerically, making use of its definition:

c[r_?NumericQ, z1_?NumericQ, z2_?NumericQ] := 
NIntegrate[Grad[F[x, y], {x, y}][[1]]*g[x - z1, y - z2,r], {x, -Infinity, 
Infinity}, {y, -Infinity, Infinity},AccuracyGoal -> 4, PrecisionGoal -> 4, 
Method -> "LocalAdaptive"]
c[2, 2, -1]

2.2144

I leave the second coordinate of the gradient on your own.

Addition.

c[r_?NumericQ, z1_?NumericQ, z2_?NumericQ] := 
NIntegrate[(Evaluate[Grad[F[x, y], {x, y}]][[1]])*
g[x - z1, y - z2, r], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, 
Method -> "LocalAdaptive"]
c[2, 2, -1]

2.51328

We see NIntegrate leaves much to be desired.

$\endgroup$
4
  • $\begingroup$ Thanks for your answer. I understand the convolution of a vector and a a function as: $(F_1,F_2)*f=(F_1*f,F_2*f)$. I edit the question to clarify what I want to do. $\endgroup$
    – prosep
    Commented Feb 27, 2022 at 15:31
  • $\begingroup$ Thanks for your answer BTW. I'm not sure I understood your answer correctly, so there is no way to calculate this convolution? $\endgroup$
    – prosep
    Commented Feb 27, 2022 at 15:51
  • 1
    $\begingroup$ x^2 + y^2 <= r should be x^2 + y^2 <= r^2. g[x - z1, y - z2] should be g[x - z1, y - z2,r]. $\endgroup$
    – cvgmt
    Commented Feb 27, 2022 at 16:12
  • $\begingroup$ @cvgmt: Thank you. I followed the notation of the question. The typo in g is fixed. $\endgroup$
    – user64494
    Commented Feb 27, 2022 at 16:16

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