First time here? Check out the FAQ!

Ask Your Question
1

reduce_trig for matrices

asked 14 years ago

mhfrey gravatar image

updated 13 years ago

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.

Preview: (hide)

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 ( 14 years ago )

3 Answers

Sort by » oldest newest most voted
3

answered 14 years ago

niles gravatar image

You could try using apply_map, as suggested here:

Is there a way to simplify_full and trig_reduce a matrix?

Preview: (hide)
link
0

answered 14 years ago

mhfrey gravatar image

That works, Thank you for the fix.

Preview: (hide)
link
0

answered 13 years ago

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.

Preview: (hide)
link

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: 14 years ago

Seen: 1,629 times

Last updated: May 16 '11