1 | initial version |
This issue is not really about matrices but about how Sage not being able to figure out that sqrt()
here are real numbers that are invariant with respect to conjugate()
. It may be possible to help Sage understand this with a set of assumptions, but I do not know how to do so (I've tried assume(norm(w_2) < 1)
and alike, but it did not help).
Below is an alternative solution using a function that manually looks for patterns conjugate(sqrt(...))
and replaces them with just sqrt(...)
def simplify_conjugate_of_sqrt(f):
x = SR.wild(0)
return f.subs({conjugate(sqrt(x)):sqrt(x)}).full_simplify()
It amounts only to replacing T.simplify_full()
in your code to T.apply_map(simplify_conjugate_of_sqrt)
to a much simpler matrix:
[ -(w_2*conjugate(w_2) - 1)*w_3*w_4*conjugate(w_3)*conjugate(w_4) -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_4*conjugate(w_3)*conjugate(w_4) sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_3)*conjugate(w_4) 0]
[ -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_3*w_4*conjugate(w_4) -(w_3*conjugate(w_3) - 1)*w_4*conjugate(w_4) -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_4) 0]
[ sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_3*w_4 -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_4 -w_4*conjugate(w_4) + 1 0]
[ 0 0 0 1]
Basically it matches the OP's expected matrix, with just each norm(z)
replaced with z * conjugate(z)
, but this is how Sage handles the norm(z)
function.
2 | No.2 Revision |
This issue is not really about matrices but about how Sage not being able to figure out that sqrt()
here are real numbers that are invariant with respect to conjugate()
. It may be possible to help Sage understand this with a set of assumptions, but I do not know how to do so (I've tried assume(norm(w_2) < 1)
and alike, but it did not help).
Below is an alternative solution using a function that manually looks for patterns conjugate(sqrt(...))
and replaces them with just sqrt(...)
def simplify_conjugate_of_sqrt(f):
x = SR.wild(0)
return f.subs({conjugate(sqrt(x)):sqrt(x)}).full_simplify()
It amounts only to replacing T.simplify_full()
in your OP's code to T.apply_map(simplify_conjugate_of_sqrt)
to get a much simpler matrix:
[ -(w_2*conjugate(w_2) - 1)*w_3*w_4*conjugate(w_3)*conjugate(w_4) -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_4*conjugate(w_3)*conjugate(w_4) sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_3)*conjugate(w_4) 0]
[ -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_3*w_4*conjugate(w_4) -(w_3*conjugate(w_3) - 1)*w_4*conjugate(w_4) -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_4) 0]
[ sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_3*w_4 -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_4 -w_4*conjugate(w_4) + 1 0]
[ 0 0 0 1]
Basically it matches the OP's expected matrix, with just each norm(z)
replaced with z * conjugate(z)
, but this is how Sage handles the norm(z)
function.
3 | No.3 Revision |
This issue is not really about matrices but about how Sage not being able to figure out that sqrt()
here are real numbers that are invariant with respect to conjugate()
. It may be possible to help Sage understand this with a set of assumptions, but I do not know how to do so (I've tried assume(norm(w_2) < 1)
and alike, but it did not help).
Below is an alternative solution using a function that manually looks for patterns conjugate(sqrt(...))
and replaces them with just sqrt(...)
def simplify_conjugate_of_sqrt(f):
x = SR.wild(0)
return f.subs({conjugate(sqrt(x)):sqrt(x)}).full_simplify()
It amounts only to replacing T.simplify_full()
in OP's code to with T.apply_map(simplify_conjugate_of_sqrt)
to get a much simpler matrix:
[ -(w_2*conjugate(w_2) - 1)*w_3*w_4*conjugate(w_3)*conjugate(w_4) -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_4*conjugate(w_3)*conjugate(w_4) sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_3)*conjugate(w_4) 0]
[ -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_3*w_4*conjugate(w_4) -(w_3*conjugate(w_3) - 1)*w_4*conjugate(w_4) -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_4) 0]
[ sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_3*w_4 -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_4 -w_4*conjugate(w_4) + 1 0]
[ 0 0 0 1]
Basically it matches the OP's expected matrix, with just each norm(z)
replaced with z * conjugate(z)
, but this is how Sage handles the norm(z)
function.
4 | No.4 Revision |
This issue is not really about matrices but about how Sage not being able to figure out that sqrt()
here are real numbers that are invariant with respect to conjugate()
. It may be possible to help Sage understand this with a set of assumptions, but I do not know how to do so (I've tried assume(norm(w_2) < 1)
and alike, but it did not help).
Below is I present an alternative solution solution, using a function that manually looks for patterns conjugate(sqrt(...))
and in a given expression. replaces them with just sqrt(...)
, and simplifies the result:
def simplify_conjugate_of_sqrt(f):
x = SR.wild(0)
return f.subs({conjugate(sqrt(x)):sqrt(x)}).full_simplify()
It amounts only to replacing T.simplify_full()
in OP's code with T.apply_map(simplify_conjugate_of_sqrt)
to get a much simpler matrix:
[ -(w_2*conjugate(w_2) - 1)*w_3*w_4*conjugate(w_3)*conjugate(w_4) -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_4*conjugate(w_3)*conjugate(w_4) sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_3)*conjugate(w_4) 0]
[ -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_3*w_4*conjugate(w_4) -(w_3*conjugate(w_3) - 1)*w_4*conjugate(w_4) -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_4) 0]
[ sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_3*w_4 -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_4 -w_4*conjugate(w_4) + 1 0]
[ 0 0 0 1]
Basically it matches the OP's expected matrix, with just each norm(z)
replaced with z * conjugate(z)
, but this is how Sage handles the norm(z)
function.
5 | No.5 Revision |
This issue is not really about matrices but about how Sage not being able to figure out that sqrt()
here are real numbers that are invariant with respect to conjugate()
. It may be possible to help Sage understand this with a set of assumptions, but I do not know how to do so (I've tried assume(norm(w_2) < 1)
and alike, but it did not help).
Below I present an alternative solution, using a the following function that manually looks for patterns conjugate(sqrt(...))
in a given expression. expression, replaces them with just sqrt(...)
, and simplifies the result:
def simplify_conjugate_of_sqrt(f):
x = SR.wild(0)
return f.subs({conjugate(sqrt(x)):sqrt(x)}).full_simplify()
It amounts only to replacing T.simplify_full()
in OP's code with T.apply_map(simplify_conjugate_of_sqrt)
to get a much simpler matrix:
[ -(w_2*conjugate(w_2) - 1)*w_3*w_4*conjugate(w_3)*conjugate(w_4) -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_4*conjugate(w_3)*conjugate(w_4) sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_3)*conjugate(w_4) 0]
[ -sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_3*conjugate(w_3) + 1)*w_3*w_4*conjugate(w_4) -(w_3*conjugate(w_3) - 1)*w_4*conjugate(w_4) -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*conjugate(w_4) 0]
[ sqrt(-w_2*conjugate(w_2) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_3*w_4 -sqrt(-w_3*conjugate(w_3) + 1)*sqrt(-w_4*conjugate(w_4) + 1)*w_4 -w_4*conjugate(w_4) + 1 0]
[ 0 0 0 1]
Basically it matches the OP's expected matrix, with just each norm(z)
replaced with z * conjugate(z)
, but this is how Sage handles the norm(z)
function.