linear algebra – How to prove if two matrices are similar without explicitly finding the basis matrix?

My understanding is that two matrices A and B are similar if and only if there exists some other matrix M such that A = MBM-1.

Is there a way to prove that two matrices are similar without knowing exactly what the basis matrix is? Because obviously if we did, then the “proof” would be a trivial one.

Finding initial conditions for DAE system of equations

I have the following DAE system of equations

(Rho)0 = 1;
M = 1;
eq1 = D(m(t, r), r) - 4 Pi (Rho)(t, r) R(t, r)^2 D(R(t, r), r);
eq2 = D(m(t, r), t) + (4 Pi)/3 (Rho)(t, r) R(t, r)^2 D(R(t, r), t);
eq3 = D(R(t, r), r, t) - D(R(t, r), t) D((Nu)(t, r), r) - 
   D(R(t, r), r) D((Lambda)(t, r), t);
eq4 = D((Rho)(t, r), r) + 1/4 (Rho)(t, r) D((Nu)(t, r), r);
eq5 = Exp(-2 (Nu)(t, r)) (D(R(t, r), {t, 2}) - 
      D((Nu)(t, r), t) D(R(t, r), t)) - 
   Exp(-2 (Lambda)(t, r)) D((Nu)(t, r), r) D(R(t, r), r) + m(t, r)/
   R(t, r)^2 + (4 Pi)/3 (Rho)(t, r) R(t, r);

I have some problem finding initial conditions that produce solutions: how can I vary the initial conditions to see when the system has solutions? Currently I am just trying different random values, but it is obviously not the best method. I use NDSolveValue as follows:

NDSolveValue({eq1 == 0, eq2 == 0, eq3 == 0, eq4 == 0, 
  eq5 == 0, (Rho)(0, r) == (Rho)0, (Rho)(t, 0) == (Rho)0, 
  m(0, r) == M, 
  m(t, 0) == 
   M, (Nu)(0, r) == -(1/4) Log((Rho)0), (Nu)(t, 
    0) == -(1/4) Log((Rho)0), (Lambda)(0, r) == 
   0, (Lambda)(t, 0) == 0, R(0, r) == ((3 M)/(4 Pi (Rho)0))^(1/3), 
  R(t, 0) == ((3 M)/(4 Pi (Rho)0))^(1/3), 
  Derivative(1, 0)(R)(0, r) == 1}, {(Rho), R, 
  m, (Nu), (Lambda)}, {t, 0, 1}, {r, 0, 1})

mathematics – finding the angle of rotation of a 3d line

I have a line segment joining two 3D points AB, and a vector V which is normal to it.

I need to know the angle of AB in the plane described with V as the plane normal, that is: in the plane of the two vectors (AB) and (AB cross-product V)

In searching I’ve come across both Rogrigues’ Rotation Formula and this answer about rotating planes, but I haven’t been able to work out how to apply either of them to this particular problem (I do feel like I’m missing a really obvious trick!)

Edit: My first idea is to rotate A and B so that V is aligned with the cartesian X axis and (ABxV) is aligned with Y, then use atan2(dy, dz). I have just started to look for a working solution to performing that rotation.

Bad drawing of the geometry

An alternative description of the geometry is that I have a cylinder with its long axis aligned with V, and the points A,B are opposite sides of the end-cap circumference… and I need to know the rotation of the cylinder around its long axis described by AB (relative to any arbitrary consistent 0 angle).

UPDATE: In case it breaks assumptions, my values are all measurements from a live camera, so the ‘normal’ vector V may not be exactly normal to AB… it should always be pretty close though (within a few degrees).

Finding the ≡A equivalence classes of L={0^n1^n|n belongs to N}

I am told to find the equivalence classes of 0^n1^n as asked above. For one, I know it has an infinite number of equivalence classes given it’s a non-regular language. Im not sure how to find all the equivalence classes and show how I got those equivalence classes.

algorithms – Finding all integer points on a hypersurface

Given a function $f$ of $n$ variables, is there a reasonable way to generate all integer points on the hypersurface given by $f(x)=0$?

To be more specific, let us assume that $f$ is a polynomial with integer coefficients and $S={xinmathbb{R}^nmid f(x)=0}$ is bounded. If one knows a bound for the elements of $S$, say, if $Ssubset (a,b)^n$ for some $a,binmathbb{Z}$, one can simply iterate over all points $xin (a,b)^n$ and check whether $f(x)=0$. This approach is insanely inefficient.

