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
3answers
32 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
20 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
37 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
0answers
32 views

How to change the variables of a function?

How can I transform: u[x,y,z] to u[x0,y0,zR] Where: z = zR + f; u [x, y, z] = 1/(I [Lambda] z)Integrate[u0 [x0, y0] Exp[(I k)/(2 z ) ((x - x0)^2 + (y - y0)^2)], y0, {x0, -Infinity, +Infinity}] ; u0 [x,...
0
votes
2answers
38 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 mathematica ...
1
vote
1answer
29 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
123 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
48 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
35 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
29 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
56 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
201 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
97 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
46 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
54 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
67 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
82 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
85 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
56 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
48 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
39 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
68 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
242 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
51 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
vote
0answers
36 views

How to return a variable name and value from within a self-contained function block?

Abstract: I have viewed other solutions on StackExchange but none actually address using a fully self-contained function to return name and value of a variable. The only function that works requires ...
1
vote
2answers
75 views

Getting the name of a variable instead of its value [duplicate]

I want to get the name of a variable instead of its value in output. Say I have a function in which I have vectors e={1,0,0,1} and ...
3
votes
1answer
91 views

Again about Module inside other Module

Let me start with a short preamble. I have a large function (defined through other functions) which I need to integrate numerically. This works. Trying to speed up the process, I played with ...
0
votes
0answers
23 views

How to retrieve variables in the Manipulate's 'dynamic' controller environment

I'm trying to code to generate 'dynamic' controllers and to set initial values (initStart and initEnd): ...
6
votes
4answers
207 views

Assigning a string to variables names

I have the list n1 = {{REL1, "REL.csv"}, {RAND1, "RAND.csv\"}}. That is {{variable name, string}, {name, string}}. I want ...
0
votes
1answer
43 views

Assign variable to solve [duplicate]

I would like to assign my result from equation. I tried /. and := but it gives me empty variable. How can i fix it?
2
votes
1answer
41 views

Problem with superscript

I would like to know if there is option to make such scrpits like in this picture below. Is option to put letter instead of a *?
1
vote
1answer
36 views

Getting a stored variable from its value

Given a numerical value, is it possible to check whether that value is stored in (or defines) some variable in the notebook? Maybe if I could list all of the defined variables, then I could simply ...
0
votes
1answer
91 views

How to get a function from a numerical integration?

I wold like to know how to get a function from a numerical integration. Here is an example: h[y_?NumericQ] := NIntegrate[y*Sin[Sin[x]], {x, 1, 2}] h[2] Then my ...
0
votes
1answer
41 views

Plot any parametrization (pure function, numbered variables)

I'd like to write a function plot[reg_,f_] that takes as input any product of intervals (list of pairs of reals) reg$\subseteq\!\...
2
votes
1answer
42 views

Assign variable array as function input and generate slider inputs for Manipulate

New to Mathematica. I want to be able to input some parameters, do some calculations, and end up with some output in a functional form such as: ...
1
vote
0answers
358 views

Defining a variable to be greater than zero [closed]

I am trying to do some integrals over a region , however this region is going to depend on parameters $ \alpha , \beta $ and when calculating these integrals they give multiple values depending if $\...
1
vote
1answer
68 views

Table of Variables within Manipulate

Given a certain number n, I want to define n controls within Manipulate with the correct ...
2
votes
1answer
64 views

separation of variables in case of vector components

I have a function f in two variables y and theta, where y=z^2+x^2. There are numerical values for x,z,and theta ( x and z are the dimensions),I have to do calculations to obtain the velocity, so I ...
2
votes
1answer
85 views

Store boolean expression into a variable

My purpose is to use a boolean expression as a requirement that a pattern must comply. The requirement is c1 == "a", and I am using it to select a string from a ...
5
votes
4answers
291 views

Name a list with Table

I am struggling to find a way to assign a value from a list to names from another pre-defined list with Table[]. names = {first, second, third} ...
0
votes
2answers
96 views

Use Alphabet[] as a variable in a function

I'm trying to figure out if I can use the letters contained in Alphabet[] as variables for a function. As a simplified example, I'd like to do something like: ...
0
votes
0answers
50 views

Variables for multiple data files plotting using same Mathematica notebook

I am not an expert in mathematica, I have this following code. As you see I import a text file under the name "MyPoint1", plot with "pAll" then I do some more calculation with more variables and ...
0
votes
1answer
31 views

Reading and re-assigning variable

I am trying to create a table by iteratively calculating its values using a temporary variable accu: ...
0
votes
0answers
47 views

ReplaceAll Not Working Correctly

I'm trying to use replaceall to redefine my expression in terms of a separate variable.. ...
0
votes
0answers
38 views

How to restrict the use of variables to the notebook? [duplicate]

I am solving two problems simultaneously in which the variable x is defined. To the left of the image, i'm solving shape functions and matrix operations. But to the right i'm solving Green's function. ...

1
2 3 4 5 6