Questions tagged [variable]

Questions on the use or manipulation of Mathematica variables (i.e. names associated with a changeable value). Use [variable-definitions] or [assignment] for questions on variable context localization, or assignment.

Filter by
Sorted by
Tagged with
0
votes
2answers
63 views

How to swap keys and values of an association? [duplicate]

How do you swap the values and keys of an Association in a manner similar to taking the transpose of a two-dimensional matrix or nested list? I am trying to solve the Wolfram Challenge Capital Cities ...
1
vote
0answers
66 views

Full Information Maximum Likelihood - Under some other name in Mathematica

I have recently stumbled upon something called FIML - Full Information Maximum Likelihood. Apparently this methodology helps overcome missing variables provided the gaps are random. Searching the ...
5
votes
1answer
129 views

What Does this Syntax Mean in Ouput from DSolve?

When I run the code DSolve[y*D[f[x, y, z], z] - z*D[f[x, y, z], y] == 0, f[x, y, z], {x, y, z}] I get the following output. I don't understand this syntax. I ...
0
votes
2answers
65 views

Integrate of simple equation but is not solving!

I have this simple integral but I don't know why Mathematica can't solve it?! FullSimplify[Integrate[x/(-x^2 + a x + b)^(1/2), {x, Sqrt[b], Sqrt[R^2 + b]},Assumptions -> {a > 0, b > 0}]]
3
votes
2answers
131 views

Making a list of variables

Consider the following code, which give a Manipulate object that returns the "total" of a certain variable var 1 ...
2
votes
0answers
55 views

Extracting variables [closed]

Similar to this perhaps, but I prefer a built-in function. I have defined the expression L = a*b*c. Is there a Mathematica function that can identify and extract ...
2
votes
1answer
122 views

How to replace the arguments of a function?

I have the following type of (very long) expression: $$\ldots + X[1,2,3,5] + X[2,4,5,6] + \ldots \tag{1}$$ where $X[a,b,c,d]$ is some undefined function. I would like to replace all the occurrences of ...
2
votes
1answer
90 views

Coloring all the variables with the same name with the same color

I would like to know if there is a possibility to automatically color the variables with the same name with the same color. For example, like in the picture below: Right now I need to do it manually ...
3
votes
1answer
71 views

Performing matrix tensor product and getting a sum of its negative entries

I am given a $3 \times 3$ matrix $M$, which only has real entries. Is there an efficient way to do the following two operations with $M$? For a given input $n$, compute the $n$-fold tensor product $M^...
1
vote
1answer
60 views

Define variables dynamically to compute a function

Let's say I have defined a function $W(p, q)$, where $p$ and $q$ are integers between (and including) $0$ and $2$ and the function takes me to a real number. Upon an input $n$, where $n$ is a positive ...
5
votes
1answer
114 views

Incorrect syntax highlighting? "Variables made special by use in arguments" not working

This example is obviously not useful on its own, but it will cover everything I actually need to know for a more complicated function I'm making. The example is to recreate the ...
0
votes
1answer
40 views
2
votes
0answers
23 views

