Ask Your Question

LukeC93's profile - activity

2022-11-21 02:24:18 +0200 received badge  Popular Question (source)
2022-03-02 01:46:07 +0200 received badge  Famous Question (source)
2021-04-20 09:28:18 +0200 received badge  Notable Question (source)
2021-04-20 09:28:18 +0200 received badge  Popular Question (source)
2020-04-11 01:20:52 +0200 received badge  Popular Question (source)
2019-02-21 14:16:28 +0200 commented answer Given a value and conditions, find a matrix with that value as its determinant

Amazing, thank you!

I'm very much a novice in Sage and Python, and have yet to dedicate time to trying to learn it properly, instead opting to just piece things together as and when. Think it might be time for me to go to basics..

2019-02-21 13:01:41 +0200 asked a question Given a value and conditions, find a matrix with that value as its determinant

I'm not sure if the title is named too obscurely, so I'll give an example of what I'm talking.

Say we have an integer matrix: M= 0 a b 0 (sorry for weird formatting; cannot seem to write matrices properly on here - any help with that as well? :P )

I want to find all values $(a,b) \in (-2,-1,0,1,2)$ such that $det(M)=2$.

I've tried the following but I'm not sure how to finish it off / if this is the right way to go:

    import itertools
    for (a,b) in itertools.product([-2,-1,0,1,2], repeat=2):
          M = Matrix(ZZ, [[0,a],[b,0]])
    if M.determinant()==2:
         min_params.append((a,b))
    elif 
         min_params = [(a,b)]
    print 'Sets of parameters with this determinant:', min_params

As I say, I feel like the start would be a good way to go, but I'm stuck when reaching elif, and I'm not sure if this is the right way to tackle this anyway!

Any help would be great!

2019-02-08 14:19:20 +0200 commented answer Minimal determinant of a matrix with varied entries

Amazing; that makes sense and works perfectly for what I'm after. Thank you again!

2019-02-08 12:02:35 +0200 commented answer Minimal determinant of a matrix with varied entries

Yes, that's very much what I'm after - thank you! Couple of questions so I can check I understand the code:

Why do we set min_det = infinity What does this do / mean exactly?

Say I wanted to see the minimal value which was larger than a set number (say 1); presumably I would change the zero in this part of the code to a 1:

elif M_det != 0 and M_det < min_det:

(I know the matrix I've used isn't the best example for checking that!)

2019-02-08 11:05:15 +0200 asked a question Minimal determinant of a matrix with varied entries

I would like Sage to tell me to minimal value of the determinant of a matrix when a vary some entries over a set range.

For example, say with the 4x4 matrix A (sorry for weird layout, I can't get the Latex code to work properly?):

0 1 i j

1 0 1 k

0 1 0 1

0 0 1 0

I'd like to know, for ${i,j,k} \in {0, \pm1}$, what the smallest non-trivial determinant is, and for which combination(s) of $i,j,k$ this is for.

I'm still pretty new to Sage, so I'm a bit unsure of how to do this effectively, if it is at all possible to do this?

Side note: I know I could of course write

sage A.determinant()

and this would give me the value of the determinant in terms of $i,j,k$. And in this example that would likely be much easier.

The idea is that I'd like to do this with larger matrices (that aren't as nice as this), more variables, etc. It would obviously be nicer to have have Sage simply compute the smallest determinant and give the corresponding values for the variables than me have to plug it in.

2019-02-01 12:33:43 +0200 commented answer Product of elements in a set

Wow - the one thing I didn't try, and it was the simplest thing! Thank you.

2019-02-01 12:33:06 +0200 received badge  Scholar (source)
2019-02-01 11:06:31 +0200 received badge  Editor (source)
2019-02-01 11:06:01 +0200 asked a question Product of elements in a set

I have a set of numbers, and I would like to find the product of them. Generally speaking, the set of the numbers could be quite large, and will be complex, so I don't want to have to manually multiply them all. The example I have below only has 3 integer elements though..

v=[1,2,3]
S=Set(v)
S
c=S.cardinality()
c

My original thinking was something along the lines of:

 P = prod(s[i] for i in range(1,c))
 P

But I'm not sure how to: 1) define s[i] appropriately or 2) if this will work

I assume at some point I need to define I'm working in a complex field, but again, I'm not sure where I would need to do that?

2019-01-20 13:27:50 +0200 received badge  Student (source)
2019-01-18 10:11:45 +0200 commented answer Multiplying Roots of a Polynomial

Thank you - this is perfect for what I'm after!

2019-01-17 16:00:04 +0200 asked a question Multiplying Roots of a Polynomial

Hello - I'm new to SAGE, so trying to get to grips with the basics!

I have a polynomial $f = x^{2}((x+\frac{1}{x})^{2} - 1) $. I would like to be able to do to things:

1) See $f$ in the form $\beta(x - \alpha_1)(x-\alpha_2)(x-\alpha_3)(x-\alpha_4)$

2) Know the value of $\beta (\prod_i \alpha_i)$

Using

f.factor

f.roots

Does not give me the linear factorisation, nor can I see a simple way of getting the product of the roots.

In the long term I'm hoping to do this for polynomials of larger degree, so any advice would be great!