-1

I need to perform the following operations as shown in the image. I need to calculate the value of function H for different inputs(x) using MATLAB.

enter image description here

I am giving the following command from Symbolic Math Toolbox

syms y t x;
f1=(1-exp(-y))/y;
f2=-t+3*int(f1,[0,t]);
f3=exp(f2);
H=int(f3,[0,x]);

but the value of 2nd integral i.e. integral in the function H can't be calculated and my output is of the form of

H =

int(exp(3*eulergamma - t - 3*ei(-t) + 3*log(t)), t, 0, x)

If any of you guys know how to evaluate this or have a different idea about this, please share it with me.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • I already did as you can see my command but I can't get the desired output. In fact, the output that I am getting is same as unsolved last step. – udit srivastava Dec 18 '16 at 14:41

1 Answers1

1

Directly Finding the Numerical Solution using integral:

Since you want to calculate H for different values of x, so instead of analytical solution, you can go for numerical solution.

Code:

syms y t;
f1=(1-exp(-y))/y;   f2=-t+3*int(f1,[0,t]);  f3=exp(f2);
H=integral(matlabFunction(f3),0,100)   % Result of integration when x=100 

Output:

H =
   37.9044

Finding the Approximate Analytical Solution using Monte-Carlo Integration:

It probably is an "Elliptic Integral" and cannot be expressed in terms of elementary functions. However, you can find an approximate analytical solution using "Monte-Carlo Integration" according to which:

Monte-Carlo Formula
where f(c) = 1/n Σ f(xᵢ)

Code:

syms x y t;

f1=(1-exp(-y))/y;   f2=-t+3*int(f1,[0,t]);  f3=exp(f2);
f3a= matlabFunction(f3);       % Converting to function handle

n = 1000;      
t = x*rand(n,1);               % Generating random numbers within the limits (0,x)
MCint(x) = x * mean(f3a(t));   % Integration
H= double(MCint(100))          % Result of integration when x=100  

Output:

H =
   35.2900

% Output will be different each time you execute it since it is based
% on generation of random numbers

Drawbacks of this approach:

  1. Solution is not exact but approximated.
  2. Greater the value of n, better the result and slower the code execution speed.

Read the documentation of matlabFunction, integral, Random Numbers Within a Specific Range, mean and double for further understanding of the code(s).

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
  • Thank you Sir. Your suggestion totally worked. But as I should have mentioned earlier, I want the value of function H evaluated at random points for which I desire H to be an indefinite solution. Is it anyway possible? – udit srivastava Dec 19 '16 at 16:06
  • What you wrote your question is not an indefinite integral. Read [**this**](http://stat.math.uregina.ca/~kozdron/Teaching/UBC/101Spring98/101integral.html) for simple explanation – Sardar Usama Dec 20 '16 at 12:42