Tag Info

Hot answers tagged

5

u[[1, All, 2]] (* {678, 678, 678, 678, 678, 678, 678, 678, 678, 678} *) u[[2, All, 2]] (* {1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888} *)


5

I hope you will realize very soon that Mathematica is not Excel. If you begin learning the basics by mimicking how you would do it in Excel, you are off to a very bad start. Let us try to do it more in Mathematica style. First, we make a list of your elements elms = {"Gold", "Silver", "Copper"} Now, we make a function which takes an arbitrary element ...


4

Let's assume you take a credit of 10000 with monthly repayments of 100. Interest of 7% p.a. is computed monthly on the remaining balance: Rest @ NestList[# + #*0.07/12 - 100 &, 10000, 13] {9958.33, 9916.42, 9874.27, 9831.87, 9789.22, 9746.33, 9703.18, 9659.78, 9616.13, 9572.22, 9528.06, 9483.64, 9438.96} The above figures are the month end ...


3

Export["matrix.csv", m[[All, All, 1, 1, 2]]] should do the trick.


3

As Sjoerd commented I believe these kinds problems can be solved using TimeValue and Annuity, as detailed in the documentation. For example if you have a monthly payment of \$304.22 on a 36 month \$10,000 loan you can calculate your interest rate as: FindRoot[TimeValue[Annuity[304.22, 36], i/12] == 10000, {i, 0.1}] {i -> 0.0600014} (* 6% yearly ...


2

I suppose you have something like this: expr = Table[{{1/u, u^2}, {Sqrt[u], 1/Sin[u]}}, {u, 0, 2 Pi, Pi/4}] {{{ComplexInfinity, 0}, {0, ComplexInfinity}}, {{4/π, π^2/16}, {Sqrt[π]/2, Sqrt[2]}}, {{2/π, π^2/4}, {Sqrt[π/2], 1}}, {{4/(3 π), (9 π^2)/ 16}, {Sqrt[3 π]/2, Sqrt[2]}}, {{1/π, π^2}, {Sqrt[π], ComplexInfinity}}, {{4/(5 π), (25 π^2)/16}, ...


2

Since v9 (if I recall) you can use MapAt with Span for such things: sample = {{"Sample", "Data", "creationdate", "othervariable"}, {2.3, 4.3, "20141008125809", 8.4}, {3.2, 1.3, "20141008125809", 9.2}, {3.2, 1.3, "20141008125809", 11.84}}; MapAt[fixDate, sample, {2 ;;, 3}] {{"Sample", "Data", "creationdate", "othervariable"}, {2.3, 4.3, ...


2

The easiest way to do what you want is to use the built-in function Binomial. Then all you need to write is cb[n_] := Binomial[2 n, n] a = Table[{n, N @ Log[cb[n]]}, {n, 25}]; TableForm[a] Note I used 25 in place of 250 to reduce the size of the output I show on this site to something reasonable. Plotting is trivial. ListPlot[a]


2

Another mm-ish way to approach this is to memoize the function (note the ":=: and "="): MyHugeMessyLongFn[a_]:=MyHugeMessyLongFn[a]=(someTimeConsumingStuff); and then do as you suggested: Table[{i, MyHugeMessyLongFn[i][[1]], MyHugeMessyLongFn[i][[2]]}, {i, 5}] Your function will be called twice, but the second time it will just remember its value from ...


2

Aside from the myriad of ways of better vectorising your task, what you are probably looking for is With. For example, With[{s = MyHugeMessyLongFn[i]}, {s, 2s, First @ s}] This can be used anywhere, including within a Table. It is just a scoped assignment to the variable s. You could have an unscoped version too: (s = MyHugeMessyLongFn[i]; {s, 2s, ...


2

You just need to Flatten each row in the Table result to get the form you are looking for. Use the same kind of expression that you are using for MySimpleFn but flatten the rows. Table[{i, MyHugeMessyLongFn[i]} // Flatten, {i, 5}]


2

You can also use the built-in function Quantile without having to use Solve or FindRoot. m2 = Table[Quantile[StudentTDistribution[0, 1, df], (100 + Vertrauensintervall)/ 200.], {df, 3, 30, 1}, {Vertrauensintervall, {80, 90, 95, 98, 99, 99.73}}]; The result is identical to the one you get using the method suggested by @Sjoerd (to the deafult ...


2

Your table can be generated much easier and considerably faster using c = CDF[StudentTDistribution[0, 1, df], a] - CDF[StudentTDistribution[0, 1, df], -a] // FullSimplify m = Table[ a /. FindRoot[c == Vertrauensintervall/100., {a, 0.1}], {df, 3, 30, 1}, {Vertrauensintervall, {80, 90, 95, 98, 99, 99.73}} ]; This exports to a ...


1

This question really amounts to: how can one manipulate lists in Mathematica? The most popular tag is in fact list-manipulation so there are a myriad of examples available to you. Other than memoization as proposed by A.G. all methods rely on calling the function only once, then doing something with the expression that is returned. You can manipulate each ...


1

This is more Mathematica-ish: MyHugeMessyLongFn[x_] := {2 x, 3 x} myList = {#, MyHugeMessyLongFn@#} & /@ Range@5 (* {{1, {2, 3}}, {2, {4, 6}}, {3, {6, 9}}, {4, {8, 12}}, {5, {10, 15}}} *)


1

mat = {{{1, 678}, {1, 678}, {1, 678}, {1, 678}}, {{2, 1888}, {2, 1888}, {2, 1888}, {2, 1888}}}; res = Rule @@@ Catenate @ mat // Merge[Identity] res[2]


1

If efficiency is important and you are going to generate more and more elements of your series then you might consider using RSolve to find an expression for all terms. RSolve[{s[t + 1] == s[t]^2, s[0] == Sqrt[2]}, s[t], t] and RSolve[{s[t + 1] == (1 + t)*s[t]^2, s[0] == Sqrt[2]}, s[t], t]


1

I don't think you need iterations to accomplish what you are looking for. For example: s[0]=Sqrt[2]; s[t_] := s[t] = s[t - 1]^2 (* Use memoization *) Map[s, Range[1,5] ] (* {2, 4, 16, 256, 65536} *) and in the second case: ss[0] = Sqrt[2]; ss[t_] := ss[t] = t ss[t - 1]^2 Map[ss, Range[1,5] ] (* {2, 8, 192, 147456, 108716359680} *)


1

Perhaps Table[{j, ElementData[j, "SpecificHeat"]}, {j, {"Gold", "Silver", "Copper"}}] // TableForm or tableF = {#, ElementData[#, "SpecificHeat"]} &; tableF /@ {"Gold", "Silver", "Copper"} // TableForm (* same output *) or (* initialize a 3 by 2 table: *) table = ConstantArray[0, {3, 2}]; (* set the first column to the three element names: *) ...


1

I think the problem is in defining Fibonacci series. The following T = Table[Fibonacci[n], {n, 0, 50}]; Log[T] //N gives {-Infinity, 0., 0., 0.693147, 1.09861, ..., 23.2559}


1

This seems to me to be a situation where MapIndexed can usefully be applied. Given pts2 as generated in the question, first get rid of the unwanted last element. pts = Take[#, width] & /@ pts2; Then either of the following tbl = Join @@@ MapIndexed[With[{j = -#2[[2]]}, {{#1, j + 1}, {#1, j}}] &, pts, {2}]; tbl = ReleaseHold @ ...



Only top voted, non community-wiki answers of a minimum length are eligible