# How to set variable type when doing calculation?

**URL:** <https://community.wolfram.com/t/how-to-set-variable-type-when-doing-calculation/5022>\
**Category:** Questions\
**Tags:** mathematica\
**Created:** [March 5, 2015, 9:41am UTC](https://community.wolfram.com/t/how-to-set-variable-type-when-doing-calculation/5022 "2015-03-05T09:41:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xfu1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/xfu1/32/18886_2.png) [@xfu1](https://community.wolfram.com/u/xfu1)\
**Post date:** [March 5, 2015, 9:41am UTC](https://community.wolfram.com/t/how-to-set-variable-type-when-doing-calculation/5022/1 "2015-03-05T09:41:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nma](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@nma](https://community.wolfram.com/u/nma)\
**Post date:** [March 5, 2015, 12:38pm UTC](https://community.wolfram.com/t/how-to-set-variable-type-when-doing-calculation/5022/2 "2015-03-05T12:38:20Z")

</div>

Clear[f, x, t, b, a, A0]  
f[x\_, t\_] := A0 E^(-a Abs) E^(-I b t);  
Assuming[Re[a] \> 0, Integrate[f[x, t], {x, -Infinity, Infinity}]]

![10232Untitled.png](https://global.discourse-cdn.com/wolfram/original/3X/0/2/02297d4fbe9f75f602d888809c5cf0a902ec64f0.png)

---

<div class="post-metadata">

**Author:** ![xfu1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/xfu1/32/18886_2.png) [@xfu1](https://community.wolfram.com/u/xfu1)\
**Post date:** [March 5, 2015, 2:44pm UTC](https://community.wolfram.com/t/how-to-set-variable-type-when-doing-calculation/5022/3 "2015-03-05T14:44:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nma](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@nma](https://community.wolfram.com/u/nma)\
**Post date:** [March 5, 2015, 3:56pm UTC](https://community.wolfram.com/t/how-to-set-variable-type-when-doing-calculation/5022/4 "2015-03-05T15:56:41Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![jpd](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/jpd/32/34994_2.png) [@jpd](https://community.wolfram.com/u/jpd)\
**Post date:** [March 5, 2015, 4:22pm UTC](https://community.wolfram.com/t/how-to-set-variable-type-when-doing-calculation/5022/5 "2015-03-05T16:22:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![xfu1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/xfu1/32/18886_2.png) [@xfu1](https://community.wolfram.com/u/xfu1)\
**Post date:** [March 6, 2015, 9:20am UTC](https://community.wolfram.com/t/how-to-set-variable-type-when-doing-calculation/5022/6 "2015-03-06T09:20:51Z")

</div>

Dear Nasser,

Thank you very much!

The global assumption is exactly what I am looking for. You solved my problem.

Thanks once again.
