I have a code that goes like this:
ClearAll["Global`*"] const1 = 2.; \[Kappa] = 23; tbl = Table[{x, N[x^(1/2)], 0 x, N[x^(1/3)], 0 x, N[x^(1/4)], 0 x, N[x^(1/5)], 0 x}, {x, 2, 20, 2}]; SetDirectory[NotebookDirectory[]]; newrow[{a_, b_, c_, d_, e_, f_, g_, h_, i_}] := {a, b, c, ( Sqrt[\[Pi]]*b* const1 Exp[-(b^2/(2 Sqrt[a]))])/(const1 \[Kappa]^5), d, e, (Sqrt[\[Pi]]*d *onst1 Exp[-(d^2/(2 Sqrt[a]))])/( const1 \[Kappa]^5), f, g, ( Sqrt[\[Pi]]*f *const1 Exp[-(f^2/(2 Sqrt[a]))])/(const1 \[Kappa]^5), h, i, (Sqrt[\[Pi]]*h *const1 Exp[-(h^2/(2 Sqrt[a]))])/( const1 \[Kappa]^5)}; newtbl = Map[newrow, tbl]; headings = {"x", "real1", "imag1", "col1manipulated", "real2", "imag2", "col2manipulated", "real3", "imag3", "col3manipulated", "real4", "imag4", "col4manipulated"}; Export["file1.dat", Join[{headings}, newtbl]]; Once the table, tbl, is created, I am taking the data from each column and use it to do some arithmetic operation.
- Now, as you can see, I have a term $\frac{\sqrt{\pi}*b*const1*e^{\frac{-b^2}{2\sqrt{a}}}}{const1*κ^5 }$ which repeats multiple time but with only one factor changing, namely, b or d or f or h. If I am writing individual terms all the times, the code becomes messy. Is there any way to simply it? E.g. define something like $\frac{\sqrt{\pi}*i*const1*e^{\frac{-i^2}{2\sqrt{a}}}}{const1*κ^5 }$ outside and call it inside every time?
- In the code which gives me heading, I have to write "real1","imag1","col1manipulated" and then "real2","imag2","col2manipulated" so on. Is there any way to simplify this? Like to make "real1","imag1","col1manipulated" till "real5","imag5","col5manipulated" by some command and then append it?
Thanks in advance.