Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 9362

Mathematica symbols are the ultimate atoms of symbolic data. Every symbol has a unique name, exists in a certain Mathematica context or namespace, and can have a variety of types of values and attributes.

8 votes

What are the requirements for a well behaved indexed variable? Subscript, ToExpression, Down...

Using DownValues enables you to format the display in the subscripted form without using Notation and Symbolize (Format[#[n_]] := Subscript[#, n]) & /@ {x, σ, a}; kvar[k_] := Through[{x, σ, a}[k]] …
Bob Hanlon's user avatar
  • 163k
4 votes
Accepted

Separating variables in an expression

expr = x z Sin[x] Sin[y]; f = Variables[Level[#, {-1}]] &; If the order is not important Times @@@ GatherBy[List @@ expr, f] (* {x Sin[x], z, Sin[y]} *) If you want them ordered by variable …
Bob Hanlon's user avatar
  • 163k
4 votes

Can you use superscripts as variable and function names?

ClearAll["Global`*"] Format indexed variables (Format[#[n_]] := Superscript[#, Row[{"(", n, ")"}]]) & /@ {z, w, a, b}; The function definition is z[1][x_, y_, z_] := x*y + z With your specific a …
Bob Hanlon's user avatar
  • 163k
4 votes
Accepted

How can i replace the symbols in a list?

Look at the FullForm of a Rule a -> b // FullForm (* Rule[a, b] *) SeedRandom[1234]; b3 = Thread[{a, b, c, d, e} -> RandomInteger[100, 5]] (* {a -> 8, b -> 72, c -> 44, d -> 38, e -> 22} *) b3 /. …
Bob Hanlon's user avatar
  • 163k
3 votes
Accepted

Replace symbols in output without evaluation

expandNCM[(h : NonCommutativeMultiply)[a___, b_Plus, c___]] := Distribute[h[a, b, c], Plus, h, Plus, ExpandNCM[h[##]] &] expandNCM[(h : NonCommutativeMultiply)[a___, b_Times, c___]] := Most[b] Ex …
Bob Hanlon's user avatar
  • 163k
3 votes

Free symbols in an expression

x = a + b; y = Defer[x*x + g] + 6 x*c + Pi*d + Sin[a*E]; Variables@Level[y, {-1}] (* {a, b, c, d, g} *) Variables@Cases[y, _Symbol, -1] (* {a, b, c, d, g} *) EDIT: y = Defer[x*x] + HoldFor …
Bob Hanlon's user avatar
  • 163k
3 votes

Matrix of functions

Recommend that you consider using an indexed variable. labels = {"A", "B", "C"}; If f[x, y] is distinct from f[y, x] ClearAll[f] Format[f[x_, y_]] := Subscript[f, ToString[x] <> ToString[y]] (m …
Bob Hanlon's user avatar
  • 163k
2 votes

A problem when solving an equation with symbolic variables

Clear["Global`*"] sol[eq_] := Solve[Cases[eq1, c_ *_Dot :> c, Infinity] == 0]; eq1 = (a[3] - a[4]) ψ . ξ + (a[1] + 2 a[2]) ψ . ϕ; sol[eq1] (* {{a[2] -> -(a[1]/2), a[4] -> a[3]}} *) For the o …
Bob Hanlon's user avatar
  • 163k
2 votes
Accepted

How to use the SymbolName of variables along with Map and pure function

Enter values as strings and convert to expressions. EDIT: Added Opacity control Manipulate[ A1 = {-1, 0, 1}; A2 = {Cos[α], Sin[2 α], -2}; With[ {polyw = PolyhedronData[poly, "Polyhedron"]}, G …
Bob Hanlon's user avatar
  • 163k
2 votes
Accepted

Programmatically defining variables

Clear["Global`*"] It is much easier to use an indexed variable and use Format to display the variable any way that you want. For example, to display μ as a subscripted variable Format[μ[n_]] := Subsc …
Bob Hanlon's user avatar
  • 163k
2 votes

Difference between (Names of ) Symbols and Mathematical Objects

$Version "13.2.0 for Mac OS X x86 (64-bit) (November 18, 2022)" Clear["Global`*"] Assigning a value to OverHat[x] OverHat[x] = 3 (* 3 *) OverHat[x]^2 + 3 OverHat[x] + 1 (* 19 *) Clear the value …
Bob Hanlon's user avatar
  • 163k
0 votes
Accepted

Testing Expression over region of values

Clear["Global`*"] expr1 = ((1 - (a*x))^12)*((1 + (a/b))/((1 + (a*x/b))^2)) // Simplify; Evaluating the integral int = Assuming[0 < a <= 1 && 0 < b <= 1, Integrate[expr1, {x, 0, 1}] // Simplify] …
Bob Hanlon's user avatar
  • 163k
0 votes

Using the symbol of the system of equations

eqns = {x + y + z == 1, x - 2 y + 4 z == 2, x + y == 1}; Grid[{ {Style["{", 18*Length@eqns, Gray], First@eqns}, Sequence @@ ({SpanFromAbove, #} & /@ (Rest@eqns))}, Alignment -> {{Right, "=="}, …
Bob Hanlon's user avatar
  • 163k