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
2
votes
0answers
15 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
22 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
0answers
33 views

How does one specify that an input variable is an integer? [closed]

Essentially, I want to combine 4 square matrices using the ArrayFlatten command. However, I am specifying the matrix dimensions as an input variable as follows, ...
0
votes
0answers
36 views

How can I isolate a specific variable to one side in an equation? [closed]

Firstly, I will integrate the equation using Simpson's 3/8 Rule since it is quite long to do analytically. All the variables (x, y, r, n, ps, k) are unknowns. I want to make r as the subject. I tried ...
0
votes
2answers
76 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
55 views

How to clear this variable [duplicate]

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

Mean of Randomvariable

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

Dynamic updating problem

Consider the code ...
0
votes
1answer
32 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
216 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
54 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
58 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
58 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
132 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
75 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
51 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
30 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
47 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
117 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
30 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
95 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
32 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
23 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
39 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
60 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
133 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
50 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
40 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
32 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
58 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
77 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 ...
1
vote
1answer
291 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
131 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
49 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
84 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
89 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
91 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
0
votes
1answer
58 views

Changing the dependent variable

I'm using NDSolve to solve a set of ordinary differential equations. The output is something like. ...
0
votes
0answers
31 views

No Solution For Solve with Free Variable [duplicate]

Mathematica returns no solutions for this simple query: Solve[a*x == x && x != 0, {x}] (* output: {} *) Clearly, when a ...
0
votes
1answer
62 views

How to asign well numerical values efficiently before to plot?

A problem is presented when the substitution of the numerical values for this function ...
2
votes
0answers
49 views

Issue with calling one notebook from inside another one

I am calling one notebook (N2) from inside another notebook (N1). The results are transferred correctly from the second notebook to the first one. But when I try to compare the results from the two ...
2
votes
1answer
41 views

How to Append the value of a variable and not the variable itself

So lets say I have a = Some complicated code that changes list = {} AppendTo[list, a] Obviously it would give me ...
0
votes
0answers
81 views

Using an if statement to assign a value to a variable

New Mathematica user here. I'm using some code from a colleague and editing it to give me more specific results in finding the zeros of a complex polynomial. I am attempting to find a way to assign a ...
3
votes
2answers
66 views

Better way for constant expressions in functions than storing as global variables?

For example, I wrote a function like this: inversions[list_] := Complement[ Subsets[{1, 2, 3, 8, 4, 7, 6, 5}, {2}], Subsets[list, {2}] ] But as you see, ...
1
vote
1answer
318 views

How to obtain non-trivial solution?

I have the following system of equations. $ quad\quad\quad\quad u+\alpha v+v+e^{\frac{i \alpha }{2}} (\alpha -1) x=\alpha u+e^{-\frac{1}{2} (i \alpha )} (\alpha +1) z, +u+v=\alpha (v+w)+w+y, (\...
4
votes
1answer
52 views

Name of patterns cast as expressions from strings

I'm trying to match a part of a string while imposing conditions on the patterns, e.g.: StringCases["223", a: DigitCharacter ~~ b: DigitCharacter /; Unequal[a, b]] ...
0
votes
2answers
76 views

Integration result depending on variable name

From previous threads I have read on the subject, it seems that Mathematica is known to simplify expressions to varying degrees depending on alphabetical order of chosen variable names. But none of ...

1
2 3 4 5 6