Ask Your Question

ozik's profile - activity

2017-12-18 11:26:59 +0200 received badge  Famous Question (source)
2017-12-18 11:26:59 +0200 received badge  Notable Question (source)
2017-10-07 21:17:06 +0200 received badge  Notable Question (source)
2017-07-21 14:45:18 +0200 received badge  Popular Question (source)
2017-06-05 16:58:11 +0200 received badge  Student (source)
2015-01-13 18:22:47 +0200 received badge  Popular Question (source)
2015-01-06 00:24:43 +0200 received badge  Famous Question (source)
2014-03-21 13:41:16 +0200 received badge  Popular Question (source)
2013-10-07 17:52:33 +0200 received badge  Notable Question (source)
2013-05-02 00:17:11 +0200 received badge  Popular Question (source)
2012-11-27 10:54:13 +0200 commented answer Why simplify doesn't work?

Great many thanks!

2012-11-22 20:17:49 +0200 asked a question Why simplify doesn't work?

Hi! My problem is that I don't want to use simplify_full(). It messes up the way my formulea look preety bad. Yet I have in them terms of the form:

f(x,y)=(x^y)^(1/y)

and these a left untouched by simplify(). Is there any way for sage to recognize, that f=x without simplify_full()?

.

(Here's what i mean by messed up formula:

var('x,b2,b1')

f1(x,b1,b2)= e^(-x/b2)/b2 - e^(-x/b1)/b1

f2(x,b1,b2)= x

f1=f1( x=log( (b1/b2)^(b1*b2/(b1-b2)) ) )

f2=f2( x=log( (b1/b2)^(b1*b2/(b1-b2)) ) )

show( f1.simplify_full() + f2.simplify_full()== (f1+f2).simplify_full() )

The lhs looks way better, doesn't it?)

.

Big thanks in advance for any comments!

2012-11-17 20:31:19 +0200 commented answer eigenvalues of a derivative vs derivative of eigenvalues

Is there any way of knowing in what order put the eigenvalues of derivative to get correct trace?

2012-11-17 20:26:43 +0200 commented answer eigenvalues of a derivative vs derivative of eigenvalues

var('x'); M=Matrix(SR, 2,2, [0, cos(x), cos(x), 0]); dM=Matrix(SR, 2,2); for i in range(2): for j in range(2): dM[i,j]=diff(M[i,j], x); dM.eigenvalues() == [diff(M.eigenvalues()[1], x), diff(M.eigenvalues()[0], x)] (dM*M).trace() == dM.eigenvalues()[0]*M.eigenvalues()[1] + dM.eigenvalues()[1]*M.eigenvalues()[0] #and not: (dM *M).trace() =/= dM.eigenvalues()[0]*M.eigenvalues()[0] + dM.eigenvalues()[1]*M.eigenvalues()[1] #as I was hoping for

2012-11-17 20:21:42 +0200 commented answer eigenvalues of a derivative vs derivative of eigenvalues

Well, ok; thank you for that comment. In order to differentiate, I was planning on typing something much-less-fancy, like to loops with dM[i,j]=diff(M[i,j], x). But what about my question? Again, sorry for my lack of narrative competence. I came up with an example:

2012-11-17 19:18:33 +0200 asked a question eigenvalues of a derivative vs derivative of eigenvalues

Hi! I have this little problem. If anyone would be so kind to share his knowledge and shed some lite on it, I'd be very grateful. Big thanks in advance (and sorry for my english)!

I have a matrix M=M(x) depending on a variable x. I want sage to compute trace of a product of a derivative of M, M' and some function of it, f(M), at a fixed value of x=x_0; that is:

(tr[M'*f(M)])|_(x=x_0).

It just so happens that tr[M'*f(M)] = sum( ev_i' *f(ev_i) ), where {ev_i(x)} are eigenvalues of M. Lucky me. Diagonalisation of M commutes with differentiating or taking the function of it, one could say.

But my M and its derivative are somewhat complicated, yet simplify greatly after substituting x=x_0. So I would very much prefer first to compute M', substitute x_0 M0:=M|_(x=x_0) and M'0:=M'|_(x=x_0), and only after that ask sage for eigenvalues:

ev1=M0.eigenvalues()

ev2=M'0.eigenvalues()

So here's the question: do i have any reason for hoping that:

(tr[M'*f(M)])|_(x=x_0) = sum( ev2[i] *f(ev1[i]) for i in range(dim of M) )?

(That is, wether the order of eigenvalues changes if I exchange diagonalisation with differentiation?)

2012-09-04 18:08:32 +0200 commented answer cannot evaluate symbolic expression numerically

Thank you, just what I wanted! I've got another question; i'm not sure if I can ask it here: is there any way to tell sage, that i'm only interested in values of 't' variable in 'solve' running in [0;1] only. I want an answer to 'yes or no' question, if is there a solution for any t belonging to [0;1]. I'm asking, since I need the range if iteration to be more like (999) than (5) and thing get little slow. Thanks in advance for commenting!

2012-09-02 04:39:48 +0200 asked a question cannot evaluate symbolic expression numerically

I'm probably doing something wrong on a fundamental level, so: sorry for my ignorance. Yet i'd very much appreciate any suggestions, how to make this work:

I have me a function f, defined in somewhat lenghty way:

var('a,b,c,d')

i=matrix(SR,3,3, [1,0,0, 0,1,0, 0,0,1])

e_1=matrix(SR,3,3, [1,0,-1, 0,0,0, -1,0,1])
e_2=matrix(SR,3,3, [0,1,-1, 0,0,0, 0,-1,1])
e_3=matrix(SR,3,3, [0,0,0, 1,0,-1, -1,0,1])
e_4=matrix(SR,3,3, [0,0,0, 0,1,-1, 0,-1,1])

M=matrix(SR,3,3, [a,b,1-a-b, c,d,1-c-d, 1-a-c, 1-b-d,a+b+c+d-1])

M_1=e_1*M+M*e_1
M_2=e_2*M+M*e_2
M_3=e_3*M+M*e_3
M_4=e_4*M+M*e_4
A=matrix(SR,4,4, [ M_1[0,0], M_1[0,1],M_1[1,0],M_1[1,1], M_2[0,0], M_2[0,1],M_2[1,0],M_2[1,1], M_3[0,0], M_3[0,1],M_3[1,0],M_3[1,1], M_4[0,0], M_4[0,1],M_4[1,0],M_4[1,1] ])

f(a,b,c,d)=A.determinant()

And then I want a solution to f==0, after giving some random arguments to it

var('k,l,m,n,t,y')

for i in range(5):
    k=random(); n=random()
    if k>n: y=k
    else: y=n
    l=random()*(1-y)
    m=random()*(1-y)
    if k+l+m+n>1:         
        sols=solve([f(k*t+1-t,l*t,m*t,n*t+1-t)==0], t);
        sols[1]

A wild string of numbers pops out. But how do i get to see how much is it? Changing to sols[1].n() gives "TypeError: cannot evaluate symbolic expression numerically".

Thanks in advance!

2012-08-02 09:39:17 +0200 received badge  Supporter (source)
2012-07-30 14:52:07 +0200 asked a question implicit_plot3d(A(a,b,c,d).determinant()==0,...), variable not found

Hi!; i've just today used sage for the first time in my life in order to do this one thing described below. I failed, so if anyone would share some helpful thoughts, Id be very grateful.

I have: four real variables: a,b,c,d, each one satisfying: 0=< a,b,c,d,a+b,a+c,...,c+d=<1, (so that m, the 3x3 matrix, is doubly stochastic:) m=[(a,b,1-a-b), (c,d, 1-c-d), (1-a-c, 1-b-d, a+b+c+d-1)]. I do some simple algerba with m end its elements, ending up with a 4x4, (a,b,c,d)-dependent matrix, A. I want to have a look at a plot of an implicit function det(A)==0. I figured i could use implicit_plot3d e.g. in (a,b,c) space with fixed d.

Yet something went wrong; last line of the error message says:

ValueError: Variable 'd' not found

here's, what I've typed from the top:

e_1=matrix(SR,3,3, [1,0,-1, 0,0,0, -1,0,1])
e_2=matrix(SR,3,3, [0,1,-1, 0,0,0, 0,-1,1])
e_3=matrix(SR,3,3, [0,0,0, 1,0,-1, -1,0,1])
e_4=matrix(SR,3,3, [0,0,0, 0,1,-1, 0,-1,1]);
var('a,b,c,d')
m=matrix(SR,3,3, [a,b,1-a-b, c,d,1-c-b, 1-a-c, 1-b-d,a+b+c+d-1])
m_1=e_1*m+m*e_1
m_2=e_2*m+m*e_2
m_3=e_3*m+m*e_3
m_4=e_4*m+m*e_4
A=matrix(SR,4,4, [ m_1[0,0],m_1[0,1],m_1[1,0],m_1[1,1], m_2[0,0], m_2[0,1],m_2[1,0],m_2[1,1],m_3[0,0],m_3[0,1],m_3[1,0],m_3[1,1], m_4[0,0],m_4[0,1],m_4[1,0],m_4[1,1] ])
d=0.5
f(a,b,c)=A.determinant()
implicit_plot3d(f, (a, 0,1), (b, 0,1), (c, 0,1))