kainmuth

5 Reputation

One Badge

7 years, 127 days

MaplePrimes Activity


These are replies submitted by kainmuth

@Rouben Rostamian  

Obviously the expression is not defined for x=y but in the limit I can calculate the integral.

So firstly I integrate over y and afterwards I integrate over x to the limits of the intervall (ybottom,ytop).


 

w := proc (s) options operator, arrow; 1/abs(s) end proc;

proc (s) options operator, arrow; 1/abs(s) end proc

(1)

g := int(w(x-y), x, y)

piecewise(y < x, -ln(x-y)*(x-y)+x-y, y = x, 0, x < y, -ln(-x+y)*(-x+y)-x+y)

(2)

``

limit(-ln(x)*x, x = 0)

0

(3)

f := eval(g, x = 2*Pi)-(eval(g, x = 0))

piecewise(y < 2*Pi, -ln(2*Pi-y)*(2*Pi-y)+2*Pi-y, y = 2*Pi, 0, 2*Pi < y, -ln(-2*Pi+y)*(-2*Pi+y)-2*Pi+y)-piecewise(y < 0, ln(-y)*y-y, y = 0, 0, 0 < y, -ln(y)*y+y)

(4)

h := limit(f, y = 2*Pi)-(limit(f, y = 0));

4*Pi*ln(2)+4*ln(Pi)*Pi-4*Pi

(5)

evalf(h);

10.52907374

(6)

``

``


 

Download limits.mw

Thank you for your detailed answer. I have been able to do most of my calculations.

However for a kernel w(x-y)= 8*pi*a*d(x-y)-(2/abs(x-y)) I have problems due to the denominator. I always get some undefined or float term in E. (even if I change integration range or do something like s->1/(abs(s)+1))

If I just run the NLPsolve with such a E it runs forever.

Is there any chance I can avoid this problem?

Thanks!

Kainmuth
 

Edit: I forgot to say that "assuming x not equal to y" does not fix the problem either.

restart

N := 2;

2

(1)

f := add((a[k]+I*b[k])*(cos(k*x)+I*sin(k*x)), k = -N .. N);

(a[-2]+I*b[-2])*(cos(2*x)-I*sin(2*x))+(a[-1]+I*b[-1])*(cos(x)-I*sin(x))+a[0]+I*b[0]+(a[1]+I*b[1])*(cos(x)+I*sin(x))+(a[2]+I*b[2])*(cos(2*x)+I*sin(2*x))

(2)

`assuming`([conjugate(f)*f], [real]):

f2x := simplify(%):

f2y := subs(x = y, f2x):

diff(f, x):

`assuming`([conjugate(%)*%], [real]):

fp2 := simplify(%):

constr := add(a[k]^2+b[k]^2, k = -N .. N) = 1;

a[-2]^2+a[-1]^2+a[0]^2+a[1]^2+a[2]^2+b[-2]^2+b[-1]^2+b[0]^2+b[1]^2+b[2]^2 = 1

(3)

rmax := 20;

20

(4)

4*Pi*c

4*Pi*c

(5)

fc := simplify(%):

c := .5;

.5

(6)

w := proc (s) options operator, arrow; 1/abs(s) end proc

proc (s) options operator, arrow; 1/abs(s) end proc

(7)

E := int(fp2, x = 0 .. Pi)+fc*(int(f2x^2, x = 0 .. Pi))-(int(int(f2x*f2y*w(x-y), x = 0 .. Pi), y = 0 .. Pi))

infolevel[Optimization] := 2

ans := Optimization:-NLPSolve(E, {constr}, iterationlimit = 100)

``


 

Download minimizer.mw

First of all you're right there should be a second integral with respect to y.

I tried to put in some general formula first but as an example w(x-y)= 8*pi*a*d(x-y)-(2/abs(x-y)). where d(x-y) is the delta function.

As soon as I get to the computer with maple I will rewrite the code to make it more clear.

Now I am trying to find c1,c2,c3 s.t. the functional is minimized. Obviously I want to use more than 3 coefficients and maybe choose a different basis that's why I tried to formulate the problem with a function f which I can change easily.

The biggest question is how to implement the normalization constraint (const). Most of the time I get an error (unexpected parameters ).

 

Page 1 of 1