Unrecognized function or variable 'zap'. the error -20 line. I don't know how to use multiple-integral function

조회 수: 1 (최근 30일)
function [Pfin]=timerperpeture(s0,v0,sigma,kappa,K,B) %varibles
s0=100;
v0=0.001;
K=90;
B=0.001;
r=0.01;
sigma=0.15;
kappa=0.1;
rho=0.5;
zpath=(2*sqrt(v0))/sigma;
deta=(4*kappa)/(sigma^2); % Bessel process parameter
nu=deta/2-1; % bessel model index
%syms tau ztau zpa
d=sqrt((1-rho^2)*B);
vaps=@(tau,ztau,zpa)-rho*(2*kappa/(sigma^2)-0.5).*(zpa)+(r*tau)-(B/2)+rho.*(ztau-zpath);
d1=@(tau,ztau,zpa)((log(s0/K)+vaps(tau,ztau,zpa)+(1-rho^2)*B))/d;
d2=@(tau,ztau,zpa)d1-d;
%% laplace inverse
alpha=(9)/(2*B); % laplace parameter,10
f1=@(tau,ztau,zpa,u)((2*sqrt(2*alpha*zpath.*ztau)./(sinh(tau.*sqrt(alpha./2))))./sqrt((pi^3).*zpa).*exp(-(2*sqrt(2*alpha*zpath.*ztau)./(sinh(tau.*sqrt(alpha./2)))).*cosh(u)-(pi^2)./(4.*zpa)-(u.^2)./(4.*zap)).*sinh(u).*sin(pi.*u./(2.*zpa)));
iy1=@(tau,ztau,zpa)integral(@(u)f1(tau,ztau,zpa,u),0,200*pi,'ArrayValued',1);
iy2=@(tau,ztau,zpa)cell2mat(arrayfun(@(tau,ztau,zpa)iy1(tau,ztau,zpa),tau,ztau,zpa,'UniformOutput',0));
la=@(tau,ztau,zpa)0.5*real(iy2(tau,ztau,zpa).*sqrt(2*alpha).*(ztau.^(nu+1))./(sinh(tau.*sqrt(alpha./2)).*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alpha).*coth(zpa.*sqrt(alpha/2)))));
%la=0.5*real(iy2.*sqrt(2*alpha).*(ztau.^(nu+1))./(sh.*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alpha).*coth(zpa.*sqrt(alpha/2)))));
%% circle
NTR=5;
alphaP=@(t)complex(alpha,(t*pi)/B);
sh1=@(t)sinh(zpa.*sqrt(alphaP/2));
gP=@(t)2*sqrt(2*alphaP*zpath.*ztau)./sh1;
iyP=@(tau,ztau,zpa)integral(@(u)gP./sqrt(pi^3.*tau).*exp(-gP.*cosh(u)-(pi^2-u.^2)./(4.*tau)).*sinh(u).*sin(pi.*u./2.*tau),0,200*pi,'ArrayValued',1);
H2=@(t)@(tau,ztau,zpa)((-1)^(t)).*real(iyP.*sqrt(2*alphaP).*(ztau.^(nu+1))./(sh1.*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alphaP).*coth(zpa.*sqrt(alphaP/2)))));
gH2=H2(2:NTR);
fgH2=@(tau,ztau,zpa)la(tau,ztau,zpa)+sum(gH2(tau,ztau,zpa));
IP=14;
alpha2=@(N)complex(alpha,((NTR+N)*pi)/B);
sh2=@(N)sinh(zpa.*sqrt(alpha2/2));
gP2=@(N)2*sqrt(2*alpha2*zpath.*ztau)./sh2;
iyP2=@(N)@(tau,ztau,zpa)integral(@(u)gP2./sqrt(pi^3.*tau).*exp(-gP.*cosh(u)-(pi^2-u.^2)./(4.*tau)).*sinh(u).*sin(pi.*u./2.*tau),0,200*pi,'ArrayValued',1);
MY=@(N)@(tau,ztau,zpa)(-1)^(NTR+N).*real(iyP2.*sqrt(2*alpha2).*(ztau.^(nu+1))./(sh2.*8*(zpath^(nu))).*exp(-(nu^2).*tau.*(sigma^2)/8-((zpath+ztau).*sqrt(2*alpha2).*coth(zpa.*sqrt(alpha2/2)))));
UMY=MY(1:IP);
C=[1,14,91,364,1001,1848,3003,3432,3003,1848,1001,364,91,14,1];
F=@(tau,ztau,zpa)(fgH2(tau,ztau,zpa)+C(2:IP).*UMY(tau,ztau,zpa));
AVGSU=@(tau,ztau,zpa)(exp(9/2)/B)*sum(F(tau,ztau,zpa))/8192*(s0*exp(vaps-r*tau)*normcdf(d1)-K*exp(-r*tau)*normcdf(d2));
% dx=find(isnan(AVGSU)~=0);
% AVGSU(dx)=0;
% dy=find(isnan(AVGSU1)~=0);
% AVGSU1(dy)=0;
%disthree=@(tau,ztau,zpa,u)(U.*AVGSU)./8192;
Pfin=integral3(AVGSU,0,B,0,1,0,1,'AbsTol', 0,'RelTol',1e-3) %inner expectation
end

답변 (1개)

Walter Roberson
Walter Roberson 2023년 6월 20일
f1=@(tau,ztau,zpa,u)((2*sqrt(2*alpha*zpath.*ztau)./(sinh(tau.*sqrt(alpha./2))))./sqrt((pi^3).*zpa).*exp(-(2*sqrt(2*alpha*zpath.*ztau)./(sinh(tau.*sqrt(alpha./2)))).*cosh(u)-(pi^2)./(4.*zpa)-(u.^2)./(4.*zap)).*sinh(u).*sin(pi.*u./(2.*zpa)));
^^^ ^^^
You define an input parameter named zpa but near the end of the expression you use a function or variable named zap instead of zpa

카테고리

Help CenterFile Exchange에서 Bessel functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by