Ask Your Question

Laurent B's profile - activity

2021-08-01 00:22:08 +0200 received badge  Popular Question (source)
2020-05-13 19:44:42 +0200 received badge  Popular Question (source)
2018-11-22 22:17:21 +0200 received badge  Famous Question (source)
2017-11-18 00:48:29 +0200 received badge  Notable Question (source)
2017-07-13 02:19:16 +0200 received badge  Popular Question (source)
2017-03-14 18:20:00 +0200 asked a question How to keep 1/sqrt(2) as 1/sqrt(2) ? [the canonical form is not canonical]

Hi all Using sagetex to make computaion, I would like it to keep radical in the denominator (though I remember my 8 th grade course viewing the canonical form today in a pdf file seems odd ) so something like 1/sqrt(2) would not be written as sqrt(2)/2 as it is normally. I saw this related link : https://ask.sagemath.org/question/352... but for me the command 1/sqrt(2).maxima_methods().rootscontract().simplify() gives also a "canonical" result. Cheers,

2017-02-18 19:38:48 +0200 asked a question How to make a function of 'fname' that produce a file named 'fname'

Hi all,

Typing a correction on some recurrent sequences $u_{n+1}=f(u_n)$ I use sage to build a nice plot illustrating the behavior of the sequence depending on the initial data. I took a nice function from this awesome book.

def escargot(f,x,u0,n,xmin,xmax,file):
    u = u0
    P = plot(x, x, xmin, xmax, color='gray')
    for i in range(n):     
        P+= line([[u,u],[u,f(u)],[f(u),f(u)]], color ='red')
        u = f(u)
    P += f.plot(x, xmin, xmax, color='blue') 
    P.save('/home/myfolder/f1a.png')

So everyhting work perfectly but, since there is a lot of examples to produce, I would like to make the function to have an extra argument say filename so that now the file so that now the plot is saved in /home/myfolder/filename.png, but I have no idea how sage manipulate string. Help would be welcome !

2017-02-01 09:50:55 +0200 commented question Where are stored gif files by default

Well ok, sorry to the people who read this ... you can save it where you want by myanime.save('/home/myusername/myfolder/myfilename') My bad .... :( :| :8

2017-01-31 22:45:43 +0200 received badge  Editor (source)
2017-01-31 22:35:02 +0200 asked a question Where are stored gif files by default

Ok I know this is a stupid question. (But i spend already half an hour on it :( ) After using a.save('myanime') on a animate I can't find the gif file (which is the default extension AFAIK) To be more specific:

I am using sage on a linux debian (sage recenlty returned to the debian archives !!:D!!) so I launch sage in terminal (the binary is installed in my /usr/bin ) and the files seemes to be stored in stuff like

/home/myusername/.sage/sage_notebook.sagenb/home/__store__/2/21/212/2123/admin/9 ... Is it right ?

In case yes it is painful to look for something outside fromethe sage notebook and I would like to integrate the .gif in another web pages. Maybe I can choose where to save the gif ?

2016-11-25 11:36:33 +0200 commented answer comparing sets of roots of charpoly

A huge thanks for the explanation ! I get it know and I will be able to adapt it properly. Regarding the first question, actually I want to know if the (rational) Matrix is diagonalizable in $R$ so I need to distinguish between real algebraic eigenvalues and non reals algebraic ones so I took your idea with ring=RR. Thanks a lot, Cheers,

2016-11-25 11:29:08 +0200 received badge  Supporter (source)
2016-11-24 21:15:42 +0200 asked a question comparing sets of roots of charpoly

I am missing something about how to compare list of roots. During a small algorithm I need to know wether a matrix has or not complex eigenvalues. I did the following

   A=matrix(QQ,[[1,2,1],[6,-1,0],[-1,-2,-1]])
   a=(B.charpoly()).roots(ring= QQ, multiplicities=False)
   b=(B.charpoly()).roots(ring= QQbar, multiplicities=False)

then a is the list [-4,0,3] and b is the list [3,0,-4]. I don't get the following :

set(a)==set(b)

return false while

set([-4,0,3])==set([3,0,-4])

return true.

Any help, either on the first pb (knowing that a QQ matrix has complex eigenvalues) or on the second would be greatly appreciated. Cheers.

2015-12-19 20:38:09 +0200 commented answer eigenvalues vs roots of characteristic polynomial

Thanks for your help; and as I suspected the only problem was my own ignorance. Is there any way to ask Sage to give the roots in radicals form instead of decimal notation ?

2015-12-19 20:29:11 +0200 received badge  Scholar (source)
2015-12-17 22:40:37 +0200 received badge  Student (source)
2015-12-17 19:55:41 +0200 asked a question eigenvalues vs roots of characteristic polynomial

Hi,

Sorry if this is a stupid question but I am struggling to make Sage compute the exact eigenvalues of a matrix. I am also confused that when I ask for the roots of the characteristic polynomial Sage answers with complex roots... I am new to Sage so please forgive me :)

Here is my worksheet:

sage: A = matrix([[1, 1, 2], [1, -2, 0], [2, 0, 1]])
sage: A
[ 1  1  2]
[ 1 -2  0]
[ 2  0  1]
sage: A.eigenvalues()
[-2.439311671683875?, -0.6611203141265045?, 3.100431985810380?]
sage: x = var('x')
sage: H = A.charpoly()
sage: H
x^3 - 8*x - 5
sage: H.roots()
[]
sage: (x^3-8*x-5).roots()
[(-1/2*(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3)*(I*sqrt(3) + 1) + 1/3*(4*I*sqrt(3) - 4)/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3),
  1),
 (-1/2*(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3)*(-I*sqrt(3) + 1) + 1/3*(-4*I*sqrt(3) - 4)/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3),
  1),
 ((1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3) + 8/3/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3),
  1)]