One way to reduce the number of operations is to iterate over $(x_1,ldots,x_{n-1})in(a,b)^{n-1}$ and solve for $x_n$ (numerically and then checking for the nearest integers or by means of the rational root theorem).

One could imagine that there is a way to “move along a hypersurface”, that is, only look at the points that are close to $S$. If one has a point $x$ which is close to $S$, it is likely that a point $y$ next to $x$ is close to $S$ as well. So one can move to such a point $y$ and repeat. But not if $y$ gets too far from $S$ (this can be judged by the value $f(y)$, and the gradient of $f$ at $y$ must be taken into account). This, however, requires storing all the integer points already visited, so might take quite a lot of memory (which I would like to avoid). I think this is not trivial even for a plane curve. It there a known way to minimize the number of points visited? In a sense, this look quite similar to the problem of enclosing $S$ inside an “integral envelope”, a minimal integral polyhedron which contains $S$ (possibly non-convex and not simply-connected).

To narrow this down even further, let us assume that $f$ is qudratic, so $S$ is an ellipsoid. I would guess that this particular case is much easier and has been studied before. Any references?

More generally, one can consider unbounded hypersurfaces. Then the problem of visiting all integer points should be reformulated as the problem of walking along the hypersurface and eventually visiting eash integer point (instead of, say, getting stuck on a subvariety).

Las Vegas algorithm for finding 00000 in bit string

Problem 1: Consider the following problem: given a binary string $w=a_1a_2cdots a_n in{0,1}^*$, decide whether $w$ contains 00000 as a substring (i.e., where $w$ contains five consecutive 0’s). There is an obvious $O(n)$-time algorithm. You will investigate the hidden constant factor, concerning the number of bits that need to be examined (i.e., the number of $a_i$‘s that need to be evaluated) to solve this problem.

  1. (10/100 points) First argue that every deterministic algorithm solving this problem needs to evaluate $Omega(n)$ bits in the worst case.
  2. (30/100 points) Prove that for a sufficiently large constant $c$, for any string $a_1 cdots a_c$ of length $c$ that does not contain 00000, there must exist two indices $i,j in {1,ldots,c}$ with $a_i=a_j=1$ and $2 leq |i-j| leq 5$.
  3. (60/100 points) Design a Las Vegas randomized algorithm solving this problem (with zero error probability) that evaluates an expected $alpha n + o(n)$ number of bits for any input, for some constant $alpha$ strictly smaller than $1$. (You do not need to optimize the constant $alpha$.)

Above is a question some friends and I have looked at to prepare for a qualifying exam and is itself from a past qualifying exam. Parts 1 and 2 are fine but what we are having troubles with is part 3. I think the idea behind this problem is to imagine that evaluating some bit $s_i$ is really expensive, so we would like to get the right answer while minimizing how many of these bits we evaluate. That said, there is some ambiguity to us about whether we (1) care about the number of distinct bits we evaluate or (2) the total number of times we evaluate any bit. Clearly if we were worried about the latter, we could just store the result of the bit evaluation and avoid doing an expensive evaluation again, but we are not sure. For now, I assume the latter case and specifically that if we want the value for the same bit twice, we assume we need to evaluate it each time and incur $2$ units to the cost we are trying to minimize.


Now I have some idea for this problem and to help explain my idea, let us consider a simple deterministic algorithm with the pseudocode written below. We will loop from the start of the string to the end, checking all meaningful 5 bit substrings. If we ever find a $1$ bit as we loop over a 5 bit substring, we know that substring cannot be $00000$ but if we start at the bit right after that $1$ bit, there might be one. Thus, we update our new starting point to the position right after that $1$ bit and then start back up again from there.

On input $s$:

  1. set $i leftarrow 1$
  2. while($i leq (n-4)$):
    • set $b leftarrow text{true}$
    • for($j = 0$ to $4$):
      • if( $a_{i+j} = 1$ ):
        • $i leftarrow (i+j+1)$
        • $b leftarrow text{false}$
        • break for loop.
    • if( $b = text{true}$ ):
  3. return FALSE

My idea for a Las Vegas algorithm was to do the same algorithm but slightly modify it by making the inner loop performed in random order, making the pseudocode now be

