Tag Info

New answers tagged

6

In Version 10, we can use Inactivate and Activate to achieve this easily: With[{rl = Array[{m -> #} &, 5], s = Inactivate[Sum[i^m, {i, 1, n}], Sum]}, Thread[Equal[s /. rl, Factor[Activate[s] /. rl]]]] // Column // TeXForm \begin{array}{l} \underset{i=1}{\overset{n}{\sum }}i=\frac{1}{2} n (n+1) \\ \underset{i=1}{\overset{n}{\sum ...


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

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 ...


0

row = {1, -1, 1, 2, -1, 1, -1, 1, 2, 3, -1, -2, 1, -1, 1, -1, -2, -3, 4}; chanceRow = Round[#/Length@#, 0.01] &[Count[row, #] & /@ row] {0.32, 0.32, 0.32, 0.11, 0.32, 0.32, 0.32, 0.32, 0.11, 0.05, 0.32, \ 0.11, 0.32, 0.32, 0.32, 0.32, 0.11, 0.05, 0.05} And this finds the length of a sequence increase or decrease in a row (using your ...


0

Perhaps tab = {{2, 5}, {5, 7}}; tab2 = List /@ # & /@ tab (* or tab2 = Map[List,tab,{-1}] *) (* {{{2},{5}},{{5},{7}}} *) Export["fileA.xls", tab2]


1

Correct it to be: Export["file.xls",{{2,5},{5,7}}] or more explicitly Export["file.xls",{{2,5},{5,7}},"XLS"] "Table" is a generic Table-Format, suitable for a simple Text-Editor, not specially dedicated to Excel When you leave away the 3rd argument, then the default value is "XLS", and Excel will import it without additional Import-Dialog.


0

Fixing the OP's original function :- data = {{0.349661, 0.380297}, {0.858156, 0.8442}, {0.906745, 0.171579}, {0.0847783, 0.277227}, {0.198453, 0.40206}, {0.941614, 0.347187}}; judge = {{0.0423892, 0.141616}, {0.141616, 0.274057}, {0.274057, 0.603909}, {0.603909, 0.882451}, {0.882451, 0.924179}, {0.924179, 0.959049}}; Which @@ Flatten@ ...


0

For more variety, using a rule replacement data = {{0.349661, 0.380297}, {0.858156, 0.8442}, {0.906745, 0.171579}, {0.0847783, 0.277227}, {0.198453, 0.40206}, {0.941614, 0.347187}}; range = {{0.0423892, 0.141616}, {0.141616, 0.274057}, {0.274057, 0.603909}, {0.603909, 0.882451}, {0.882451, 0.924179}, {0.924179, 0.959049}}; data[[All, 1]] ...


1

indexF = Function[{x}, Piecewise[MapIndexed[{First@#2, #[[1]] <= x <= #[[2]]} &, #]]]&; h = MapAt[indexF[#2], #1, {All, 1}] &; data = {{0.349661, 0.380297}, {0.858156, 0.8442}, {0.906745, 0.171579}, {0.0847783, .277227}, {0.198453, 0.40206}, {0.941614, 0.347187}}; ints = {{0.0423892, 0.141616}, {0.141616, 0.274057}, {0.274057, ...


0

Just for variety: data = {{0.349661, 0.380297}, {0.858156, 0.8442}, {0.906745, 0.171579}, {0.0847783, 0.277227}, {0.198453, 0.40206}, {0.941614, 0.347187}}; int = {{0.0423892, 0.141616}, {0.141616, 0.274057}, {0.274057, 0.603909}, {0.603909, 0.882451}, {0.882451, 0.924179}, {0.924179, 0.959049}}; Changing the intervals and sorting ...


4

data = {{0.349661, 0.380297}, {0.858156, 0.8442}, {0.906745, 0.171579}, {0.0847783, .277227}, {0.198453, 0.40206}, {0.941614, 0.347187}}; ints = {{0.0423892, 0.141616}, {0.141616, 0.274057}, {0.274057, 0.603909}, {0.603909, 0.882451}, {0.882451, 0.924179}, {0.924179, 0.959049}}; {IntegerPart@ InverseFunction[Interpolation[ints[[All, 1]], ...


4

If I'm interpreting your question correctly... data = {{0.349661, 0.380297}, {0.858156, 0.8442}, {0.906745, 0.171579}, {0.0847783, 0.277227}, {0.198453, 0.40206}, {0.941614, 0.347187}}; intervals = Interval /@ {{0.0423892, 0.141616}, {0.141616, 0.274057}, {0.274057, 0.603909}, {0.603909, 0.882451}, {0.882451, 0.924179}, ...


1

data = {{0.349661, 0.380297}, {0.858156, 0.8442}, {0.906745, 0.171579}, {0.0847783, 0.277227}, {0.198453, 0.40206}, {0.941614, 0.347187}}; data2 = {{0.0423892, 0.141616}, {0.141616, 0.274057}, {0.274057, 0.603909}, {0.603909, 0.882451}, {0.882451, 0.924179}, {0.924179, 0.959049}}; data3 = Range[6] f[{x_, y_}] := Evaluate@Piecewise@Transpose@{{#, ...


2

table = {{10, 2}, {3, 40}}; export = (Transpose@IntegerString@table)[[#]] /. a_String :> Table[" ", {# + 2 - StringLength@a}] <> a & /@ {1, 2} // Transpose; Export["file.dat", export, "Table"]


3

One way would be to do the padding manually: padToWidth[width_, n_] := StringJoin@PadLeft[Characters@ToString[n], width, " "] newData = MapAt[padToWidth[4, #] &, data, {All, 1}]; (* Apply to first column *) newData = MapAt[padToWidth[3, #] &, newData, {All, 2}]; (* Apply to second column *) Export["data.dat", StringJoin[First@#, " ", Last@#] & ...


0

You really have to slow RegionPlot down a lot to see the monitor output. The following is slow enough that you can see the values of x and y change as the plot algorithm builds it mesh. f[x_, y_] := (Pause[.01]; x y) Monitor[RegionPlot[f[x, y] > 20000, {x, 0, 500}, {y, 0, 500}], {x, y}]



Top 50 recent answers are included