How can I remove some specific terms from a function?
조회 수: 6 (최근 30일)
이전 댓글 표시
Dear sir, I am trying to write a code that can generate the specific terms from certain function. However, I just cannot find a way to remove the exponential terms. I have a list of functions that generate by same function, that all look like f=a!*sqrt(b+c*i)*exp(-dk+sqrt(b+c*i)), where a,b,c,d are all changing variable. I want to remove all the terms of exp(), so as to use the first two part for next step of calculation. How to do this? Thank you.
To be concrete, here is my formula sheet.
if true
format long;
h=1.05457173e-34;
t=1e25*365*24*3600;
m=60;
a=1/1000;
syms x k;
int(exp(i*k*x-i*h*k^2*t/(2*m)-k^2*a^2/2),k,-Inf,Inf)
f=pi^(1/2)*(sqrt(a/(2*pi^(3/2))))/((10126067097211690078125*i)/365375409332725729550921208179070754913983135744+ 1/2000000)^(1/2)
g=pi^(1/2)*(sqrt(a/(2*pi^(3/2))))/((158219798393932657470703125*i)/5708990770823839524233143877797980545530986496+1/2000000)^(1/2)
u=pi^(1/2)*(sqrt(a/(2*pi^(3/2))))/(27714145064399998094084151567728884845503502656025676347457107551846400*i+ 1/2000000)^(1/2)
o=pi^(1/2)*(sqrt(a/(2*pi^(3/2))))/((1756592631284943967788998796645*i)/633825300114114700748351602688+ 1/2000000)^(1/2)
q=pi^(1/2)*(sqrt(a/(2*pi^(3/2))))/((89937542721789151668027362145*i)/324518553658426726783156020576256+ 1/2000000)^(1/2)
Z=(real(f))^2;
SD=1/(sqrt(2*pi)*Z)
end
The f g u o q, is some example with different t I done, but actually I need to do for more than 100 times for data analysis. As you see, the integral will generate sth with exp(),and f g u o q are all eliminated by myself.
댓글 수: 1
Walter Roberson
2013년 11월 11일
Are you using the symbolic toolbox? If not then how is your function represented ?
채택된 답변
Walter Roberson
2013년 11월 11일
For that h and m, and holding a and t symbolic, but assuming a is real and assuming t is positive:
YourIntegral = 284475670516978489457516559826613190 * exp(-284475670516978489457516559826613190 * x^2 / (i*t + 568951341033956978915033119653226380 * a^2)) * 2^(1/2) * pi^(1/2)/ ((142237835258489244728758279913306595*i) * t + 80926407116084504595296678347317302904777180422918746308915785881976100 * a^2)^(1/2)
To get to this form instead of a piecewise form, before you do the integral use assume() to add the assumptions about a and t
assume(t > 0 & a > 0)
and you might need to simplify() the result of the integral.
By examination we can see that the x variable exists as a multiplier of the numerator of the exp() term, and does not otherwise appear anywhere in the integral. So to get rid of the exp() term,
exp_removed = subs(YourIntegral, x, sym(0));
Now if you want you could turn it into a numeric procedure with a and t as parameters:
f = matlabFunction( simplify(exp_removed), 'vars', {a, t});
Note: the result is going to be complex.
Also note: there is no factorial or gamma function involved.
추가 답변 (2개)
Image Analyst
2013년 11월 11일
Does the delete key not work on your computer? Simply delete the term and do this:
f1 = factorial(a)*sqrt(b+c*i);
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!