[NDSolve error]: Equation or list of equations expected instead of 0.0001` in the first argument {(s^\[Prime])[t]==-0.325 s[t]-1.5 i[t] s[t]-1.5 [closed]

I am trying to have 5 PDEs with 5 unknowns, with code below However, I always receive the error message that Equation or list of equations expected instead of 0.0001` in the first argument {(s^[Prime])...
1
vote
0answers
28 views

Error using list of discrete variables with WhenEvent

I came across an error when using a list of Discrete Variables with NDSolve and WhenEvent. As you can see in the minimal example, where I defined the 'testevent', when I use ...
0
votes
2answers
78 views

Why does this simple code with Eliminate not give any result?

My goal is to obtain the function $s$ defined in the code below as a function of $\chi_1$, $\chi_2$, $\chi_3$. The code runs but never ends, although the problem does not seem too hard to solve for a ...
0
votes
1answer
62 views

How to clear this variable [duplicate]

I can not clear this variable. How to clear?
0
votes
1answer
43 views

Mean of Randomvariable

I want to calculate Mean[x+y]. x = NormalDistribution[] y = NormalDistribution[] Mean[x + y] ...
1
vote
1answer
65 views

Dynamic updating problem

Consider the code ...
0
votes
1answer
45 views

Solve in parametric equations in term of a set of parameters

I am not sure the title is right but let me explain. I have the relations ...
3
votes
3answers
219 views

Make matrixes with numbered name

Suppose I have two matrixes M1 = {{0, 0}, {0, 0}} M2 = {{0, 0}, {0, 0}} Now I wanna have $N$ matrixes in this form called M1, M2, M3, M4,...MN How to code to ...
0
votes
0answers
56 views

A function that maps Held symbol to string

Rougly my question is about constructing a function that maps Hold[var] to "var" even when var has an assigned value. In details : ...
2
votes
2answers
63 views

How can I store vectors in a matrix

I am triying to generate realizations of a Gaussian random process using the KL expansion. For that, I need to multiply an eigenvector for an eigenvalue and a random variable. I have tried ...
3
votes
1answer
59 views

Definition of multiple variables from a list

I have a list of the form {{0, 0, 0, 0, 0, 0, a, b, c, d, e, f}, {0, 0, 0, 0, 0, 1, a, c, b, d, f, e}, {2, 2, 2, 2, 1, 2, b, f, c, a, d, e}, ... } and I would ...
5
votes
1answer
140 views

How to plot solutions of a system of equations by changing colours when one of the variables increases by step?

I have a system of two 3-variable equations $SysEqs=\{f(x,y,z)=0\;,\;g(x,y,z)=0\}$ where the domain of variables are $$6 < x < 2 \pi \\ - \frac{15}{100} < y < 0\\ 0 < z < \frac 32$$ ...
3
votes
0answers
76 views

Module inside With, With inside Module, or Just Module?

In general, if one wants to define local variables and local constants, which of the following is the best programming practice in terms of performance and code "safety"? (Assume ...
0
votes
1answer
72 views

Is it possible to plot a 3-variable function, two variables normally, and the third one to change with color?

I have a function like $$f(x,y,z)=4 \sinh (2 y) \cosh (z-x)+5 \sin (2 x-y)-6 x+y+3 \cosh (2 z)$$ where $$0<x<4\;,\qquad-3<y<0\;,\qquad0<z<2$$ I would like to have a plot of this ...
1
vote
0answers
31 views

How to change expression of variable in output

I run the example: c = a - b; e^(a - b) This gives me e^(a-b). How can I do to let it output e^c
2
votes
1answer
51 views

shadowing problem with options of a package

So here is my problem. I am writing a software with mathematica, that uses an external package as a resource. They are some libraries for numerical integration, the CUBA libraries. http://www.feynarts....
1
vote
2answers
125 views

How to make a change of variable $y=x^2$ in the differential operator $\frac{d^2}{d y^2}$?

I have this differential operator $$\frac{d^2}{d y^2}\qquad (1)$$ I want to make a change of variable $y=x^2$ in $(1)$ so that I get this differential operator $$ \frac{1}{4 x^2} \frac{d^2 }{d x^...
0
votes
1answer
31 views

Writing a function with a variable [closed]

trying to write this function, while b,d are known numbers and hj is the variable thank you very much
0
votes
3answers
99 views

Elimination of the variables

I am trying to get an equation in terms of variable z by eliminating variables g0 and g1 but Running below code is taking time forever ...
0
votes
0answers
33 views

Automating the re-writing of an expression

I have a function of two variables $f(x,y)$ that I know I can be expressed in the form of a single variable $z=x/y$. Is there a way to write the function in terms of $z$ easily/in an automised fashion ...
0
votes
3answers
39 views

Removing terms with more than 2 variables

Say I have the variable x = a + a b + a b c + a b c d + .... What is the easiest way to remove all terms with more than 2 variables? Up until now, I have used <...
0
votes
0answers
24 views

Minimizing a function and plot it

I have a long expression, depended on 3 different variables say "a", "b" and "p". Just as an example, a part of this expression is: z = p * Cos[x] * Sin[y]. I'm going to ...
-1
votes
1answer
40 views

How to store ParametricPlot in a variable without plotting the graph?

Write separated commands for the following parametric equations using ParametricPlot and plot all of them in a single graph and show the combined graph only.
0
votes
2answers
67 views

Indexed variable - Function that contains summation

I have the following problem: I have a function that looks like $f(c_1 , c_2 ) = c_1 + c_2 + c_3$. The variables are $c_1$ and $c_2$, $c_3$ is a known constant. I would like to define a function in ...
1
vote
1answer
32 views

How can I use Table in a replacement rule? [closed]

I would like to implement the following replacement rule: $$tr[a^k]^\ell \longrightarrow t[\underbrace{k,k,...,k}_{\ell\ \text{times}}]\,. \tag{1}$$ My (naive) attempt was to write: ...
4
votes
1answer
138 views

Construct 1 variable function from given 2 variable function

Given a function f[x , y]. The definition of f is not self-describing. (f was defined with objects other than f.) Then I want to construct a function g[x] such that f[x,y] and g[x][y] are the same, ...
6
votes
1answer
55 views

Automatically set x=0, after each input/output ? ($AfterEachInputOutput)

Is it possible to do something that I want, after each input/output automatically and silently? I am looking for a feature like $AfterEachInputOutput in the following code : Example : to set variable ...
0
votes
0answers
41 views

Assign Variable to NSolve

I'm looking to create an interactive region plot in Mathematica, and it's quite a complicated region (seen below).. The variable p is actually a function of y, and it's too hard to solve analytically. ...
0
votes
0answers
36 views

Replace the output of a module containing local variables by their actual value

I want to construct a function as the output of a Module, but I obtain the local variables as part of the output. This is a problem when I try to construct many of these functions in a parallel table, ...
0
votes
2answers
60 views

Solving equation for unknown and replacing it in second equation

I am new to Mathematica and struggling with its syntax. I have a set of equations, which I would like to solve for my unknowns. I would like to solve the first equation for the first unknown and ...
0
votes
0answers
79 views

Issue with several replacements in a function under certain conditions

I am trying to define a function (reduce[x]) which does several substitutions, depending on the values of certain parameters. Concretely, consider an expression x, which contains an arbitrary number ...
2
votes
1answer
420 views

Desktop vs. Cloud option, home plan vs. basic plan: syntax differences

I do not understand why the following simple expression is accepted using a browser (cloud option), but is not accepted using the installed software (desktop option) with the plan basic of Wolfram ...
1
vote
1answer
160 views

How to do importance sampling to estimate variance?

For a random variable X with density $q(x)=e^{(1/3)∗|x|^3}$, I can estimate its variance by numerical integration method. Then, how can I do importance sampling using a standard normal proposal (...
2
votes
1answer
56 views

Extension of Coefficient to variable exponents

Say I have an expression that is a polynomial in a variable, for example in the variable $x$, in which terms appear for which the exponent of $x$ also includes variables. For example: ...
1
vote
0answers
55 views

Mathematica says that a variable is not defined, yet it gives me a value [duplicate]

this is probably a dumb question (Mathematica noob here) but I can't figure out what's going on. I have a variable that I assign a value to and use, then later in the notebook I assign it a different ...
2
votes
1answer
98 views

Why some variables get substituted and others don't

I was running into some trouble with my math and I whittled it down to this nugget: ...
4
votes
1answer
93 views

Use a variable to represent another variable?

I'm trying to create a list of functions by replacing variables in a template. I tried this: ...
1
vote
1answer
157 views

how to define an example of ODE that represents an undamped forced oscillator whose time evolution is described by beats

I am a newbie in Mathematica and I really don't know how to define an example of ODE that represents an undamped forced oscillator

1
2 3 4 5 6