Tag Info

Hot answers tagged

7

s = {x, y} /. Solve[a x + y == 7 && b x - y == 1, {x, y}][[1]] {8/(a + b), -((a - 7 b)/(a + b))} lsa = LinearSolve[{{a, 1}, {b, -1}}, {7, 1}] {8/(a + b), (-a + 7 b)/(a + b)} f = LinearSolve[{{a, 1}, {b, -1}}]; lsb = f[{7, 1}] // Simplify {8/(a + b), -((a - 7 b)/(a + b))} s == lsa == lsb // Simplify True Solve can handle a ...


6

Use proper syntax (e.g., Sin[ ] vice Sin( ), Pi vice pi, Normal for Series, Evaluate Plot function to keep from recalculating series expansion for each point). Plot3D[ Evaluate[ Series[ Sin[1 + x + y^2]/(4 + x^2 + y^2), {x, 0, 4}, {y, 0, 7}] // Normal], {x, -Pi, Pi}, {y, -Pi, Pi}, ClippingStyle -> None]


4

You can define your own scalar product as Scalar[a_, b_] := Dot[a, Conjugate[b]] so that Scalar[{1,0},{I,0}] = -I. The issue is that vectors and dual vectors in Mathematica are written the same way---they are both lists---so the system has no way to keep track of whether you are passing it b or Conjugate[b], for example. Thus Mathematica does the least ...


3

I'm the one inside the company who suggested RightComposition (and pushed for syntax for Composition and RightComposition). I'm sympathetic to your need, and have wanted the same thing once or twice myself. Given that not much /* and @* code has been written yet, I think it is certainly possible we could have /* parse to LeftComposition. I'm not sure what ...


2

Good News Everyone! Two-parameter syntax for Fold and FoldList has been (silently) implemented! Taliesin Beynon informs me that this was implemented in 2011, so check your older versions as well. Using version 10: Fold[f, a] FoldList[f, a] f[f[f[1, 2], 3], 4] {1, f[1, 2], f[f[1, 2], 3], f[f[f[1, 2], 3], 4]} And the held expression example: ...


2

Here is the functionality I wrote as a part of the static code analyzer, which itself is a part of my effort to construct a FE-based IDE. It takes into account variable localization, and gives only globally-defined symbols, defined in a given piece of code. Some helper functions: ClearAll[shead]; SetAttributes[shead, HoldAllComplete]; shead[f_Symbol[___]] ...


2

Using this site as my rubber duck and attempting to answer my own questions: (1) Reason for existing behavior One may want to be able to do this: heldRow = HoldForm @* Row @* List; (* version 10 syntax *) x = 7; Block[{x}, heldRow[x + x + x, x^2*x^3] ] 3 xx^5 (* proposed behavior would yield: x+x+xx^2 x^3 *) My counterargument: this ...


1

I've actually managed to answer it myself - will answer here if it's any good to others; Ebound[r_] = Piecewise[{{Eb1[rn, 14400] /. x, r < rn}, {Eb1[r, 14400] /. x, r > 0}}]; Plot[Ebound[r], {r, 0, ro}, PlotRange -> Automatic] this gives the expected behaviour;


1

A bit more terse than your own code: Symbol /@ ToString /@ Row /@ {{x, y}, {y, z}, {x, z}} {xy, yz, xz} Or using SymbolName as suggested by mfvonh in the comments: Symbol[""<>(SymbolName /@ #)] & /@ {{x, y}, {y, z}, {x, z}} {xy, yz, xz} However, both these and yours will fail if a Symbol such as x already has a value. To get around ...



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