필터 지우기
필터 지우기

Numerical symbolic differentiation and evaluate at 0.

조회 수: 2 (최근 30일)
Henrik Dam
Henrik Dam 2015년 5월 23일
댓글: Henrik Dam 2015년 5월 23일
I am trying to do numerical symbolic differentiation of the kappa function below after which I want to evaluate at 0 and simplify. This is my code:
clear
syms delta gamma rho lambda T sigma u r
f_1(u) = 1i*u*rho -(1-exp(-lambda*T))*(u^2+1i*u)/(2*lambda);
f_2(u) = 1i*u*rho-(u^2+2*1i*u)/(2*lambda);
I(u) = delta/lambda*(sqrt(gamma^2-2*f_1(u))-sqrt(gamma^2-2*1i*rho*u))...
- 2*delta*f_2(u)/(lambda*sqrt(gamma^2 - 2*f_2(u))) ...
*(atanh(sqrt((gamma^2-2*1i*rho*u)/(gamma^2 - 2*f_2(u)))) ...
- atanh(sqrt( (gamma^2-2*f_1(u))/(gamma^2- 2*f_2(u)))));
kappa(u) = 1i*u*T*(r-lambda*(delta*rho)/(sqrt(gamma^2 -2*rho))) ...
-sigma*(u^2+1i*u)/(2*lambda)*(1-exp(-lambda*T)) ...
+ lambda*I(u);
c_1(u) = diff(kappa,u);
simplify(c_1(0))
But I get the error: Error in MuPAD command: Division by zero. [_power]
It might be a typo, but I am pretty sure there aren't any. In case I have not, and my friend has neither, it is solvable in Mathematica (I do not have access to or ever tried using the program my self). I've tried all sorts of stuff, but I cannot get Matlab to evaluate it.
I have 2014b of course with the symbolic toolbox (but it might be possible for me to update).
Any ideas?
  댓글 수: 4
Walter Roberson
Walter Roberson 2015년 5월 23일
Another potential difficulty occurs with using capital-I as a symbolic variable name: capital-I is how the symbolic toolbox represents sqrt(-1)
Henrik Dam
Henrik Dam 2015년 5월 23일
Thanks for the tip Walter :)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by