Inverse Laplace transform of non-symbolic function

2 views (last 30 days)
I'm trying to compute the inverse Laplace transform of the function gam below
t = 0.7968;
r = 0.05;
C = 0.397;
G = 4.312;
M = 19.5587;
Y = 0.5839;
C = C*100^Y;
G = G/100;
M = M/100;
EQ = C*t*gamma(2-Y)*(1/M^(2-Y) + 1/G^(2-Y));
I = @(nu,a,lambda) (2.*lambda).^(-nu/2).*gamma(nu).*Herm(-nu,a./sqrt(2*lambda));
phi = @(lambda) exp ( - C*t* (((2*lambda)./Y+M.^2./(Y*(1-Y))).*I(2-Y,M,lambda) + ...
((2*lambda)./Y+G.^2/(Y*(1-Y))).*I(2-Y,G,lambda) + ...
(2*lambda*M)./(Y*(1-Y)).*I(3-Y,M,lambda)+ ...
(2*lambda*G)./(Y*(1-Y)).*I(3-Y,G,lambda) - ...
M.^Y./(Y*(1-Y)).*gamma(2-Y) - G.^Y./(Y*(1-Y)).*gamma(2-Y)));
gam = @(lambda) exp(-r*t).*((phi(lambda)-1)./lambda.^2 + EQ./lambda);
syms lambda K
price = ilaplace(gam,K);
where Herm is a function computing an infinite sum:
function x = Herm(nu,z)
S = 0; % Holds the sum
M = 10;
j = 0;
while M > (2*eps)
M = gamma((j-nu)/2)*2.^((j-nu)/2)*(-z).^j./factorial(j);
S = S + M;
j = j + 1;
end
x = 1./(2*gamma(-nu))*S;
When running the code, I get the error: "Conversion to logical from sym is not possible.", and I guess it's because of the while loop in the function Herm since Matlab cannot compare symbolic variables with values. I don't know how I should work around this since I cannot apply the Gamma function on a symbolic variable and thereby not use symsum instead of my user defined Herm function?
My other problem is that I have tried to compute the inverse Laplace transform when Herm is equal to 1 just to test if it works, and the resulting function is
(8655406674580457*exp(23477544183654475070368399262999/2535301200456458802993406410752)*heaviside(K)*ilaplace(exp(- (13078573778032534235659040224658125*(2*lambda)^(5839/20000))/925226481841578934417406252023808 - (3983232481287751717700979741070630539400651704603*2^(5839/20000))/(11692013098647223345629478661730264157247460343808*lambda^(14161/20000)) - (3982073156105729051442022632207669983713730125349*2^(15839/20000))/(1387060907782069057605350303705368947727532032000*lambda^(4161/20000)))/lambda^2, lambda, K))/9007199254740992 - (8655406674580457*K)/9007199254740992 + 30121999757536443160652423468557/79228162514264337593543950336
That is, the resulting function is expressed as yet another inverse Laplace transform. Maybe something is wrong but I should be able to get some nice function since I am trying to replicate the results from this article
Thanks in advance.
  1 Comment
Jingyu Liu
Jingyu Liu on 13 Mar 2019
I have the same problem with you. Do you know how to do an inverse laplace transform with gamma function now? Thank you.

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!