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

  • Context: Mathematica 
  • Thread starter Thread starter AxiomOfChoice
  • Start date Start date
  • Tags Tags
    Mathematica
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
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

[tex] \sqrt{1+t^2g^2},[/tex]

but instead I'm just getting

[tex] \text{Abs}[1 + i g t],[/tex]

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


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.