Skip to content
Advertisement

Tag: math

Trying to accurately get 100 digits of pi with Chudnovsky’s algorithm in PYTHON

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

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

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

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

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

Advertisement