Ask Your Question
1

reduce_trig for matrices

asked 2010-12-29 12:24:53 +0100

mhfrey gravatar image

updated 2011-04-28 18:07:58 +0100

Kelvin Li gravatar image

I am trying to reduce the trig functions of the following symbolic matrix:

[  sin(1/2*B)*cos(1/2*B)  I*sin(1/2*B)^2 - 1/2*I]
[-I*sin(1/2*B)^2 + 1/2*I  -sin(1/2*B)*cos(1/2*B)]

I expect:

[1/2*sin(B), -1/2*I*cos(B)]
[1/2*I*cos(B), -1/2*sin(B)]

But get: Traceback (click to the left of this block for traceback) ... AttributeError: 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense' object has no attribute 'reduce_trig'

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>
  File "_sage_input_170.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("KFJ4KEIpKkl5KlJ4KC1CKSkucmVkdWNlX3RyaWcoKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

  File "/tmp/tmpTc7DZX/___code___.py", line 2, in <module>
    exec compile(u'(Rx(B)*Iy*Rx(-B)).reduce_trig()
  File "", line 1, in <module>

  File "element.pyx", line 306, in sage.structure.element.Element.__getattr__ (sage/structure/element.c:2666)
  File "parent.pyx", line 272, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:2840)

What am I doing wrong?

Thank you for your help.

edit retag flag offensive close merge delete

Comments

you can use the "code" button (little picture of 0's and 1's) to format code (such as the traceback lines) correctly

niles gravatar imageniles ( 2010-12-29 12:29:06 +0100 )edit
kcrisman gravatar imagekcrisman ( 2011-01-03 22:02:11 +0100 )edit

3 Answers

Sort by ยป oldest newest most voted
3

answered 2010-12-29 12:31:07 +0100

niles gravatar image

You could try using apply_map, as suggested here:

Is there a way to simplify_full and trig_reduce a matrix?

edit flag offensive delete link more
0

answered 2010-12-29 13:04:16 +0100

mhfrey gravatar image

That works, Thank you for the fix.

edit flag offensive delete link more
0

answered 2011-05-16 16:20:55 +0100

kcrisman gravatar image

As it turns out, we already have it, just not with all possible aliases! I didn't even know this.

sage: m = matrix([[sin(x), cos(x)], [sin(x), cos(x)]]); m
[sin(x) cos(x)]
[sin(x) cos(x)]
sage: o = m*m.transpose()
sage: o.simplify_trig()
[1 1]
[1 1]

But the ticket referenced in the comment above should make all of them available.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-12-29 12:24:53 +0100

Seen: 1,488 times

Last updated: May 16 '11