For mathematical questions about Python; questions purely about the language, syntax, or runtime errors are off-topic here and would likely be better received on Stack Overflow.
Questions tagged [python]
978 questions
19
votes
1 answer
How to convert Euler angles to Quaternions and get the same Euler angles back from Quaternions?
I am rotating n 3D shape using Euler angles in the order of XYZ meaning that the object is first rotated along the X axis, then Y and then Z. I want to convert the Euler angle to Quaternion and then get the same Euler angles back from the Quaternion…
Amir
- 475
12
votes
3 answers
Infinite sum of Python for loop
I'm a geometry student. Recently we were doing all kinds of crazy circle stuff, and it occurred to me that I don't know why $\pi r^2$ is the area of a circle. I mean, how do I really know that's true, aside from just taking my teachers + books at…
Ashleigh Basil
- 121
11
votes
2 answers
Math for simple 3D coordinate rotation (python)
I'm rotating points from one coordinate system to the other, but drawing a blank how to do this.
I've done some reading about Euler angles but after staring at this GIF for a while I just get dizzy.
above: from here
What I am doing:
The new $z$…
uhoh
- 1,967
10
votes
3 answers
Why is a simulation of a probability experiment off by a factor of 10?
From a university homework assignment:
There are $8$ numbered cells and $12$ indistinct balls. All $12$ balls are randomly divided between all of the $8$ cells. What is the probability that there is not a single empty cell ($i.e.$ each cell has at…
Shmuel Levinson
- 117
9
votes
1 answer
When are $n!+1$ and $(n+2)!+1$ coprime?
For every $n\geq 1$, $n!+1$ and $(n+1)!+1$ are coprime. I suspected the same would happen for $n!+1$ and $(n+2)!+1$, but short Python script yielded 3 counterexamples:
$\gcd(7!+1,9!+1)=71$
$\gcd(16!+1,18!+1)=61$
$\gcd(61!+1,63!+1)=71$
But up to…
aleph2
- 1,056
8
votes
2 answers
Bouncing Bullet Problem
This is a problem that was presented to me through the google foobar challenge, but my time has since expired and they had decided that I did not complete the problem. I suspect a possible bug on their side, because I passed 9/10 test cases (which…
Kraigolas
- 1,569
8
votes
0 answers
Convergence of the complex QR algorithm to Schur decomposition
I study the complex Schur decomposition of a complex matrix $A \in \mathbb{C}^{n \times n}$, that is:
$$ A = U T U^H $$
where $T$ is upper-triangular (the eigenvalues of $A$ appear on its diagonal, and may be complex) and $U$ is unitary $U^H =…
Triceratops
- 404
8
votes
5 answers
How to solve 5x5 grid with 16 diagonals?
I have a grid 5x5 and I have to fill 16 little squares with a diagonal
Rules
You cannot place more than 1 diagonal in each square
The diagonals cannot touch each other (example bellow)
Click here to view the solution
But what I seek here is a…
BrunoLM
- 199
8
votes
1 answer
tensor product and einsum in numpy
I am trying to understand the einsum function in NumPy. In this documentation, the last example,
>>> a = np.arange(60.).reshape(3,4,5)
>>> b = np.arange(24.).reshape(4,3,2)
>>> np.einsum('ijk,jil->kl', a, b)
array([[ 4400., 4730.],
[ 4532.,…
LWZ
- 295
8
votes
2 answers
How to reduce matrix into row echelon form in NumPy?
I'm working on a linear algebra homework for a data science class. I'm suppose to make this matrix into row echelon form but I'm stuck.
Here's the current output
I would like to get rid of -0.75, 0.777, and 1.333 in A[2,0], A[3,0], and A[3,1]…
7
votes
3 answers
Determine if a number is algebraic.
I recall there is an algorithm involving lattices that would tell me if a given number(approximation) is an algebraic number or not, along with the exact algebraic form of the number. Is there any tool (Gap, Mathematica, python package, etc) that…
ReverseFlowControl
- 1,126
7
votes
4 answers
How many non-diagonalizable $2\times 2$ matrices are there with all entries single-digit strictly positive integers?
I'd like to know how many non-diagonalizable size 2 matrices there are with integer coefficient between 1 and 9.
I built a python program which counts the non-diagonalizable matrices with such coefficients:
from sympy import *
count = 0
for a in…
anni
- 947
6
votes
2 answers
How to perform high precision calculation involving 100s of decimal places?
This is not directly a math question but rather a question on computing error.
I am looking for ways to perform calculation involving 100s of decimal places (especially for, but not limited to, this problem statement)
One well known library for high…
Nilotpal Sinha
- 24,086
6
votes
2 answers
Doubling Point Formula of Elliptic Curve is Not Working
Let $E$ be an elliptic curve and a point $P = (x, y) \in E,$ from the duplication formula, the x-coordinate of $2P$ is -
$$x_{(2P)}=(x^4-b_4*x^2-2*b_6*x-b_8)/(4*x^3+b_2*x^2+2*b_4*x+b_6)$$
The formula is given on page $54$ in book The Arithmetic…
Consider Non-Trivial Cases
- 574
- 6
- 23
6
votes
2 answers
How many right triangles can be built from points
There are array of points, I need to determine how many right-angled triangles can be built from them.
This is a task for both programming and geometry.
Because the number of points can be very large, and the time to run the program is…
yoloy
- 165