Ask Your Question

mattb's profile - activity

2023-09-01 04:18:20 +0200 received badge  Famous Question (source)
2023-09-01 04:18:20 +0200 received badge  Notable Question (source)
2023-09-01 04:18:20 +0200 received badge  Popular Question (source)
2023-02-05 03:12:51 +0200 received badge  Notable Question (source)
2021-05-31 18:10:35 +0200 received badge  Popular Question (source)
2020-02-25 13:29:24 +0200 commented answer Fill intersection of multiple ellipses

Thanks for the idea. Actually, this was kind of how I was trying to tackle the problem. Your answer got further than I was able to. But the contour plot approach shown by Juanjo seems to work well, and give me the end result I was looking for.

2020-02-25 13:27:14 +0200 commented answer Fill intersection of multiple ellipses

Thank you! This is a great answer. This is exactly what I was trying to do.

2020-02-23 03:44:24 +0200 received badge  Nice Question (source)
2020-02-22 19:11:41 +0200 asked a question Fill intersection of multiple ellipses

I'm plotting multiple ellipses via the ellipse() function. I want to only fill the area where they all overlap. I see there are many options for plotting and filling. However, all the examples I've seen refer to other types of plots that would not be compatible with ellipses. Is there a way to automatically fill the overlapping area of multiple ellipses without pre-calculating this area?

For example, two of the ellipse functions would be:

4.31814496201205*x^2 + 0.442360403122904*x*y + 0.0424448964961035*y^2 - 0.170411375833593*x - 0.0205526646997484*y - 2.4358560850288997
ellipse((0.01, 0.19), 8.86, 0.75, 92.96*pi/180)

7.81630506700337*x^2 - 47.0795923749769*x*y + 72.3295112191380*y^2 + 8.78879644990554*x - 27.0144183395227*y + 0.1289109700897777
ellipse((0.01, 0.19), 4.13, 0.17, 18.06*pi/180)
2020-02-22 18:39:48 +0200 commented answer defining multivariate polynomial ring in script

Perfect! So simple, but didn't know about the 'inject_variables' method. Thanks!

2020-02-22 18:38:46 +0200 received badge  Scholar (source)
2020-02-08 12:09:30 +0200 received badge  Student (source)
2020-02-08 00:59:48 +0200 commented question defining multivariate polynomial ring in script

That gives me the same result as my second example.

2020-02-07 14:16:21 +0200 asked a question defining multivariate polynomial ring in script

I'm trying to setup a multivariate polynomial ring within a generic python script so I can access the coefficients of an ellipse easily. One wrinkle in the problem is that I'm declaring variables that have an arbitrary display value. For instance,

theta1, theta2 = var('v1073, v1074')
f = 10.6*theta1**2 + 4.63*theta1*theta2 + 5.332*theta2**2 + 4.56*theta1 + 3.25456*theta2 - 43.54352

The reason I'm declaring a different value between the variable and the display value is because I'm using this same equation in a loop where I update the variable values to represent a current pair. This equation is being used to generate elliptical variable constraints in an optimization.

To the heart of the question. I can get the proper output for the coefficients if I declare a PolynomialRing lexographically. But this format is not compatible with a python script. How do you define the same PolynomialRing in another way? For example:

A.<theta1, theta2> = QQ[]; A
Multivariate Polynomial Ring in theta1, theta2 over Rational Field
f.coefficients()
[10.6, 4.63, 5.332, 4.56, 3.25456, -43.54352]

but

A = QQ['theta1', 'theta2']; A
Multivariate Polynomial Ring in theta1, theta2 over Rational Field
f.coefficients()
[[5.332*v1074^2 + 3.25456*v1074 - 43.54352, 0],
[4.63*v1074 + 4.56, 1],
[10.6, 2]]

I've tried a few other methods, but it doesn't seem to work. Even though when I look at the definition of A, I get the same answer as to what it represents. How can I define the ring, such that I get the correct answer?

2020-02-04 03:24:20 +0200 commented question Generate >2D Matrix

OK, it did work. It required the 2-dimensions. But that is even more work than just using a Python List, since you still need to two sets of brackets to specify an element. It looks like maybe a list of matrices might be my best bet.

Alternatively, I think I saw that Maxima supports arrays. Since I'm doing most of the computation there, I may look into just storing the data there as well.

2020-02-03 23:55:44 +0200 commented question Generate >2D Matrix

A list of matrices would work. I was just hoping there would be something more intact, so that you don't have to make function calls through a for loop or list comprehension. Also, nesting lists, etc. can be a lot more confusing to decipher, since you have multiple sets of brackets. It seems like this aspect would actually slow things down. Maybe there's an even easier way to handle it if it is a list matrices without the for loop/list comprehension?

For a vector/matrix of matrices. I tried this. I got an error from Sage. Seems that Sage requires the elements of the matrix to be within some namespace. Maybe this is just due to an issue with declaration?

2020-02-03 14:27:19 +0200 asked a question Generate >2D Matrix

I am trying to find a concise way to store data in a single variable for easy computational referencing. This data is basically an n-length vector of 2x2 matrices. I would like to be able to do linear algebra on the 2x2 matrices, but each of the n elements are handled separately. Is there an easy way to do this?

Basically, this would be the equivalent of a nx2x2 array in Numpy. The reason I want to use Sage instead of Numpy, is because there is a lot of linear algebra, including some symbolic, that needs to be performed. Numpy and Sympy are too slow for this. I've been able to do these computations in Maxima with an acceptable speed. For ease of interfacing with my Python script, I would like to just use Sage. This would also make things much easier if I do still need to push some of the computation to Maxima.

2020-01-09 13:38:28 +0200 commented answer Problem importing Sage library in Python script on Windows

OK, so it's a bit of a misunderstanding on my part. SageMath is actually a complete environment, not just an add in package. I did try to run in sage, but I couldn't seem to figure out how to load the other needed packages into the sage environment. I'll do some more reading, including your link, to see if I can figure this one out. Unfortunately, Windows is such a pain to deal with all these things. I wish we were running Linux or Mac at work, but that is not the case.

if all I'm using SageMath for is a go between with Maxima, is there any scaled down implementation that doesn't necessarily need the SageMath environment?

2020-01-08 22:34:44 +0200 asked a question Problem importing Sage library in Python script on Windows

I have a script that is fully operational which uses Sage as a python library in my python script. It runs completely normal on MacOS. However, when I tried to transfer this to work, where we are on Windows, I cannot load Sage in my python script. I get a ModuleNotFoundError.

Some background on this. My MacOS setup was generated via miniconda, including the conda package install of sage. Really, I'm only using Sage for a nice python friendly interface to Maxima, where I can do some very complex symbolic matrix computations very quickly.

On Windows, I was using MSYS2. However, after reading that Sage does not support this whatsoever, I installed Cygwin. Everything, except Sage, is running fine on Cygwin. I installed Sage via the Windows installer.

What do I need to do with the installation to get my python script to find Sage?

As an aside, is there a reason why there is no conda package for Sage on Windows, only Linux and MacOS? Trying to install Sage on Windows has been an all day, 2 day nightmare, and it is still not working. The Windows installer works fine if you just want to use Sage completely standalone. But it seems completely incompatible for integration with other languages/tools. I even tried to self compile. It took ~5-6 hours, then I got an error that one of the packages, bleach, failed. When I looked at the log for that, it seems like there was a connection issue and the source could not be downloaded. This all seems like complete overkill for using Sage in a python script.