# How to set variable type when doing calculation?

Posted 8 years ago
3612 Views
|
5 Replies
|
3 Total Likes
|
 I am a newbie in Mathematica. Recently, I want to use Mathematica to help my mathematics calculation.I have the following function: f[x_,t_]=A E^(-a Abs[x])E^(-I b t), in which A, a, b are real positive numbers. And I would like to calculate the following integration: Integrate[f[x,t], {x, -Infinity, Infinity}] However, as I know A, a, b are real positive numbers, so I expect the following result: (2 A E^(-I b t))/a But, Mathematica give the following result: (2 A E^(-I b t))/a, when Re[a] > 0; Integrate[A E^(-I b t - a Abs[x]), {x, -\[Infinity], \[Infinity]}, Assumptions -> Re[a] <= 0], True My problem is: how to let Mathematica know, A, a, b are real positive numbers, so that it could generate the result I want?I know, this might be a simple question, but I have searched a lot of pages, and got no answer. Could anybody help me? Thanks a lot.
5 Replies
Sort By:
Posted 8 years ago
 There aren't "variables" with "types" in Mathematica in the sense that you seek. A symbol may serve as a variable in the context of a particular expression. In that context, you may be able to use assumptions: see the documentation for the particular function you are using to treat the symbol as a variable or parameter.
Posted 8 years ago
 Clear[f, x, t, b, a, A0] f[x_, t_] := A0 E^(-a Abs[x]) E^(-I b t); Assuming[Re[a] > 0, Integrate[f[x, t], {x, -Infinity, Infinity}]] 
Posted 8 years ago
 Hi, Nasser M. Abbasi. Thank you! The Assuming function could generate the right result, but it is a little restricted. However, sometimes I just want to assume some variables to be real numbers, is it possible?
Posted 8 years ago
 sometimes I just want to assume some variables to be real numbers, is it possible This can be done using Element as in Clear[f, x, t, b, a, A0] f[x_, t_] := A0 E^(-a Abs[x]) E^(-I b t); Assuming[Element[a, Reals] && a > 0, Integrate[f[x, t], {x, -Infinity, Infinity}]] Which gives the same result as before. The assumption can also be made global Clear[f, x, t, b, a, A0] f[x_, t_] := A0 E^(-a Abs[x]) E^(-I b t); \$Assumptions = Element[a, Reals] && a > 0; Integrate[f[x, t], {x, -Infinity, Infinity}] Giving same result. See ?Element
Posted 8 years ago
 Dear Nasser,Thank you very much! The global assumption is exactly what I am looking for. You solved my problem.Thanks once again.