New answers tagged

1

It is unclear from your question what you really want to compute. This is my guess. I will start by showing a function,counter, that performs the counting you ask for one $n \times n$ matrix. I will then generate a base matrix, say m, consisting of zeros and ones and use it to make a list of the unitized powers of m as you describe in your question to use as ...


2

Alternative solution: vc[m_] := {#, Times@@Dimensions[m]-#}&[Count[Unitize[c] + Transpose[Unitize[c]], 2, 2]]; Generate a random matrix: SeedRandom[17]; c2 = RandomChoice[{1,9}->{1,0}, {150, 150}]; {v, c} = Sum[vc[MatrixPower[c2, n]], {n, 2, 20}] {418711, 8789} To explain what's going on here, since Unitize will convert the matrix to entirely 0s ...


2

You don't need to define any functions. You just need to write a While-loop. It is tempting to write the While-loop to use system floating-point arithmetic for speed, like so: With[{ϵ = 10.^-16}, Block[{x = 1., nxt}, While[True, nxt = Cos[x]; If[Abs[nxt - x] < ϵ, Break[], x = nxt]]; nxt]] But this doesn't work because system ...


Top 50 recent answers are included