Mathematica does not completely evaluate expressions.

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

This discussion addresses the issue of Mathematica not fully evaluating expressions involving affine transformations defined as compositions. Users defined transformations A and B on \mathbb{R}^2 and attempted to create compositions C and D, which resulted in Mathematica retaining them as unevaluated expressions. The solution involves redefining C and D as functions instead of vectors, allowing for proper evaluation through the use of the Simplify function. The discussion emphasizes the importance of avoiding reserved names in Mathematica and highlights the necessity of using functions for composition to achieve the desired results.

PREREQUISITES
  • Understanding of affine transformations in \mathbb{R}^2
  • Familiarity with Mathematica syntax and functions
  • Knowledge of function composition in programming
  • Experience with the Simplify function in Mathematica
NEXT STEPS
  • Learn how to define and use functions in Mathematica for transformations
  • Explore the use of the Simplify function for expression evaluation in Mathematica
  • Research the implications of reserved names in Mathematica and how to avoid conflicts
  • Investigate advanced composition techniques in Mathematica for complex expressions
USEFUL FOR

Mathematica users, mathematicians working with affine transformations, and anyone seeking to optimize expression evaluation in computational mathematics.

Identity
Messages
151
Reaction score
0
I've defined A and B to be two affine transformations on \mathbb{R}^2. Then, I defined C and D to be some kinds of compositions of A and B, for example:
C = Composition[A,B,B,A,A][{x,y}]
D = Composition[B,A,B,A,B][{x,y}]

Now, I want to evaluate expressions like:
X = Composition[C,D,C,C,D,C][{x,y}]

I know this seems like a silly thing to do, but it is actually quite necessary for the problem I'm doing. However, X does not explicitly evaluate to a column vector, Mathematica just keeps it as Composition[C,D,C,C,D,C][{x,y}].

How can I FORCE mathematica to evaluate an expression to the end? Thanks
 
Physics news on Phys.org
If I assume the answer I gave you yesterday is similar to what you are doing today then

A[{x_,y_}]:={{1,-1},{-1,1}}.{x,y};
B[{x_,y_}]:={{0,1},{2,-1}}.{x,y}+{1,1};

Then this appears to work as expected because A and B are functions.

Composition[A,B,A][{x,y}]

It transforms vector to vector using the sequence of functions.

Now you want today

C = Composition[A,B,B,A,A][{x,y}]
D = Composition[B,A,B,A,B][{x,y}]
X = Composition[C,D,C,C,D,C][{x,y}]

but what are C and D and what is the Composition of them?

First, Mathematica reserves a vast number of names for itself. Those include C and D. Using either of those as an ordinary user variable almost certainly will give you nothing but grief.

Second, think a moment, what is Composition[C,D,C,C,D,C] exactly? Composition is expecting a sequence of functions and will compose those. But your C and D are both vectors, not functions. If I scribbled on the board C={1,2} and D={4,3} Compose those. What would you do?

So resolve both of those and we will see if we can get you where you need to go
 
Last edited:
Here's an example. You can keep shift+entering the output until it fully simplifies, but I can't get it to simplify immediately
 

Attachments

A general rule I try to remember: The more people try to desktop publish their math the more problems they have. I realize Mathematica makes it almost impossible for some people to resist this.

Carefully check this and see if it is correct after having removed the desktop publishing.

In[1]:= a[{x_,y_}]:={{1,0},{2,-1}}.{x,y};
b[{x_,y_}]:={{3,0},{-1,2}}.{x,y}+{1,1};
c[{x_,y_}]:=Simplify[Composition[a,b,a,b,a][{x,y}]];
d[{x_,y_}]:=Simplify[Composition[b,a,a,b,b][{x,y}]];

In[5]:= c[{x,y}]

Out[5]= {4+9 x,6+15 x-4 y}

In[6]:= d[{x,y}]

Out[6]= {13+27 x,1-19 x+8 y}

In[7]:= X = Composition[c,d,c,c,d,c,d][{x,y}]

Out[7]= {64570081+129140163 x,120307837+240270449 x+131072 y}

Note: Literally scrape and paste that into Mathematica without forcing it back into your 2-dimensional published form
Thank you
And I'm still not sure I understand what you mean by composition of two element vectors.
 
Thx, that works. I guess it's a shortcoming of mathematica. Oh, and the vectors aren't like usual vectors, they're just maps from R^2 to R^2.
 
You could spend hours or days and try to find a work around that will let you use the 2d format you were using. If you could make a very convincing case that it should work you could submit this to Wolfram and see if in a year or two they send you a note saying they have corrected this. But is probably very unlikely that they will change this.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K