Message Boards Message Boards

0
|
1957 Views
|
9 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Integral of an exponent function

Hii all, I'm stuck at a very basic point where an integral of an exponent of a polinomial function is not being calculated. The follwing is how the integral is formulated. It uses shape functions and a field vector. The integral of an exponential function of the field value interpolated in a 2d element using the Shape function

c = {c1, c2, c3, c4};
Y = {y1, y2};
sf = ConstantArray[1, 4];(*shape function as a 1x4 vector*)
sf[[1]] = 0.25*(1 - y1)*(1 - y2);
sf[[2]] = 0.25*(1 + y1)*(1 - y2);
sf[[3]] = 0.25*(1 + y1)*(1 + y2);
sf[[4]] = 0.25*(1 - y1)*(1 + y2);
cGP = sf.c;(*field value at a gauss point interpolated using shapefunction at y1,y2*)
fC = Exp[cGP]
out:=e^(0.25 c1 (1 - y1) (1 - y2) + 0.25 c2 (1 + y1) (1 - y2) + 0.25 c4 (1 - y1) (1 + y2) + 0.25 c3 (1 + y1) (1 + y2))
intfC = Integrate[fC, {y1, -1, 1}, {y2, -1, 1}](*exponent of the field value evaluated and integrated all over the element*)

I don't understand why this doesnt work and would be very grateful for an explanation or any suggestions on remedies or alternate solutions. Thank You!!

Attachments:
9 Replies

I would try this way:

c = {c1, c2, c3, c4};
sf = 1/4*{(1 - y1)*(1 - y2),
    (1 + y1)*(1 - y2),
    (1 + y1)*(1 + y2),
    (1 - y1)*(1 + y2)};
cGP = sf . c;
fC = Exp[cGP];
firstIteratedIntegral = Integrate[fC, {y1, -1, 1}];
primitiveOfFirstIteratedIntegral[y2_] = 
  Integrate[firstIteratedIntegral, y2];
doubleIntegral[c1_, c2_, c3_, c4_] = 
 primitiveOfFirstIteratedIntegral[1] - 
  primitiveOfFirstIteratedIntegral[-1]
Manipulate[Quiet@Plot3D[doubleIntegral[c1, c2, c3, c4],
   {c1, -2, 2}, {c2, -2, 2}, AxesLabel -> Automatic],
 {{c3, -1}, -2, 2},
 {{c4, 1/2}, -2, 2}]
POSTED BY: Gianluca Gorni

This Works perfectly @Gianluca, thanks a lot. But the result is still in terms of 'ExpIntegralEi'. Is there a way I can extract the complex function in terms of the variables c1,c2,c3,c4 in a plain form. I tried Series expansion but the function seems to be too complicated.

-((4. (1. E^((1. c1 c3 - 1. c2 c4)/(1. c1 - 1. c2 + 1. c3 - 1. c4))
       ExpIntegralEi[
       0. + 0.5 c2 - 0.5 c3 + (
        0.5 c1 c2 - 0.5 c2^2 - 0.5 c1 c3 + 0.5 c3^2 + 0.5 c2 c4 - 
         0.5 c3 c4)/(c1 - 1. c2 + c3 - 1. c4)] - 
     1. E^((1. c1 c3 - 1. c2 c4)/(c1 - 1. c2 + c3 - 1. c4))
       ExpIntegralEi[
       0. + 0.5 c1 - 0.5 c4 + (
        0.5 c1^2 - 0.5 c1 c2 - 0.5 c1 c3 + 0.5 c2 c4 + 0.5 c3 c4 - 
         0.5 c4^2)/(c1 - 1. c2 + c3 - 1. c4)]))/(
  c1 - 1. c2 + c3 - 1. c4)) + (
 4. (1. E^((1. c1 c3 - 1. c2 c4)/(1. c1 - 1. c2 + 1. c3 - 1. c4))
      ExpIntegralEi[
      0. - 0.5 c2 + 0.5 c3 + (
       0.5 c1 c2 - 0.5 c2^2 - 0.5 c1 c3 + 0.5 c3^2 + 0.5 c2 c4 - 
        0.5 c3 c4)/(c1 - 1. c2 + c3 - 1. c4)] - 
    1. E^((1. c1 c3 - 1. c2 c4)/(c1 - 1. c2 + c3 - 1. c4))
      ExpIntegralEi[
      0. - 0.5 c1 + 0.5 c4 + (
       0.5 c1^2 - 0.5 c1 c2 - 0.5 c1 c3 + 0.5 c2 c4 + 0.5 c3 c4 - 
        0.5 c4^2)/(c1 - 1. c2 + c3 - 1. c4)]))/(
 c1 - 1. c2 + c3 - 1. c4)

Single order approximation

approxintfC = 
     Series[intfC[c1, c2, c3, c4], {c1, 0, 1}, {c2, 0, 1}, {c3, 0, 
       1}, {c4, 0, 1}]

ExpIntegralEi is a special function. It is as "plain" as you can get, I am afraid. What is your purpose in this calculation?

POSTED BY: Gianluca Gorni

I use Matlab to develop a Finite Element model of a mechanical process. This process is governed by a series of PDEs. The whole volume is broken into small elements and these PDEs are kinda converted into a form called weak form which is integrated over the volume of these elements to calculate a residual which is equated to '0', this is basiclly what FEM is. Usually the integral over the element is calculated through Gaussian Quadrature, But I'm trying to do it using Matematica analytical integration as I'm using the concept of reduced integration for certain terms of the PDE as it demands this. So anyway, this Integrated expression goes into the residual formulation in Matlab as a function of the field variables 'c'. SoI'll need an expression that I can write in matlab to compute the value of the residual at each Newton Iteration for every element. Thanks a lot for your help and curiosity, I hope I gave a clear answer.

TL;DR: I need to write this expression in matlab where I give the c values and get the expression value as an output. Thanks!!

I checked right now the Help Center of Matlab. Among the special functions it offers also expint, described as "Exponential integral function". I wonder if it is the same thing as Mathematica's ExpIntegralEi.

POSTED BY: Gianluca Gorni

Thanks for your effort Gianluca, it is a very similar function. I should have checked this myself.

Mathematica ExpintegralEi: enter image description here

ExpIntegralEi[1.8]
Out[1]= 4.24987

Matlab expint: enter image description here

>> expint(-1.8)
ans =
  -4.2499 - 3.1416i

but for some reason, - expint(-x) and ExpIntegralEi(x) are matching only in real value and there is an imaginary value associated with the matlab expint that is missing in ExpIntegralEi from Mathematica. But anyway, I shall try out a few other values and see if real(-expint(-x)) does the job. Finally, Thanks a lot Gianluca, you helped me a great deal!!

There is something wrong with Matlab's value of expint. Its definition is an integral of a real function (principal value) on an interval. How can it be complex?

POSTED BY: Gianluca Gorni
Posted 1 year ago

Does this help?

Assuming[c1>0,
  Integrate[E^(1/4c1(1-y1)(1-y2)),{y1,-1,1},{y2,-1,1}]]
POSTED BY: Bill Nelson

Thank you for your answer, Bill. It works for a single variable, but the issue reappears after I do the same for more variables. In any case, the other answer worked. Thank You!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract