Questions tagged [python]

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.

892 questions
16
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
  • 405
  • 1
  • 5
  • 17
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…
10
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
  • 2,010
  • 2
  • 17
  • 44
9
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…
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,549
  • 5
  • 19
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
  • 1
  • 7
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
  • 1
  • 3
  • 7
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…
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
  • 919
  • 4
  • 13
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…
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
  • 5
6
votes
1 answer

Verify the Riemann Hypothesis for first 1000 zeros.

I'm trying to verify the Riemann hypothesis for the first 1000 zeros using the Euler-MacLaurin expansion of $\zeta(s)$. But here's where my problems begin, firstly my python code doesn't seem to be working, I'm essentially using the method outlined…
kingee
  • 241
  • 1
  • 7
5
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
  • 17,908
  • 4
  • 28
  • 80
5
votes
3 answers

Number of ways to place $n$ rooks on $n$ by $n$ board such that they don't hit each other. But someone has cut out squares of one of diagonals.

I was thinking about asking this is chat because I thought that my concern is not serious enough, but it became too long so here I am. I hope that the question is clear: you just can't place rooks on squares with coordinates $(1, 1), 2, 2)$ and so…
1
2 3
59 60