Tag Info

New answers tagged

2

ClearAll[f]; f = Transpose@Table[i {##2}/#^{##2} , {i, 1, #}] &; f[3, x] (*{{3^-x x,2 3^-x x,3^(1-x) x}} *) f[3, x, y, z] (* {{3^-x x,2 3^-x x,3^(1-x) x}, {3^-y y,2 3^-y y,3^(1-y) y}, {3^-z z,2 3^-z z,3^(1-z) z}} *)


2

You have several issues here. My oldest Mathematica here is version 8, but when I look at your compiled code: cf = Compile[{{x, _Integer}, {n, _Integer}}, z = (n^x); Binomial[n, #]*StirlingS2[x, #]*(#!)/z & /@ Range[x]]; << CompiledFunctionTools` CompilePrint[cf] I see that there are several callbacks from the compiled code to the ...


2

If your n is a very big integer and your x and y are real values, and you need realy high speed, than you should try Compile: cf = Compile[{{x, _Real, 0}, {n, _Integer, 1}}, n*x/Length[n]^x, RuntimeAttributes -> {Listable}, Parallelization -> True, CompilationTarget -> "C" ] f[n_, x_, y_] := {cf[x, Range[n]], cf[y, Range[n]]} For ...


1

perhaps something like this: function[n_, x_, y_] := ({table1, table2} = Table[i {x/n^x, y/n^y}, {i, n}] // Transpose;) But note your example does not need Table at all: function[n_, x_, y_] := ({table1, table2} = {x/n^x, y/n^y} # & /@ Range[n] // Transpose;) Of course assigning to global variables inside a ...



Top 50 recent answers are included