Message Boards Message Boards

0
|
4105 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How to set variable type when doing calculation?

Posted 9 years ago

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.

POSTED BY: X FU
5 Replies

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 BY: John Doty
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}]]

enter image description here

POSTED BY: Nasser M. Abbasi
Posted 9 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 BY: X FU

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 BY: Nasser M. Abbasi
Posted 9 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.

POSTED BY: X FU
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract