simplication of a matrix with ruleset

51 views
Skip to first unread message

Souleiman omar hoche

unread,
Jun 8, 2015, 11:51:14 AM6/8/15
to fricas...@googlegroups.com
Hello everyone. I want to know if it is possible to simplify a square matrix with the command "ruleset".
Until now, I managed to simplify each element of the matrix
separately, but it is long (my matrix is 4 * 4).
I want to write my pile of rules and use it to simplify the matrix at once. The result will be in the form of a matrix where the elements are simplified with the rules.
Thank you in advance.

Ralf Hemmecke

unread,
Jun 8, 2015, 12:34:25 PM6/8/15
to fricas...@googlegroups.com
The simplest thing that comes to my mind is to use map the rules on the
entries of the matrix. But unless you make your problem more specific, I
cannot help you much more.

Maybe using "rule" or "ruleset" is even inappropriate for your problem.

Ralf

Souleiman omar hoche

unread,
Jun 8, 2015, 1:35:34 PM6/8/15
to fricas...@googlegroups.com

Ok. Consider the example of the 2*2 square matrix : « matrix([[a*log(sin x)-2*log(x), log(x)+log(y)], [log(x)-log(y), 3*log(x)-4*log(x+3)+log(y)]]) » and the rules : «logrules:=rule(log(x)+log(y)==log(x*y); log(x)-log(y)==log(x/y);y*log(x)==log(x^y)) ». If, i put : « f:=a*log(sin x)-2*log(x) » and use the command « logrules f », i obtain : « log(sin^{a}(x)/x^2) ».

But if i use the command « logrules M », i obtain : « There are no library operations named logrules

Use HyperDoc Browse or issue

)what op logrules

to learn if there is any operation containing " logrules " in its

name.

Cannot find a definition or applicable library operation named

logrules with argument type(s)

Matrix(Expression(Integer))

Perhaps you should use "@" to indicate the required return type,

or "$" to specify which version of the function you need. ».

Is it possible to simplify the matrix M in one shot? Idest all the elements of the matrix M in one shot?

Thanks in advance.

Souleiman omar hoche

unread,
Jun 8, 2015, 1:43:43 PM6/8/15
to fricas...@googlegroups.com
 

Sorry, i forgot to precise that : «M:=matrix([[a*log(sin x)-2*log(x), log(x)+log(y)],[log(x)-7*log(y), 3*log(x)-4log(x+3)+log(y)]]) ».

Ralf Hemmecke

unread,
Jun 8, 2015, 5:11:46 PM6/8/15
to fricas...@googlegroups.com
> Is it possible to simplify the matrix M in one shot? Idest all the elements
> of the matrix M in one shot?

As I said, use map for this.

(1) -> m := matrix([[a*log(sin x)-2*log(x), log(x)+log(y)],
[log(x)-log(y), 3*log(x)-4*log(x+3)+log(y)]])

+a log(sin(x)) - 2log(x) log(y) + log(x) +
(1) | |
+ - log(y) + log(x) log(y) - 4log(x + 3) + 3log(x)+
Type:
Matrix(Expression(Integer))
(2) -> logrules:=rule(log(x)+log(y)==log(x*y);
log(x)-log(y)==log(x/y);y*log(x)==log(x^y))

(2)
{log(y) + log(x) + %B == log(x y) + %B,
x y
- log(y) + log(x) + %C == log(-) + %C, y log(x) == log(x )}
y
Type:
Ruleset(Integer,Integer,Expression(Integer))
(3) -> map(c +-> logrules c, m)

+ a +
| sin(x) |
|log(-------) log(x y) |
| 2 |
| x |
(3) | |
| 3 |
| x x y |
| log(-) log(----------------------------)|
| y 4 3 2 |
+ x + 12x + 54x + 108x + 81 +
Type:
Matrix(Expression(Integer))

Note that you defined logrules to work on "Expression(Integer)" (I
abbreviate by E), however "Matrix(E)" is not the same type as E. But the
entries of the matrix are of type E, so "map" does the job of applying
logrules to each entry.

The form "c +-> logrules c" is a lambda expression that locally defines
a function that takes an entry c of the matrix and applies logrules to it.

