Firstly, I integrate a simple function on an ellipse. Secondly, I integrate the same function to which I add a constant value. The results are not consistent as you can see on the bottom of my message.
Thanks in advance for you help.
# -*- coding: utf-8 -*-
from scipy import integrate
from math import *
a = 2.0;
b = 1.0;
Cst = 1.0
def f1(x, y):
return sqrt(abs(1. -(x/a)**2 -(y/b)**2))
def f2(x, y):
return sqrt(abs(1. -(x/a)**2 -(y/b)**2)) + Cst
def un(x, y):
return 1.0
def bounds_y():
return [-b, b]
def bounds_x(y):
xLimSup = a*sqrt(1-(y/b)**2)
xLimInf = -xLimSup
return [xLimInf, xLimSup]
[S, err] = integrate.nquad(un, [bounds_x, bounds_y])
Stheo = a*b*pi
[Intf1, err1] = integrate.nquad(f1, [bounds_x, bounds_y])
Intf1corr = Intf1 + Cst * S
[Intf2, err2] = integrate.nquad(f2, [bounds_x, bounds_y])
print("S = %1.4e " % S)
print("Stheo = %1.4e \n" % Stheo)
print("Intf1 = %1.4e " % Intf1)
print("Intf1corr = %1.4e " % Intf1corr)
print("Intf2 = %1.4e " % Intf2) # Ce résultat est complètement faux !!!
**********************************************************
S = 6.2832e+00
Stheo = 6.2832e+00
Intf1 = 4.1888e+00
Intf1corr = 1.0472e+01
Intf2 = 9.7238e-01