Ask Your Question

Pierre's profile - activity

2017-12-19 21:34:57 +0200 received badge  Notable Question (source)
2017-12-19 21:34:57 +0200 received badge  Famous Question (source)
2015-11-16 12:48:34 +0200 received badge  Popular Question (source)
2015-04-13 21:03:45 +0200 received badge  Teacher (source)
2015-04-11 16:29:03 +0200 received badge  Supporter (source)
2015-04-11 13:41:34 +0200 received badge  Student (source)
2015-04-11 02:30:20 +0200 commented answer Why is sage giving me wrong answers?

There is a similar question in this thread

http://ask.sagemath.org/question/1006...

2015-04-11 02:08:41 +0200 commented answer Why is sage giving me wrong answers?

Can be written this way too

var('t,v,a,b', domain="complex");
v=sqrt(-3);   a=(-1+v)/2;  b=(-1-v)/2;
t=a*b; t.real(); t.imag();

or this way

var('t,v', domain="complex");
v=sqrt(-3);
t=((-1+v)/2)*((-1-v)/2);
t.expand().factor();
2015-04-11 01:46:27 +0200 received badge  Editor (source)
2015-04-11 01:37:57 +0200 commented answer Why is sage giving me wrong answers?

OOOPs it doesn't work

i=CC(-3); 

j=CC(-1);

k=CC(2);

t = ((j + sqrt(i))/k)*((j - sqrt(i))/k);

t.real();

t.imag();

The error moved into he imaginary part (approx 0.5 E-16).

I must edit the answer .....

2015-04-11 01:34:50 +0200 commented answer Why is sage giving me wrong answers?

Sage complex numbers are based on floating points, 1+2i is implemented as 1.00000000 + 2.00000000000 * i.

2015-04-11 01:00:20 +0200 answered a question Why is sage giving me wrong answers?

Default complex numbers use double precision floating points and their rounding errors (which can't be avoided).

Use variable from the right field and arithmetic specific to complex numbers

var('t,v,a,b', domain="complex")
v=sqrt(-3);
a=(-1+v)/2;
b=conjugate(a);
t = a*b;

v;
a;
b;
t.real();
t.imag();

displays

sqrt(-3)
1/2*sqrt(-3) - 1/2
1/2*conjugate(sqrt(-3)) - 1/2
1
0
2015-04-10 23:38:04 +0200 asked a question Compute the determinant of a symbolic 5x5 matrix

why does the following script fail to compute the determinant of a 5x5 matrix (same problem appears with larger similar matrices 6x6 and 7x7 matrix too) ?

version();

var ('a,b,c,d,e,f,g,h');

A4 = matrix(SR,4,4,[a,b,c,d,a,a,b,c,a,a,a,b,h,a,a,a]);

A5 = matrix(SR,5,5,[a,b,c,d,e,a,a,b,c,d,a,a,a,b,c,a,a,a,a,b,h,a,a,a,a]);

A4; A4.determinant().expand().factor();

A5; A5.determinant();
A5.determinant().expand().factor();

a spurious "_e" appears in the determinant

'Sage Version 6.5, Release Date: 2015-02-17'
(a, b, c, d, e, f, g, h)
[a b c d]
[a a b c]
[a a a b]
[h a a a]
a^4 - 3*a^3*b + 3*a^2*b^2 - 2*a^2*b*c + a^2*c^2 + a^3*d - a^2*b*d - b^3*h + 2*a*b*c*h - a*c^2*h - a^2*d*h + a*b*d*h
[a b c d e]
[a a b c d]
[a a a b c]
[a a a a b]
[h a a a a]
_e*a^4 + a^5 - 2*_e*a^3*b - 4*a^4*b + _e*a^2*b^2 + 6*a^3*b^2 - 4*a^2*b^3 + 3*a^2*b^2*c - a^3*c^2 - 2*a^2*b*c^2 + a^2*c^3 - 2*a^3*b*d + 2*a^2*b^2*d + 2*a^3*c*d - 2*a^2*b*c*d - _e*a^3*h + 2*_e*a^2*b*h - _e*a*b^2*h + b^4*h - 3*a*b^2*c*h + a^2*c^2*h + 2*a*b*c^2*h - a*c^3*h + 2*a^2*b*d*h - 2*a*b^2*d*h - 2*a^2*c*d*h + 2*a*b*c*d*h
Error in lines 13-19
Traceback (most recent call last):
  File "/projects/cbc78de9-848d-4653-bf96-aa8a68749e86/.sagemathcloud/sage_server.py", line 879, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
  File "sage/symbolic/expression.pyx", line 9266, in sage.symbolic.expression.Expression.factor (build/cythonized/sage/symbolic/expression.cpp:45045)
    f = self.polynomial(QQ)
  File "sage/symbolic/expression.pyx", line 5716, in sage.symbolic.expression.Expression.polynomial (build/cythonized/sage/symbolic/expression.cpp:31627)
    return polynomial(self, base_ring=base_ring, ring=ring)
  File "/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1163, in polynomial
    converter = PolynomialConverter(ex, base_ring=base_ring, ring=ring)
  File "/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 999, in __init__
    self.ring = PolynomialRing(self.base_ring, names=vars)
  File "/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 477, in PolynomialRing
    R = _multi_variate ...
(more)