Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Aug 6, 2012 #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


    but instead I'm just getting

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

    which is obviously pretty worthless. Does anyone see what I'm doing wrong?
  2. jcsd
  3. Aug 6, 2012 #2


    User Avatar
    Homework Helper
    Gold Member

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

    I'd try using Simplify[] or FullSimplify[] instead of Refine[].
  4. Aug 7, 2012 #3
    Re: Mathematica: Why isn't this command with "Assuming" working?

    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.


    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook