Mathematica Mathematica: Why isn't this command with Assuming working?

  • Thread starter Thread starter AxiomOfChoice
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion revolves around the Mathematica command using "Assuming" in conjunction with the "Refine" function. The user expects to simplify the expression Abs[1 + I g t] to √(1 + t²g²) but instead receives the original expression. The conversation highlights that Mathematica determines simplicity based on LeafCount, which can lead to unexpected results. Attempts to use Simplify or FullSimplify also yield the original expression, indicating that Mathematica does not recognize the preferred output as simpler. It is noted that FullSimplify can successfully simplify expressions with a single variable but struggles with multiple variables. Custom functions to influence LeafCount have been mentioned but are reported to be challenging to implement successfully.
AxiomOfChoice
Messages
531
Reaction score
1
Mathematica: Why isn't this command with "Assuming" working?

I'm trying to execute the following command:

Assuming[g >= 0 && t >= 0, Refine[Abs[1 + I g t ]]]

I expect it to spit out

<br /> \sqrt{1+t^2g^2},<br />

but instead I'm just getting

<br /> \text{Abs}[1 + i g t],<br />

which is obviously pretty worthless. Does anyone see what I'm doing wrong?
 
Physics news on Phys.org


I'd try using Simplify[] or FullSimplify[] instead of Refine[].
 


What is "simplest" is a deeply subjective issue.
Usually Mathematica uses the smallest LeafCount to decide that.

In[1]:= LeafCount[Abs[1-I a b]]
Out[1]= 9

In[2]:= LeafCount[Sqrt[1+a^2 b^2]]
Out[2]= 13

So Mathematica thinks your preferred output is more complicated. Trying to subvert what Mathematica thinks it wants to do is usually very difficult. It is possible to write custom functions to be used by LeafCount but I have never had any success doing that.

In[3]:= Refine[Abs[1-a b I],a>=0&&b>=0]
Out[3]= Abs[1-I a b]

In[4]:= Simplify[Abs[1-a b I],a>=0&&b>=0]
Out[4]= Abs[1-I a b]

In[5]:= FullSimplify[Abs[1-a b I],a>=0&&b>=0]
Out[5]= Abs[1-I a b]

So none of those are going to, by default, accomplish what you want.

However

In[6]:= Refine[Abs[1-a I],a>0]
Out[6]= Abs[1-I a]

In[7]:= Simplify[Abs[1-a I],a>0]
Out[7]= Abs[1-I a]

In[8]:= FullSimplify[Abs[1-a I],a>=0]
Out[8]= Sqrt[1 + a^2]

So FullSimplify can do it with a single variable and not with more.
 

Similar threads

Replies
19
Views
2K
Replies
5
Views
2K
Replies
13
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
5
Views
2K
Replies
9
Views
3K
Replies
5
Views
2K
Back
Top