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

  • Context: Mathematica 
  • Thread starter Thread starter AxiomOfChoice
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary
SUMMARY

The discussion focuses on the limitations of the "Assuming" command in Mathematica when attempting to simplify expressions involving absolute values. The user expected the command Assuming[g >= 0 && t >= 0, Refine[Abs[1 + I g t]] to yield \sqrt{1+t^2g^2}, but instead received \text{Abs}[1 + i g t]. It was concluded that Mathematica uses LeafCount to determine the simplest form, which can lead to unexpected results when the preferred output has a higher LeafCount. Alternatives like Simplify[] and FullSimplify[] were also explored, revealing that FullSimplify[] can achieve the desired result under specific conditions.

PREREQUISITES
  • Familiarity with Mathematica syntax and commands
  • Understanding of mathematical concepts such as absolute values and complex numbers
  • Knowledge of simplification techniques in symbolic computation
  • Basic understanding of LeafCount and its implications in Mathematica
NEXT STEPS
  • Explore the use of FullSimplify[] in Mathematica for complex expressions
  • Research custom functions to modify LeafCount behavior in Mathematica
  • Learn about the differences between Refine[], Simplify[], and FullSimplify[]
  • Investigate how assumptions affect simplification in Mathematica
USEFUL FOR

Mathematica users, mathematicians, and anyone involved in symbolic computation who seeks to understand the nuances of expression simplification and the behavior of the "Assuming" command.

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 2 ·
Replies
2
Views
3K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K