How can I remove some specific terms from a function?

1 次查看(过去 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.

采纳的回答

Walter Roberson
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.
  1 个评论
Michael
Michael 2013-11-11
Thx a lot, it really works. However, for the part
assume(t > 0 & a > 0)
It tells me that
Undefined function 'assume' for input arguments of type 'logical'.
What happens?

请先登录,再进行评论。

更多回答(2 个)

Image Analyst
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);
  1 个评论
Michael
Michael 2013-11-11
Sorry, may be I didn't clearly express the question. What I mean is a,b,c,d will change with my initial conditions. Thus, each time I can generate a new equation. I don't want to eliminate the exp() terms each time by hand...it is really time consuming, as I need to calculate more than 100 times.

请先登录,再进行评论。


bethel o
bethel o 2013-11-11
编辑:bethel o 2013-11-11
Why don't you multiply the different part of the equation by different terms e.g Q=1, R=1, S=1, etc and the these terms to zero when you don't want to use the respective part of the equation.

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by