Hope that helps.

Ralf

Souleiman omar hoche

unread,
Jun 9, 2015, 4:30:48 AM6/9/15
to fricas...@googlegroups.com
Thank you very much. That's exactly what i want. I really appreciate this forum. You are really very efficient and helpful. Thanks again.

Souleiman omar hoche

unread,
Jun 9, 2015, 4:45:13 AM6/9/15
to fricas...@googlegroups.com
I had another question.

In my rules for the simplification of my matrix 4*4, there a lot of expression of the type « y11*y12==-y12*y11 », in fact the place of the yij (in the first position or in the second position, there are commuting only if all the indice are different) is important but i remark that for fricas it is the same.

Here are my rules : « yjk*yjl=-yjl*yjk for k l;ykj*ylj=-ylj*ykj for k l; yjk*ylm=ylm*yjk for j l and k m».

Fricas dont make the difference between the two position, what can i do to force fricas to make the difference ?

Thanks in advance.

Ralf Hemmecke

unread,
Jun 9, 2015, 5:52:13 AM6/9/15
to fricas...@googlegroups.com
Hello Souleiman,

can you stop posting HTML and not attaching irrelevant old mails?

> In my rules for the simplification of my matrix 4*4, there a lot of
> expression of the type « *y11*y12==-y12*y11* », in fact the place of the*
> yij *(*in the first position or in the second position, there are commuting
> only if all the indice are different*) is important but i remark that for
> fricas it is the same.

FriCAS is one of the few systems that can use "*" both for denoting
commutative and non-commutative multiplication. However, within the type
Expression(Integer) "*" is meant to be commutative.

> Here are my rules : « *yjk*yjl=-yjl*yjk for k ≠ l;ykj*ylj=-ylj*ykj for k ≠
> l; yjk*ylm=ylm*yjk for j ≠ l and k ≠ m*».

OK. But I have the impression that this is only part of your problem.
Obviously, you want to have this in connection with your logrules. For a
good suggestion it would be good to have a full description of what you
are trying to achieve.

In particular, you seem to focus on (simplification) rules. FriCAS is
different to most other CAS. One usually doesn't just enter an
expression and then "simplifies" or transforms it, but rather one thinks
in advance in which "domain" that expression lives.

So for your "non-commutative" multiplication I would probably define a
polynomial ring with the yij's as variables and a special
multiplication. And then enter your data as elements of this domain.
Then the "simplification" happens automatically, since your "domain"
knows all about the properties of the non-commutative multiplication. In
other words, you implement a non-commutative algebra and then work in that.
Yes, that involves a bit of programming.

If, however, you want to use such an algebra in connection with rules,
it probably gets a little more involved.

Ralf

Souleiman omar hoche

unread,
Jun 9, 2015, 6:33:10 AM6/9/15
to fricas...@googlegroups.com
Ok thanks.

Waldek Hebisch

unread,
Jun 9, 2015, 8:56:01 AM6/9/15
to fricas...@googlegroups.com
Souleiman omar hoche wrote: >
> I had another question.
>
> In my rules for the simplification of my matrix 4*4, there a lot of
> expression of the type y11*y12==-y12*y11, in fact the place of the
> yij (in the first position or in the second position, there are
> commuting
> only if all the indice are different) is important but i remark
> that for
> fricas it is the same.
>
If you just have products of two things there is a little trick
that may help. Namely, you can define new operator, call it
'left' and 'right'. Then instead of y11*y12 use left(y11)*right(y12)
which clearly is different than left(y12)*right(y11). Of course
if you multiply more things this will no longer work. More
precisely, for a fixed number of factors you can modify this
to encode position using appropriate operator (say pos1, pos2, ...).
But again, there is problem if you want to do longer calculations.

In general FriCAS way is to create new algebra which respect
your rules. For example, XDistributedPolynomial is a domain
where coefficients may be noncommutative, variables do not
commute but it is assumend that variables commute with
coefficients. Note: XDistributedPolynomial makes no extra
assumptions so by itself will not porform simplifications
due to specific commutation rules.

> Here are my rules

For me your rules appear mangled. But they look similar to
rules for Grassman algebra. Maybe you can use one of standard
algebras buit into FriCAS. Or do a little Spad coding to
create algebra fitting your problem.

