# Tag Info

1

Conjugate by default assumes that all symbolic quantities are potentially complex. This may seem annoying at first, but there is a very good reason for it, and one way to see why is to define your own version of Conjugate, and see it fail. For educational purposes, I do that below. Define $Conjugate as follows:$Conjugate[x_] := x /. Complex[a_, b_] :> ...

3

LyapunovSolve and DiscreteLyapunovSolve solve several equations Lyapunov, Sylvester, Stein, generalized versions, etc., and as such there is no one standard form. Since they are linear solvers their design was based on the precedent set by LinearSolve. For $\dot{x}=A.x$ to be stable, $P=\text{LyapunovSolve}\left[A^{\mathsf{T}},-Q\right]$ has to be positive ...

0

f[n_] := Module[{i = 1}, Nest[(n - i++)/(a + #) &, n, n - 1]]

5

You can use Fold instead: f[n_Integer] := Fold[#2/(1 + #) &, n, Reverse@Range[n - 1]] f[3] $\frac{1}{1+\frac{2}{1+3}}$ It not very useful analytically, but it allows you to invoke the CPU gods: f /@ Range[50] // ListLinePlot[#, PlotRange -> All] &

1

I'm afraid I don't know what realized covariance means. Perhaps the easiest solution is to use RLink and directly use the R implementation. Here are some links to the documentation to get you started. http://reference.wolfram.com/language/RLink/guide/RLink.html http://reference.wolfram.com/language/RLink/tutorial/UsingRLink.html

5

No, it is not doing a Gram-Schmidt procedure. One way to note that this is distinct from Gram-Schmidt is that Gram-Schmidt produces an orthonormal basis, whereas the example outputs in the Documentation Center page for LatticeReduce are neither normalized nor orthogonal. Instead, LatticeReduce returns a basis $B$ comprised of linear combinations of integer ...

7

Just for fun: f[a_, t_] := a {t - Sin[t], 1 - Cos[t]} Manipulate[ ParametricPlot[{f[1, 4 t], f[2, 2 t], f[4, t]}, {t, 0, 4 Pi}, PlotStyle -> {Red, Green, Blue}, Epilog -> {{Orange, Circle[{4 p, 1}, 1], Black, PointSize[0.015], Point[f[1, 4 p]]}, {Orange, Circle[{4 p, 2}, 2], Black, PointSize[0.015], Point[f[2, 2 p]]}, {Orange, ...

1

Here is what I believe you are seeking: ParametricPlot[{{1 (Theta - Sin[Theta]), 1 (1 - Cos[Theta])}, {2 (Theta - Sin[Theta]), 2 (1 - Cos[Theta])}, {4 (Theta - Sin[Theta]), 4 (1 - Cos[Theta])}}, {Theta, -10 Pi, 10 Pi}, AspectRatio -> .5, PlotRange -> {{-8 Pi, 8 Pi}, Automatic}] The resulting Plot:

0

You probably want something that works in higher dimensions but, for your 2D example can hack Dataset with Transpose: {{{a, b}, {c, d}}, {{w, x}, {y, z}}} // Dataset // Transpose // Query[Apply@g, Apply@f] // Normal (* g[f[{a, b}, {w, x}], f[{c, d}, {y, z}]] *) Maybe Inner for order tensors can be emulated with some combo of arguments to Transpose ...

4

This probably doesn't address the full scope of your question but for the particular example you could use MapThread and Apply: ex1 = {{a, b}, {c, d}}; ex2 = {{w, x}, {y, z}}; g @@ MapThread[f, {ex1, ex2}] g[f[{a, b}, {w, x}], f[{c, d}, {y, z}]] Or Transpose and Apply: g @@ f @@@ ({ex1, ex2}\[Transpose]) g[f[{a, b}, {w, x}], f[{c, d}, {y, z}]]

5

Maybe MapThread gives the levelspec control you need: lst = {{{a, b}, {c, d}}, {{w, x}, {y, z}}}; g @@ MapThread[f, lst, 1] (* or just g @@ MapThread[f, lst] -- thanks: Mr.W *) (* g[f[{a,b},{w,x}],f[{c,d},{y,z}]] *) g @@ MapThread[f, lst, 2] (* g[{f[a,w],f[b,x]},{f[c,y],f[d,z]}] *) or, g @@ Thread[f @@ lst] (* g[f[{a,b},{w,x}],f[{c,d},{y,z}]] *) or ...

0

list = {{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}}; Fucntion[x_, y_, z_, a_, b_, c_] := {a, b, c}.{x, y, z} Fucntion[Sequence @@ #, a, b, c] & /@ list (*{a x1 + b y1 + c z1, a x2 + b y2 + c z2, a x3 + b y3 + c z3}*)

3

ClearAll[a, b, c, x, y, z, list, func]; list = {{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}}; func[x_, y_, z_, a_, b_, c_] := {a, b, c}.{x, y, z} func[##, a, b, c] & @@ list[[1]] (* a x1+b y1+c z1 *) func[## & @@ #, a, b, c] &@list[[1]] (* a x1+b y1+c z1 *) func[##, a, b, c] & @@@ list (* {a x1+b y1+c z1,a x2+b y2+c z2,a x3+b y3+c z3} *) ...

8

In biref, clear denominators and form a lexicographic Groebner basis with variable ordering x>y. Now throw out anything with x in it. eqns = {7*x == -(x*y) + (9*y^4)/(1 + 3*x)^2, 5*y == -2*x^2 + (6*y^3)/(1 + 3*x)}; rats = Subtract @@@ eqns; polys = Numerator[Together[rats]] (* Out[112]= {7 x + 42 x^2 + 63 x^3 + x y + 6 x^2 y + 9 x^3 y - 9 y^4, 2 ...

0

One thing I'd suggest is do not put Solve inside Manipulate if you don't really need to. In this case the expressions can be easily solved symbolically beforehand. Also you should specify initial values for your parameters so that you don't throw an error on first evaluation: These now work fine. Clear[r1] r1[ep_, \[Alpha]_, \[Eta]p_, c_, \[Epsilon]p_] ...

0

Perhaps something like colors = {Red, Blue, Green, Black, Orange, Blue, Pink}; aA = Sin[t] RandomInteger[{1, 7}, {7}]; table = Table[{{aA[[k]] + 1, k}, {aA[[k]], k}, {aA[[k + 1]], k + 1}, {aA[[k + 1]] + 1, k + 1}}, {k, 1, 6}]; polygons = Polygon /@ Prepend[table, Join[{{0, 0}, {1, 0}}, table[[1, ;; 2]]]]; Animate[Evaluate@ ...

1

This is not an answer to your question (hence the community tag) since I do not know why Integrate does not solve this, but to point out that the command Int solves this instantly with no problem. This is using Albert Rich Rubi package: ShowSteps = False; Int[(1 + (1 + 1/(2*Sqrt[x]))/(2*Sqrt[Sqrt[x] + x]))/(2*Sqrt[x + Sqrt[Sqrt[x] + x]]), x]

1

There are several little issues that conspire to trip up your code here and there. Let me just point out a couple of the major things to think about. First, keep clearly in mind the difference between a function f and the expression f[t]. I know from teaching mathematics that these tend to get conflated in ordinary conversation, but you cannot get away ...

8

Here is what I do in such cases: ClearAll[g, f]; Options[f] = {optA -> 1, optB -> 1, optC -> 1}; f[x_, opts : OptionsPattern[]] := {OptionValue[optA], OptionValue[optB], OptionValue[optC]} Options[g] = {optA -> 0, optB -> 0}; g[x_, opts : OptionsPattern[{g, f}]] := f[x, opts, Sequence @@ Options[g]] In other words, only define options ...

1

Not sure if this is what you want, but this is much faster: ClearAll[a, c, phi, t1, psi, g]; a = 0; c[t_] := t*{Cos[t], Sin[t]} phi = Integrate[Sqrt[c'[t].c'[t]], {t, a, t1}, Assumptions -> t1 \[Element] Reals && t1 > 0]; psi = InverseFunction[Function[{t1}, Evaluate@phi]]; g[s_] := g[s] = c[psi[s]] ParametricPlot[g[x], {x, 0, 40}, PlotRange ...

2

I haven't yet tried to imagine an algorithm for your problem but here is a visualization that might help you approach it. pairs[ls_List] := Join @@ Tuples /@ Subsets[ls, {2}]; plot[ls_List, set_List] := ArrayPlot[ Outer[SubsetQ, set, pairs @ ls, 1] // Boole, FrameTicks -> All, FrameLabel -> {"Tuples", "Pairs"} ] If you are not using ...

0

Rationalizeing the first argument of Solve and using ReplaceAll to inject the values for ϵp and ηp solves the issue in your first Manipulate: Manipulate[λ /. Solve[Rationalize[rp*(yp - ep - c + α*λCrp) + sp*(yp - ep + α*(1 - λCsp)) == yp + α*(1 - λ)], {λ}][[1]] /. {ϵp -> ϵpa, ηp -> ηpa}, {ep, 0, α}, {c, 0, α}, {α, 0, 1}, {ϵpa, 1/2, 1}, {ηpa, ...

4

dist = MultinormalDistribution[ {0, 0}, {{1, 0}, {0, 1}}]; PDF[dist, {x, y}] E^((1/2)*(-x^2 - y^2))/(2*Pi) CDF[dist, {x, y}] (1/4)*Erfc[-(x/Sqrt2)]*Erfc[-(y/Sqrt2)] The inverse CDF is not unique. To simplify the problem I will find the inverse CDF with y == x Show[ ContourPlot[ CDF[dist, {x, y}], {x, -3, 3}, {y, -3, 3}, Contours ...

1

Distribute[f[g[x]], g] (* g[f[x]] *)

10

For your particular example, Thread[f[g[x]], g] Generally, we can think of Thread as of a function to exchange heads between first two levels. For more complex rearrangements, you may need to use replacement rules and other methods, described in other answers.

5

Taking the problem a bit more generally we might use a decomposition function: de[p : a_@_ | _] := {a, ## & @@ de @@ p} Then on any expression with one argument at each level: b[c[d[e[x]]]] // de {b, c, d, e, x} Reorder however we please: %[[{3,1,4,2,5}]] {d, b, e, c, x} And put it back together: Compose @@ % d[b[e[c[x]]]]

1

I have found the answer to my question. It is because I was trying to modify the value of x, rather than the name itself. A way round this is to make a copy of the variable, and operate on this. This below works: addHeg[aPopulationImmutable_, aNode_, aNumHeg_] := Module[{aPopulation = aPopulationImmutable}, aPopulation[[aNode]][[3]] += aNumHeg; ...

6

#[[0]] /@ #[[1]] &@ f[g[x]] (* g[f[x]] *)

4

What about switch[f_[g_[x_]]] := f[g[x]] /. {f -> g, g -> f}

2

This works much faster: f[r_, z_, from_, to_] := (int = Integrate[r/((l - z)^2 + r^2)^(3/2), z]; Limit[int, z -> to] - Limit[int, z -> from]) sol = f[r, z, 0, L0] The reason is takes much longer when doing definite integration directly is due to assumptions. If you gives assumptions, then it will be fast also. Try ...

11

Which documented Mathematica function has the longest name I assume then you want all of Mathematica, which includes all standard packages and contexts that come in the installation and not just in the System context. I just run some code I have and added a check to obtain this information. Here is the table. According to this: ...

19

Max[StringLength@Names["System*"]] 38 Select[ Names["System*"], 38 == StringLength[#] &] {"MultivariateHypergeometricDistribution"} As far as I can say there is no limit for lengths of symbol names, besides that of the memory limitation.

12

The term pure function used in Mathematica is not being used in the same sense as the cited Wikipedia article. In Mathematica it refers to an anonymous function. In the Wikipedia article it is a term extracted by analogy from the increasingly popular term "purely functional" which refers (mainly) to deterministic programming free of side-effects. The ...

2

As you're trying to represent things that aren't functions, I suggest to change your representation to vectors (affine): (* a few functions *) line[{v_List, d_List}, a_] := a v + d circle[{c_List, r_}, t_] := c + r {Cos@t, Sin@t} intersection[{v_List, d_List}, {c_List, r_}] := Solve[line[{v, d}, a] == circle[{c, r}, t], {t, ...

1

k[{data_, {}}] := {} k[{data_, rulez_}] := k[{Sow@StepNTimes[data, rulez[[1]], 5], Rest@rulez}] Reap@k[{data, {M1, M2}}] (* {{}, {{StepNTimes[data, M1, 5], StepNTimes[StepNTimes[data, M1, 5], M2, 5]}}} *)

3

I'm not sure I understand what you are doing but the plots plat should be simple. We put all your results in a Table using ParallelTable to use all available cores in your CPU. data = ParallelTable[ Block[ {r = f[x, cb], fmax, xmax}, fmax = First[r]; xmax = (x /. Last[r]); {cb, xmax, fmax} ], {cb, 0, 0.3, 0.3/20}]; TableForm[N@data, ...

1

SeriesData[ a , 0 , #, 0, Length@#, 1] &@CoefficientList[#, a] &@ Integrate[Series[Cos[x], {x, 0, 3}], {x, 0, a}] second try: int = (SeriesData[a, 0, #[[1]], 0, #[[2]] + 1, 1] &@ {CoefficientList[Integrate[ Normal@# , {x, 0, a }] , a], #[[5]] }) &; int@Series[Cos[x], {x, 0, 3}] int@Series[x^4, {x, 0, 3}] ...

9

Here's a way that doesn't mess with an important system function: Clear[a, times]; m = Array[a, {3, 3}]; TensorContract[ Outer[times, Sequence @@ m] \[TensorProduct] LeviCivitaTensor[Length[m], List], Table[{i, i + Length[m]}, {i, Length[m]}]] (* times[a[1, 1], a[2, 2], a[3, 3]] - times[a[1, 1], a[2, 3], a[3, 2]] - times[a[1, 2], a[2, 1], a[3, 3]] + ...

7

In principle you can redefine safely a native function inside Block and given that Det uses Times for symbolic matrices then Block[ {Times = f}, Det[{{a, b}, {c, d}}] ] f[a, d] + f[-1, b, c] As pointed out by @Kuba and @Jens there are several limitations. A better solution would be this: newDet[m_, f_] := Activate@(Block[{ms = Length[m], Times = ...

2

I believe this question is a combination of these: Annoying display truncation of numerical results Confused by (apparent) inconsistent precision A problem about function N Specifically, for your function to work as desired most directly (and correctly) it will need to return a number or expression in arbitrary precision. This is (best) done by using ...

1

I have Mma v.8.0.0 here and it works and gives the same result as v10. Just as a reference, it works also on v9.0.1. IDK if there are versions between 7.0.1 and 8.0.0, though.

1

Fixed for 10.0.2. – John Fultz 5 hours ago

1

Using TraditionalForm[ ] does nothing?: Need to use ParameterVariables ClearAll["Global`*"] vars = {a, b, c, d}; (*Input Matrix*) A = {{a, b}, {c, d}} cp = Collect[CharacteristicPolynomial[A, x], x] TraditionalForm[cp, ParameterVariables -> vars] Reference: http://reference.wolfram.com/language/tutorial/PolynomialOrderings.html

1

There is a built-in function HodgeDual Normal@HodgeDual[{{0, -3, 2}, {3, 0, -1}, {-2, 1, 0}}] (* {-1, -2, -3} *) Normal@HodgeDual[{-1, -2, -3}] (* {{0, -3, 2}, {3, 0, -1}, {-2, 1, 0}} *)

1

As belisarius implies, Mathematica's pattern matcher matches literal expressions and not mathematical equalities. Here's another implementation: skewToq[M_] := If[ And[Dimensions[M] == {3, 3}, M == -Transpose[M]], {M[[3, 2]], M[[1, 3]], M[[2, 1]]} ] skewToq[{{0, -q3, q2}, {q3, 0, -q1}, {-q2, q1, 0}}] (* {q1, q2, q3} *) skewToq[{{0, -3, 2}, ...

3

Set your output to a variable and use in a replacement, e.g. sol = DSolve[...] or setting the output directly sol = {{y -> Function[{x}, x^2 - x^3]}}; z = First[y /. sol]; z[4] -48

4

f1[{a_, b_, ___}] := {a, f[a, b], b}; g1[{a_, B_, b_}] := {g[a, B, b], B, b}; NestList[g1[f1[#]] &, {a, b}, 2][[All, 1 ;; 2]] // TableForm (* a b g[a,f[a,b],b] f[a,b] g[g[a,f[a,b],b],f[g[a,f[a,b],b],f[a,b]],f[a,b]] f[g[a,f[a,b],b],f[a,b]] *) To get your nomenclature ...

1

This does what you want: With[{count = 3, start = {a, b}}, Most /@ NestList[Composition[Prepend[Rest@#, g@@#]&, {#[[1]], f[#[[1]], #[[2]]], #[[2]]}&], Append[start, 0], count]] Explanation: ...& defines an anonymous function. # accesses its argument, which is the list. [[n]] just ...

Top 50 recent answers are included