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

  • Mathematica
  • Thread starter AxiomOfChoice
  • Start date
  • Tags
    Mathematica
In summary, the user is trying to use the command "Assuming" in Mathematica to refine a complex expression, but is not getting the expected output. They have tried using Simplify and FullSimplify, but have not had success. It is mentioned that the concept of "simplest" is subjective in Mathematica and using custom functions to modify LeafCount is difficult. The conversation ends with the suggestion to use FullSimplify with a single variable to achieve the desired result.
  • #1
AxiomOfChoice
533
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
  • #2


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


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.
 

Why isn't this command with Assuming working?

There could be several reasons why the command with Assuming is not working, such as an incorrect syntax or the assumptions not being properly specified. It is also possible that the command is not applicable to the specific problem at hand.

How do I properly use Assuming in Mathematica?

To use Assuming in Mathematica, you need to specify the assumptions using the syntax Assuming[condition, expression]. The condition can be a logical expression or a list of assumptions in the form of x\[Element]Domain, where x is a variable and Domain is a domain specification. It is important to note that the assumptions are only valid for the expression within the Assuming command.

What is the purpose of Assuming in Mathematica?

The Assuming command in Mathematica allows you to specify assumptions about variables or parameters in an expression. This helps Mathematica to make certain simplifications or calculations based on those assumptions, providing more accurate and efficient results.

Can I use multiple assumptions in the same Assuming command?

Yes, you can use multiple assumptions by separating them with commas in the Assuming command. For example, Assuming[x>0, y>0, x+y] will assume both x and y are positive when calculating the sum of x and y.

What are some common mistakes when using Assuming in Mathematica?

Some common mistakes when using Assuming in Mathematica include incorrect syntax, using assumptions that are not relevant to the expression, or not specifying the assumptions at all. It is important to carefully check the syntax and ensure that the assumptions are correctly specified for the desired result.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
257
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
124
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Programming and Computer Science
Replies
1
Views
255
Back
Top