23
votes
Extracting variables from an expression
Using an undocumented function:
...
14
votes
Accepted
How to transform a function from f[#1] to f[x]
Well, the easy way is to evaluate it for [x,y].
f[x_, y_] = Sqrt[-1 + Tanh[#1 - #2]^2] &[x, y];
If you'd rather do it ...
13
votes
Accepted
When to name a variable with $
Look at the system context to see what the convention is. I can find 257 built-in symbols in 11.3,
symbols = Names["System`$*"];
Length @ symbols
(* 257 *)
In ...
Community wiki
13
votes
How to transform a function from f[#1] to f[x]
I think the easiest way would be to define(name) the pure function f
f = Sqrt[-1 + Tanh[#1 - #2]^2] &
and use it accordingly
...
11
votes
For any symbol, how can I get the full context-qualified name of the symbol as a string?
This is a variation of Leonid's answer that avoids the dependence on a context like "Test`" that must be empty:
...
11
votes
General::ivar 0 is not a valid variable when using Series in Plot
There are couple of problems with your code.
It is an image, it would be way nicer not to have to rewrite it.
Plotting Series
If you go to ref / Series / ...
11
votes
Accepted
Name a list with Table
Clear[first, second, third]
names = {first, second, third}
numbers = {{1, 1}, {2, 2}, {3, 3}}
Table[Evaluate[names[[i]]] = numbers[[i]], {i, 3}]
first
second
third
10
votes
Accepted
Map[Remove[#]] doesn't seem to do anything
As stated in the comments, a is evaluated before being fed into Remove. We can prevent this by using ...
10
votes
Accepted
Is it possible for Mathematica to output the name of a matrix as opposed to its matrix form?
You can decompose any Hermitian 2ร2 matrix $A$ into a sum over Pauli matrices,
$$
A=c_1\mathbb{1}+c_x\sigma_x+c_y\sigma_y+c_z\sigma_z
$$
and the coefficients $(c_1,c_x,c_y,c_z)$ can be computed by the ...
9
votes
Accepted
Apply ToString to a list of variables
In addition to Mr.Wizard's answer here is a collection of other possibilities:
...
9
votes
Accepted
Context inside Do[...]-loop
Begin["mycontext`"] affects the parser, not the evaluator.
These are separate expressions:
Begin["mycontext`"];
...
9
votes
Accepted
Why is DSolve different when the equation is built programmatically?
You attempt to solve the ODE at the time of definition of lsolve. At this point, q does not depend on ...
9
votes
Name a list with Table
Clear[first, second, third]
names = {first, second, third};
numbers = {{1, 1}, {2, 2}, {3, 3}};
With[{names = names}, names = numbers];
first
{1, 1}
9
votes
Partial derivatives in a variable name
I suggest using any of the other similar-looking characters:
U+1D6DB ๐
U+1D715 ๐
U+1D74F ๐
U+1D789 ๐
U+1D7C3 ๐
all of which seem to produce a valid symbol in Mathematica.
9
votes
Accepted
How to Obtain Complete List of Properties
Importing "MTX" returns a SparseArray, so you can do A["Properties"]. ...
8
votes
Character to replace _ in symbol names?
I use $ as a separator. It is a valid symbol character.
In my application I have a set of variables that need to be identified by coordinates, like for example a17_4_25. I can't just drop the _ ...
8
votes
Name a list with Table
With the following definitions:
Clear[first, second, third]
names = {first, second, third}
numbers = {{1, 1}, {2, 2}, {3, 3}}
a one-liner approach would be:
<...
7
votes
Accepted
Want to return name of last defined variable without explicitly naming it
I think there must be a better way to accomplish the OP's ultimate goal than the general approach outlined above. But be that as it may, the following culls all the ...
7
votes
Accepted
Is it possible to "escape" numbers so they can be used as a variable name?
YES.
Use Script Numbers like ScriptThree
\[ScriptThree]=4
7
votes
Accepted
Name of patterns cast as expressions from strings
StringCases["223", a : DigitCharacter ~~ b : DigitCharacter /;
Evaluate[Unequal @@ (ToExpression /@ Characters["ab"])]]
...
7
votes
Construct 1 variable function from given 2 variable function
What you want is called "currying".
Not involving new operators you may try:
...
7
votes
Accepted
Make matrixes with numbered name
You can use ToString and ToExpression to form the variable names and make assignments to them.
Variable names:
...
7
votes
Accepted
Incorrect syntax highlighting? "Variables made special by use in arguments" not working
Welcome to MMA SE! (Note that I think you shouldn't be using Evaluate there: consider i=3; Do2[Print[i], {i,5}].) Syntax ...
7
votes
Accepted
How to use <* *> in tex to substitute mathematica variables
I haven't saved it.
Well, if you do not save the latex to the file, it will not work. Here is a small template to use. This creates index.tex file, solves few integrals and solves an ode and saves ...
7
votes
Does Mathematica have that function which returns the variables back
Edit
Thanks @BobHanlon
...
7
votes
Is it possible for Mathematica to output the name of a matrix as opposed to its matrix form?
This is a partial answer addressing only the first example given.
If you Set the value of a symbol, the symbol can never appear in the output, only its value.
...
6
votes
Apply ToString to a list of variables
You're going to first need to hold {data1,data2} unevaluated in some way; either define it first, use SetDelayed (short form <...
6
votes
Accepted
Can I bake my own PI using your Wolfram language oven and prebuilt utensils?
Beside using Block as ciao suggests in his comment to the question, you can also play with the attribute Protected.
Thus,
<...
6
votes
6
votes
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
variable × 345variable-definitions × 55
equation-solving × 48
functions × 41
list-manipulation × 29
plotting × 28
manipulate × 20
replacement × 16
assignment × 16
scoping × 15
symbols × 15
differential-equations × 14
function-construction × 13
calculus-and-analysis × 12
evaluation × 12
expression-manipulation × 11
symbolic × 10
matrix × 8
simplifying-expressions × 8
string-manipulation × 8
syntax × 8
packages × 8
import × 6
dynamic × 6
warning-messages × 6