Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 4405

A general purpose high-level programming language that emphasizes ease of code syntax and readability.

8 votes
Accepted

Python: Underflow vs. exp of large negative numbers

If your final result is of the order of magnitude of exp(-1000) $\approx 5 \cdot 10^{-435}$, then you are out of luck; no matter how you compute it, it will always underflow. There is simply no repres …
Federico Poloni's user avatar
3 votes

Is there something unique you can get out of a set of numbers?

This can be done optimally, mapping bijectively each combination of $k$ numbers among $n$ into a distinct integer in $\{1,...,N\}$, with $N = \binom{n}{k}$ is as small as possible. This problem is kno …
Federico Poloni's user avatar
5 votes
Accepted

How can I solve my equation with the best numerical precision?

When implementing this is there some care I have to take besides checking that the denominator is not zero in order to achieve the best numerical results? No. The naive algorithm (compute the numera …
Federico Poloni's user avatar
2 votes

LCM builtin in Python / Numpy

, and it looks very fast: sage: %timeit lcm(range(1,1000)) 100 loops, best of 3: 820 µs per loop If you are doing number theoretical computations, I'd recommend you to move to Sage instead of pure Python
Federico Poloni's user avatar
3 votes

Solving a system of quadratic equations in Python

Why don't you use regular Newton? Your system is simple enough that you can find its closed-form Jacobian and write your own Newton solver. If you just need one solution which is close to a given star …
Federico Poloni's user avatar
3 votes
Accepted

Whitening transformation does NOT return a unit covariance matrix

As the comments notice, you may have some confusion in your head between covariance and sample covariance. However, that's not what causes your error. First of all, forget about getting the covarianc …
Federico Poloni's user avatar
4 votes

Float equality tolerance for single and half precision

Those proposed tolerances look fine, but in my (opinionated) view this is really a problem with no satisfying solution, as the comments also argue. For most algorithms, the error bounds one gets look …
Federico Poloni's user avatar
8 votes
Accepted

Composite matrices in Numpy

They are commonly called block matrices. You can create them with hstack, vstack, and block.
Federico Poloni's user avatar
1 vote
Accepted

Auto differentiation with JAX in python and ForwardDiff.jl in Julia give matrices with diffe...

Are you sure the implementations of the function that you wish to differentiate return the same results both in Julia and Python? That seems the first place to look for bugs. …
Federico Poloni's user avatar
9 votes
Accepted

Poor SVD reconstruction of singular matrix

Algorithms for the SVD, as more or less every classical linear algebra algorithm based on orthogonal transformations, are normwise backward stable, i.e., it should be guaranteed that $\frac{\|USV^* - …
Federico Poloni's user avatar
2 votes
Accepted

Numpys `tensordot` and what is happening mathematically

If you are familiar with einsum, maybe this explanation does it: axes[0] and axes[1] specify the locations of the repeated letters in the parameters of einsum. For instance, np.tensordot(a, b, axes= …
Federico Poloni's user avatar
2 votes

Solve for large array of PD matrices

This will get technical, though: you will need to call Lapack functions by hand, I am afraid (*potrf and *potrs), since Python doesn't help you here, so to use the exact same algorithm you may want to …
Federico Poloni's user avatar
5 votes
0 answers
1k views

Symmetric sparse direct solvers in scipy

scipy.linalg.solve, in its newer versions, has a parameter assume_a that can be used to specify that the matrix $A$ is symmetric or positive definite; in these cases, LDL or Cholesky are used rather t …
Federico Poloni's user avatar
5 votes

Numerically stable and fast sum of last K elements in sequence

(in Python notation). There are orthogonal transformations thrown in between these sums that make it difficult to use different strategies. …
Federico Poloni's user avatar
3 votes
Accepted

Implementation of $[X, \cdot]$ as an $n^2 \times n^2$ matrix, where $X$ is an $n \times n$ m...

output[i*n + j][k*n + l] = com[k][l] That's your mistake I think -- reversed indices. To compute the matrix $M$ associated to a linear operator $f$ (the way it's usually taught in a linear algebra c …
Federico Poloni's user avatar

15 30 50 per page