--
Waldek Hebisch
heb...@math.uni.wroc.pl

Souleiman omar hoche

unread,
Jun 10, 2015, 10:51:59 AM6/10/15
to fricas...@googlegroups.com
Ok thanks for your answer. I tried with left and right operators but it doesn't works unfortunately. Can you help me to create my own algebra with the rules (completed):
relationrules:= rule(y11*y11+y21*y21==1;y11*y11+y12*y12==1;y12*y12+y22*y22==1;y21*y21+y22*y22==1;y11*y12+y21*y22==0;y11*y21+y12*y22==0;y12*y11+y22*y21==0;y21*y11+y22*y12==0;y11*y22+y12*y21==sigma;y11*y22==y22*y11;y12*y21==y21*y12;y11*y12==-y12*y11;y21*y22==-y22*y21;y11*y21==-y21*y11;y22*y12==-y12*y22). I have the fricas documentation but i dont really understand how to use it for this.Now, i just need to make some matrix multiplication using yij and simplify the result with this relations.
Thanks for all.
Sorry, if my post is again in HTML to be honest, i dont know what is the correct form for posting.

Ralf Hemmecke

unread,
Jun 10, 2015, 12:38:39 PM6/10/15
to fricas-devel
On 06/10/2015 06:08 PM, Souleiman omar hoche wrote:
> I have to do this precisly:
>
> ->M:=(1/sqrt(2))*matrix([[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, -1, 0], [1, 0,
> 0, -1]])
>
> ->N:=inverse(M)
>
> ->Y:=N*matrix([[y11*y11, y11*y12, y12*y11, y12*y12], [y11*y21, y11*y22,
> y12*y21, y12*y22], [y21*y11, y21*y12, y22*y11, y22*y12], [y21*y21, y21*y22,
> y22*y21, y22*y22]])*M
>
> ->relationrules:=
> rule(y11*y11+y21*y21==1;y11*y11+y12*y12==1;y12*y12+y22*y22==1;y21*y21+y22*y22==1;y11*y12+y21*y22==0;y11*y21+y12*y22==0;y12*y11+y22*y21==0;y21*y11+y22*y12==0;y11*y22+y12*y21==sigma;y11*y22==y22*y11;y12*y21==y21*y12;y11*y12==-y12*y11;y21*y22==-y22*y21;y11*y21==-y21*y11;y22*y12==-y12*y22)
>
> -> map(c +-> relationrules c, Y)
>
> Until now the results of Fricas and the calculations i have made doesnt
> coincide. And the problem is, i dont suggest to fricas that my
> multiplication is not commutative. I want to learn how to do that and what
> i understand with you is that i must create my own algebra an working on it.
>
> Thanks for reading my thoughts.

Thanks for your description. However, that is still not your *problem*,
me thinks.

What you have given is a number of steps from which I have to figure out
that you want to get a matrix of polynomials in yij.
Your hint that you are working on quantum groups (in another email) is
good. I'm not working in this field, but I have the impression that your
yij and their relations can be represented by matrices. That would
probably already cover a description of the algebra of the yji's.
My guess, you want to get relations in the yij as a result so the idea
would then be to construct a algebra that implements the operations via
matrix multiplication. I'm not yet sure whether you can uniquely recover
the initial matrices for the yij's from a general matrix.

So more details of the problem is welcome. What is your input and what
do you want to achieve in the end?

Ralf

Ralf Hemmecke

unread,
Jun 10, 2015, 7:57:13 PM6/10/15
to Souleiman omar hoche, fricas-devel
Hi Souleiman,

Your expressions looked rather easy, so I did the reduction by hand.

http://axiom-wiki.newsynthesis.org/ExampleXDistributedPolynomial

One could also really introduce a symbolic sigma. I didn't bother, and
used 1111 instead.

Ralf

Souleiman omar hoche

unread,
Jun 11, 2015, 4:56:50 AM6/11/15
to fricas...@googlegroups.com, hochso...@gmail.com

Hi Ralf. Thanks for your quick answer. This really answers my question. Thanks again.
Reply all
Reply to author
Forward
0 new messages