Hot answers tagged

3

You could use Fold, e.g. q[f_, x_, a_] := Expand@Fold[ x D[#1, x] + #2 #1 &, f, a]; Or rule replacement of polynomial as suggested in comment: fun[f_, x_] := x D[f, x] op[n_, f_, x_] := Nest[Expand@fun[#, x] &, f, n] w[f_, x_, a_] := Module[{v, pol, r}, pol = Expand[Times @@ (v + # & /@ a)]; r = pol /. {Times @@ a -> (Times @@ a) f, v ...


3

Are you aware that you can define a Rule to specify a change of Rules ? For example here is a replacement of the value indexed by {1,1} : {{1, 1} -> 2, {1, 2} -> 3} /. ({1, 1} -> _) -> ({1, 1} -> XXX) {{1, 1} -> XXX, {1, 2} -> 3}


2

(* make a dummy example array *) test = RandomInteger[10, {5, 5}]; (* get rules *) atest = ArrayRules[test]; (* Prefix with our replacements - the default behavior *) (* for sparse array is to ignore subsequent duplicate positions *) patest = SparseArray[Join[{{1, 1} -> -1, {2, 2} -> -2}, atest]]; (* show result *) test patest // Normal ...


2

This is more a long comment than an answer. If you calculate: D[x Hypergeometric2F1[1/2, 2/3, 3/2, x^2], x] FullSimplify@D[x/Sqrt[1 - x^2], x] You find respectively: 1/(1 - x^2)^(2/3) and 1/(1 - x^2)^(3/2) Mathematica gives the correct answer: Check the exponents!!


1

The solution to your Eigenvalues function are Root objects, see the documentation. Root[f,k] represents the exact k^(th) root of the polynomial equation f[x]==0. Inside Root is the pure function in the argument #1. If we named this pure function f with argument x, this would correspond to the situation in the above quote with f[x]. Your Matrix $A$ ...


1

Play seems to have the property that it autoscales the volume to some constant level, regardless of the specified amplitude. The following code should play two tones, the first one loud and the second one quiet: louddot := Play[Sin[2000 t], {t, 0, 1}, SampleRate -> 22050]; quietdot := Play[0.01 Sin[2000 t], {t, 0, 1}, SampleRate -> 22050]; ...


1

It seems you have already done it with Alternative. c = <|"Major" | "Maj" -> {0, 4, 7}, "Minor" | "Min" -> {0, 3, 7}|>; You would just need KeySelect and MatchQ. KeySelect[MatchQ[#]@"Major" &]@c (* <|"Major" | "Maj" -> {0, 4, 7}|> *) or with ReplaceAll. KeySelect["Maj" /. # -> True &]@c (* <|"Major" | "Maj" -> ...



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