Tag Info

New answers tagged

0

Here's another way that's quite a bit faster on David Stork's example: #.Y.# &[A.X] SeedRandom[0]; A = Table[RandomReal[], {3000}]; X = Table[RandomReal[], {3000}, {8000}]; Y = Table[RandomReal[], {8000}, {8000}]; AbsoluteTiming[A.X.Y.X\[Transpose].A] AbsoluteTiming[(A.X).Y.(X\[Transpose].A)] AbsoluteTiming[A.(X.Y).(X\[Transpose].A)] ...


5

Since your central question was about speed (or time complexity), you might wish to know an important result from elementary theory of algorithms and computational complexity, which is that the time and space complexity of matrix multiplication depends upon the order of such multiplication (see Introduction to Algorithms by Cormen, Leiserson and Rivest). As ...


4

In Einstein notation your initial expression is $$A_{i}A_{j}X_{ik}X_{jl}Y_{kl}\\=A_iX_{ik}Y_{kl}X^\mathsf{T}_{lj}A_j\\=AXYX^\mathsf{T}A$$ which can be easily entered into Mathematica as A.X.Y.X\[Transpose].A It's unlikely you'll be able to devise anything faster than this, but this should be very fast. On my machine, this executes in 0.062 seconds for ...


2

f[x_] = Sqrt[1 + x]; The fixed point is the golden ratio, independent of the starting value (x /. Solve[x == f[x], x][[1]]) == GoldenRatio True GoldenRatio == f[GoldenRatio] // FullSimplify True FixedPoint[f, {.01, .1, 1., 1.1, 10.}] // Union {1.61803} %[[1]] // RootApproximant 1/2 (1 + Sqrt[5]) % == GoldenRatio True


0

Nest is probably what you need. Nest[f, x, 40] Also worth reading the docs for Fold and FixedPoint


1

Let us define: form1 = {10000, 10004} -> {2, 2, 637}; f[x_] := x -> form1[[2]]; Then the second form is f /@ f1[[1]] (* {10000 -> {2, 2, 637}, 10004 -> {2, 2, 637}} *) Have fun!


6

There is the third argument for Thread: Thread[ {10000, 10004} -> {2, 2, 637}, List, 1] {10000 -> {2, 2, 637}, 10004 -> {2, 2, 637}}


3

l = {10000, 10004} -> {2, 2, 637}; # -> l[[2]] & /@ l[[1]] (* {10000 -> {2, 2, 637}, 10004 -> {2, 2, 637}} *)



Top 50 recent answers are included