On input $s$:

  1. set $i leftarrow 1$
  2. while($i leq (n-4)$):
    • set $b leftarrow text{true}$
    • for($j = 0$ to $4$ in random order):
      • if( $a_{i+j} = 1$ ):
        • $i leftarrow (i+j+1)$
        • $b leftarrow text{false}$
        • break for loop.
    • if( $b = text{true}$ ):
  3. return FALSE

The positive thing going for this algorithm is that if there exists a $1$ bit in the 5 bit substring we are looking at in the inner loop, we will find it in at most $3$ loop iterations in expectation. However, if I define a bit string $s$ to be
$$s = 100001 100001 100001 cdots 100001$$
then the algorithm should require looking at $6$ bits (potentially some of the same ones multiple times) in expectation to get past each $100001$ substring. This implies on this input we will go to see the value of $n$ bits (the number of distinct bits seen may be less) in expectation before we answer the question of if $00000$ is contained in $s$. Thus, this algorithm does not seem sufficient.

Does anyone have any thoughts on how to approach this problem or think we should actually be worried about the number of distinct bits we evaluate? If yes to the latter, then I could potentially see other ways to tackle this problem.

code – Help with subscripts. Attempting to compute Salamin and brent equation for finding pi

You can implement recursions almost in the same way you have specified them:

Clear(a, b, c, s, p);
a(0) = 1.; b(0) = 1/Sqrt(2); c(0) = 1/2; s(0) = c(0);
a(k_) := a(k) = (a(k - 1) + b(k - 1))/2;
b(k_) := b(k) = Sqrt(a(k - 1) b(k - 1));
c(k_) := c(k) = a(k)^2 - b(k)^2;
s(k_) := s(k) = s(k - 1) - 2^k c(k);
p(k_) := p(k) = 2 a(k)^2/s(k);

The first 10 terms:

p(#) & /@ Range(10)

{3.18767, 3.14168, 3.14159, 3.14159, 3.14159, 3.14159, 3.14159, 3.14159, 3.14159, 3.14159}

It seems to converge very quickly! If you want to retain exact expressions (instead of machine precision), use a(0)=1 (instead of a(0)=1.).

Python clr not finding a dll

I’m trying to include a DLL into my python project but I’m having a terrible time.

I was following this thread:
Accessing CPU temperature in python
But I can’t get the thing to import the file.
I’m getting:
Unable to import ‘OpenHardwareMonitor’pylint(import-error)

I also placed the DLL into System32 folder and tried including it without the path with no luck.
Any ideas?

Folder:
OpenHardwareMonitorLib.dll
Test.py

import clr #package pythonnet, not clr
import os
openhardwaremonitor_hwtypes = ('Mainboard','SuperIO','CPU','RAM','GpuNvidia','GpuAti','TBalancer','Heatmaster','HDD')


dir_path = os.path.dirname(os.path.realpath(__file__))

print ("Path:")
print (dir_path)
print ()

file = dir_path + "OpenHardwareMonitorLib.dll"

clr.AddReference(file)
from OpenHardwareMonitor import Hardware

mining theory – Process for finding nonce

Assume we have a transaction in hex (tx_hex) and we want to find a nonce such that

SHA-256(SHA-256(nonce|| tx_hex)) = new_transaction_id (‘||’ denotes concatenation)

first bits consist of 32 zeros. I understand that this nonce can be found only by brute force.

However, I cannot figure out how you check this condition in practice. new_transaction_id is in hex, so is that equivalent to checking that its first 8 digits are 0?

And if so to find the nonce, I just have to try every possible number (let’s say up to 32 bits) for the first 8 digits of new_transaction_id to be 0?

That is my code BTW

def mine(self, tx_hex):
    for i in range(1,4294967295):
        nonce = hex(i)(2:)
        new_tx = self.add_nonce(nonce, tx_hex)
        sha = self.get_tx_id(new_tx)
        print(sha(:2))
        if sha(:8) == '00000000':
            print('Nonce:', i)
            break

Adsense Reporting – Finding Earning not Attributed to an Ad Unit

I’ve been a publisher using Adsense since 2006.

Up until sometime in 2020, I was pretty good with having all ad placements allocated to (or “tied to”) Ad Units.

Recently though, as much as half of my actual earnings don’t show up in the Ad Units report. e.g. If my overall earnings on a given day was $60, only $30 of that shows up in the Ad Units report.

Clearly I must have an ad (or multiple ads) running that don’t have an Ad Unit?

How would I go about troubleshooting that?

It’s all on the same site/domain so hopefully it won’t be too hard to track down.