# Tag Info

10

A packed arrays (or a MTensor on the C++ side of Mathematica) consists of a linear array containing all entries plus the information needed for storing of the Dimensions of the packed array. That is 1 mreal=double/mint=long long int = 64 bit = 8 byte per entry + a few bytes for storing the array of the Dimension of the packed array (again probably a mint/...

8

Let me explain what went wrong. When you define a function f[pattern] := ... then this will check at every occurrence of f[x] if x matches pattern. Your pattern was x_Real which means "match any expression whose Head is Real". In Mathematica floating point numbers have the Head Real. In[1]:= Head[0] Out[1]= Integer In[2]:= Head[0.] Out[2]= Real ...

5

decompose[ expr_, vars_?(ListQ[#] && Length[#] >= 2 && VectorQ[#, AtomQ] &), dom_ : Reals ] := If[ VectorQ[Keys[#], k \[Function] Length[k] <= 1], {True, Times @@@ Apply[Power, #, {2}]}, (* Else, do some math. True: Decomposable but FactorList failed. @...

5

Okay, I have to admit this is kind of cheating, but, since Mathematica hasn't had an ad hoc function for the frequently-used list equi-division... we can write a shorthand by ourselves? ClearAll[Backslash]; Backslash[ ls_?ListQ /; (Dlen = Length[ls]; True), n_?IntegerQ /; 1 <= n <= Dlen && (Dn = n; True), Optional[nth_?IntegerQ /; 1 &...

5

You need to convert your permutation from a cycles form into a positional form, and note that you need to provide the missing 3, which I've put in a separate cycle because it's unchanged by the permutation: perm = FromCycles[{{1, 4, 2, 5}, {3}}]; ToInversionVector[perm] (* returns: {4, 3, 2, 0} *) Inversions[perm] (* returns: 9 *)

5

Add some Dynamic[] and a variable to keep track of the selected tab: Manipulate[Row[{ Dynamic@TabView[{ 1 -> Pane[Row[{pt[[1]], pt[[2]]}, "\t"], 150], 2 -> Pane[Row[{2*pt[[1]], 2*pt[[2]]}, "\t"], 150], 3 -> Pane[Row[{3*pt[[1]], 3*pt[[2]]}, "\t"], 150] }, Dynamic@i], LocatorPane[Dynamic@pt, ...

4

Generating a differential equation, you can calculate an interpolating function alphasol depending an beta and gamma. Since i use version 8.0, i had to make an unusal construction for NDSolve. With higher versions use ParametricNDSolve with beta as parameter. eq1[α_, β_, γ_] = eq = ((γ + α) - Tan[α])/((γ + α) Sec[α] - Sin[α]) == -β beta[α_] = -eq[[1]] /. ...

4

This is a transcendental equation and in general they don't have analytic solutions. There are special cases, of course, where a "trick" works. But in general no. See https://en.wikipedia.org/wiki/Transcendental_equation for example.

4

Use With. It will inject the pre-calculated value of the larger Subsets expression in your definition, but without “messing up” the readability of your code: ClearAll[inversions] With[ {SUBSETS = Subsets[{1, 2, 3, 8, 4, 7, 6, 5}, {2}]}, inversions[list_] := Complement[SUBSETS,Subsets[list, {2}]] ] You can check that downvalues (i.e. the definition) of ...

4

The problem with your definition of f is x is an expression that uses 2 subscripted symbols θ and ϕ, but f is a function of 4 symbols θ1, ... . Here is a definition of f that works (for n=2) f = x /. {Subscript[θ, 1] -> #1, Subscript[θ, 2] -> #2, Subscript[ϕ, 1] -> #3, Subscript[ϕ, 2] -> #4} &; f[1, 2, 3, 4] This definition of f can ...

3

To summarize insightful comments, Piecewise is the appropriate construct to express the mathematical idea of a piecewise function, as Natas suggested. Condition (i.e. /;) is a programming construct. As Szabolcs mentioned, "it is not meant to represent mathematical ideas; it is meant to implement algorithms". In the following, note also the ...

3

h[t_] := Dot[Through[{f, g}[t]], {2, 4}] h[5.63] (* result: 2 f[5.63] + 4 g[5.63] *) (* or using Function *) y = Function[{t}, Dot[Through[{f, g}[t]], {2, 4}]]; y[9.14] (* result: 2 f[9.14] + 4 g[9.14] *)

3

it1[t_] := ((i01*(Exp[-\[Alpha]*t] - Exp[-\[Beta]*t])))* HeavisideTheta[t] ell = 1; \[Epsilon] = 8.85418781*10^-6 ; d = 10; c = 10^8; \[Beta] = 3; \[Alpha] = 5; i01 = 10^-3; e[t_] := 1/(4*\[Pi]*\[Epsilon])*(Integrate[(2*ell*it1[t]/(d^3)) + (2* ell*it1[t]/(c*(d^2))) + (D[it1[t], t]/(d*(c^2))), t]) Plot[e[t] // Evaluate, {t, 0, 10^-5}, PlotRange -&...

3

The vertical threshold to split the data is found by locating the peak in the reversed data Arev = Reverse /@ Ainput; thresholdVert = Arev[[FindPeaks[Arev[[All, 2]]][[All, 1]]]][[1, 1]] (* 0.58 *) Splitting the data into the upper and lower curves Ainput2 = DeleteDuplicatesBy[#, First] & /@ GatherBy[Ainput, #[[2]] < thresholdVert &]; The ...

3

There is a function in Wolfram Function Repository for making contingency tables: CrossTabulate.

3

0 without the "." is an Integer, see Head @ 0 (* Integer *) but f[0.] delivers 0.

3

I found that there are similar questions in the course of mathematical analysis compiled by 史济怀 of China. I pasted the questions and the reference answers as follows: On page 492 of this book, we can find a brief reference answer: In short, if $u(x,y)$ can be decomposed into the product of two monomials, then the second mixed partial derivative of \$\ln u(x,...

2

As mentioned by flinty, Iw should be I*w; and LogLinearPlot makes it easier to visualize. freq[a_, b_, t0_, tr_, s_] := -((b E^(-s (b + t0)) (b E^(s (b + t0)) (-1 + b s) UnitStep[-b] - b E^(s t0) UnitStep[b] + E^(s (b - tr)) (E^(s (t0 + tr)) (-1 + b s) UnitStep[-t0] + E^(s tr) (-1 + b s - s t0) UnitStep[t0] - E^(s ...

2

How can I programmatically display the values of A,B,α,β For just this, you could do (for the example you have) Clear["Global*"]; p = 5 + 2 I*w + (I*w)^2; H = Apart[1/p] A0 = Numerator[First@H] B0 = Numerator[Last@H] alpha0 = ComplexExpand@Re[Denominator[First@H]] beta0 = ComplexExpand@Re[Denominator[Last@H]] w0 = ComplexExpand@Im[Denominator[...

2

There is no unique answer. The limit depends on the path by which you approach the origin. By parametrizing the path Limit[f[a t, b t, c t],t->0] we obtain $$-\frac{i \text{q1} \left(2 a^2+c^2\right)}{4 \text{po} \left(a^2-c^2\right)}.$$

2

But this variable SUBSETS is used for only the function inversions, and thus should've been bound to this function, instead of dangling in the global scope like this You could put the stuff inside some new context? From clean Kernel Begin["myStuff`"] SUBSETS = Subsets[{1, 2, 3, 8, 4, 7, 6, 5}, {2}]; inversions[list_] := Complement[SUBSETS, Subsets[...

2

You could try using some Cuboid's: f[i_, j_] := i*j; data = Table[f[i, j], {i, 1, 25}, {j, 1, 25}]; bar[{i_, j_}, h_] := Cuboid[{i - 0.5, j - 0.5, 0}, {i + 0.5, j + 0.5, h}] Graphics3D[{ MapIndexed[bar[#2, #1] &, data, {2}] }, BoxRatios -> 1 ] ... and here I've spiced it up with colour, axes, and cylinders: huescale = MinMax[data]; bar[{i_, ...

2

A slightly shorter form of Carl Lange's comment code: List @@@ Sort @ Normal @ GroupBy[Ainput, First -> Last, Max] ListLinePlot @ % {{0., 0.}, {0.14, 0.049}, {0.27, 0.098}, {0.38, 0.14}, {0.41, 1.}, {0.42, 0.99}, {0.43, 0.99}, {0.44, 0.98}, {0.46, 0.98}, {0.47, 0.97}, {0.49, 0.96}, {0.51, 0.95}, {0.53, 0.94}, {0.56, 0.92}, {0.58, 0.91}, {0.61, 0.89},...

2

Something like this? funScale[a_] := Function[{x}, a #[x]] & funSum[f1_, f2_] := f1[#] + f2[#] & funDot[scales_, funs_] := Inner[funScale[#1][#2] &, scales, funs, funSum] funDot[scales, funs][x] (* 6 InterpolatingFunction[{{1, 4}}, { 5, 3, 0, {4}, {4}, 0, 0, 0, 0, Automatic, {}, {}, False}, {{1, 2, 3, 4}}, {{1}, {2}, {3}, {4}}, {Automatic}...

1

Like this? list = Table[i, {i, 1, 10}]; n = Floor[Length[list]/2]; list2 = Drop[list, n] list3 = Drop[list, -n]

1

In addition to the issue of subscripts, which I recommend avoiding, there is an issue of substitution within a Function as this requires the parameter Symbols to be literally present in the body: x = a + b * c; f = Function[{a,b,c}, x]; f[1, 2, 3] a + b c (* substitution did not occur *) This construct using a Block analog addresses both points: ...

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