New answers tagged

4

First question: See How can I overload a function with multiple bracket-slots so f[a][b] and f[a] can coexist?, and the comments. Second question: Without the s, C_ is a pattern which we can call C on the right hand side. (It seems like you understand this.) With the s included, C_s is likewise a pattern that we can call C, but it only matches ...


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$ ...


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

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]; ...


0

I will give the morse code - generating part of this question another go: First let's query Wolfram Alpha for some morse code: query[letter_]:= WolframAlpha["morse code " <> letter, "PodPlaintext"][[2]] and create an Association for easy lookup charToMorse = query ~AssociationMap~ CharacterRange["A","Z"] The following function translates a given ...


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 ...


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" -> ...



Top 50 recent answers are included