Message Boards Message Boards

0
|
3223 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

Get back a symbolic answer from a function call?

Posted 7 years ago

Hi,

I have this little function:

qExp[x_,q_]:= Module[{ret},
If[q==1,ret=Exp[x],ret=(1+(1-q)x)^(1/(1-q))];
ret
];

After setting up some variables:

In[1]:= mat = Array[Subscript[a, ##] &, {2, 2}]
Out[1]= {{Subscript[a, 1, 1], Subscript[a, 1, 2]}, {Subscript[a, 2, 
  1], Subscript[a, 2, 2]}}
i = 1; j = 1; k = 1; l = 1;
dim = Dimensions[mat];
Clear[q]

I execute:

In[25]:= qExp[I*2*Pi*(i*k/dim[[1]] + j*l/dim[[2]]), q]
Out[25]= ret$956

Now, if I have a specific value for q, then I get a numeric result:

q = 1.1;
In[33]:= qExp[I*2*Pi*(i*k/dim[[1]] + j*l/dim[[2]]), q]
Out[33]= 0.148088 - 0.118137 I

After Clearing q again:

Clear[q]

and assuming that 1<q<2 and executing:

In[35]:= Assuming[1 < q < 2, 
 qExp[I*2*Pi*(i*k/dim[[1]] + j*l/dim[[2]]), q]]
Out[35]= ret$1632

I am not getting a symbolic result. I expected to get:

(1+(1-q)*I*2*Pi)^(1/(1-q))

How should I define qExp to give me back symbolic result instead of ret#xxxx Thanks ahead, János

POSTED BY: Janos Lobb

The test q==1 does not use the assumptions from Assuming. It does if you add Simplify:

qExp[x_, q_] := 
  If[Simplify[q == 1], Exp[x], (1 + (1 - q) x)^(1/(1 - q))];
POSTED BY: Gianluca Gorni
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