I am trying to teach myself Chudnovsky’s algorithm using Python and this wikipedia page: https://en.wikipedia.org/wiki/Chudnovsky_algorithm On the wiki, I am focused on the “high performance iterative implementation, [that] can be simplified to”: I tried to code up the equation on the far right that is using the Sigma symbol. I am familiar with Python but am not that great at
Tag: math
The sum of the products of a two-dimensional array python
I have 2 arrays of a million elements (created from an image with the brightness of each pixel) I need to get a number that is the sum of the products of the array elements of the same name. That is, A(1,1) * B(1,1) + A(1,2) * B(1,2)… In the loop, python takes the value of the last variable from
math domain error doesnt add up using various trig functions with variable
so I am new to python, im using it for a couple classes, I am making programs to run calculations. here I have my code for 3 dimensional vectors, I ran into an issue however when I input a vector with Fx=0 Fy=-6 and Fz=8, it gave me a math domain error when computing the variable s. I tried the
How to print a standard circle in the console window?
I am trying to print an arbitrary math function through a callback function, the execute() function will iterate over all integer coordinates (x,y), if the callback returns true then canvas[x][y] = ‘*’. But my implementation only works when printing straight lines, always fails to print hollow circles The following two pictures are the printed x shape and the wrong ring
SymPy lambdify gives wrong result, while *.subs gives the accruate one
Sorry for bothering you with this. I have a serious issue and now im on clock to solve it, so here is my question. I have an issue where I lambdify a quantity, but the result of the quantity differs from the “.subs” result, and sometimes it’s way off, or it’s a NaN, where in reality there is a real
How do I distribute a value between numbers in a list
I am creating a bias dice rolling simulator I want the user to: 1.Input the number they would like to change the prob of 2.Input the prob (in decimal form) Then I would like my program to distribute the remainder between the other values, this is my first post – let me know if any other info is needed My
what does cardinality mean in relation to an image dataset?
After successfully creating a tensorflow image Dataset with: dataset = tf.keras.utils.image_dataset_from_directory(…) which returns Found 21397 files belonging to 5 classes. Using 17118 files for training. There is the cardinality method: dataset.cardinality() which returns a tensor containing the single value tf.Tensor(535, shape=(), dtype=int64) I’ve read the docs here but I don’t understand what 535 represents or why its different to the
Python: Not being able to compare radians with pi values
I am writing an algorithm which should be able to determine in which quadrant a radian is based on two values that the user inputs. I think that the code is calculating the radian but I know that those values are not being compared to the pi values that I gave since I am not getting any output. Code below:
How can I solve this arithmetic puzzle? My solution is too slow after n = 14
Given numbers 1 to 3n, construct n equations of the form a + b = c or a x b = c such that each number is used exactly once. For example: The question is, does a solution exist for every n? I tried writing a basic program and it becomes too slow after n = 14. Here are the
Calculate distance between points in polygon
I found a lot of posts on how to calculate distance between two points or from one point to polygon but I simply can’t find how to calculate distance of each edge. I have a polygon, where the coordinates are these: I simply want to calculate length of each edge. Maybe I should use (math.dist(p, q)) with for loop or