Questions tagged [rule]

Questions about transformation rules in Mathematica--constructs that let you set, or programmatically modify, local values for expressions.

Filter by
Sorted by
Tagged with
0
votes
0answers
31 views

How to make the variable on the lhs stay after eliminate?

I had a following list of variables, {x''[t] == -x[t]+x'[t], x'''[t] == -x'[t]+x''[t], x''''[t] == -x''[t]+x'''[t]} after performing Eliminate to simplify the ...
2
votes
2answers
119 views

Function incorrectly renaming variables in Rule Pattern

Consider the simple pure Function containing a Rule with the named pattern q. ...
0
votes
1answer
42 views

Using conditions and rules to replace entries in a nested list [closed]

I need to write a single rule that replaces any pair in the testlist with the entry {"Error"} if the first element is negative or the second element is not an integer. I've done: ...
0
votes
3answers
60 views

How do I plot a function that is in a list? [closed]

I am trying to plot a function that I had converted from the returned list of rule assignments from Solve[ ]. I am trying to plot this, but the resulting graph is empty. Does anyone know what I am ...
2
votes
1answer
36 views

Passing an expression to the Plot Function does not Work

Solving a differential equation I found that its solution was analytic, and I stored it as an expression from the default rule output of the DSolve[] function: <...
0
votes
2answers
68 views

Create my own 'Refine' function

I'd like to understand how the Refine function works internally. I tried to create my own Refine function to support basic cases,...
4
votes
3answers
155 views

Not all rules being used in replacement

Result I get for the following replacement doesn't seem to be correct. ...
0
votes
1answer
28 views

Expand product of symbolic sums (with identically named indices)

I have an expression that is a product of two symbolic sums. Sum[a[k], {k, 1, n}]*Sum[b[k], {k, 1, n}] How can I expand this expression? I want to see something ...
8
votes
2answers
225 views

Given x ⊕ x =5,x ⊕ (y ⊕ z) = (x ⊕ y)+z-5 what is 2009 ⊕ 1949

There is an operation "⊕" that satisfies $x ⊕ x =5$ $x ⊕ (y ⊕ z) = (x ⊕ y)+z-5$ what is 2009 ⊕ 1949? I think it is feasible to solve with Mathematica, but my code doesn't give a useful ...
0
votes
0answers
36 views

Are not rules applied in succession?

I am trying this: ...
0
votes
4answers
63 views

Only Reals Rules

I have a huge array of rules with many variables, such as ...
1
vote
3answers
75 views

My rule does not do anything (understandably)

I want a rule that would transform, for example, And[i,F[j,k],l,G[m,F[j,k],n],p] into And[i,F[j,k],l,G[m,T,n],p], where ...
1
vote
0answers
110 views

How to substitute values of multiple variables into an expression [closed]

Brand new user here. How to substitute values of multiple variables into an expression? I try: ...
4
votes
1answer
99 views

Turn definitions into rules

I know that this seems to be unnecessary, but here I have a bunch of assignments, like around 50, and I want to create rules for all these to have the freedom to apply these rules only on certain ...
0
votes
2answers
107 views

How to solve for y for a set of implicit (in x and y) linear equations for use in Plot?

From a matrix m={{1, 1}, {-1, 1}}, a vector b={1, 2}, and a list of variables vars={x,y} we ...
3
votes
3answers
108 views

Ordering a list of rules by its 4 last elements of LHS

I have a list of rules such as ...
1
vote
0answers
52 views

How can I convert a list of rules into a list of equations? [closed]

How can I convert a list of solutions to a list of equations? For example, say I have: sol = {{a->1},{b->2}} and I would like to change it to ...
0
votes
0answers
26 views

Vertical text in a nested grid not aligning correctly along the horizontal (center desired)

I reconstructed the results of several functions that generate rows and nested grids so as to do away with the minutia. I am having difficulty getting the vertical text to ...
1
vote
1answer
37 views

Should be a Piecewise function, a ConditionalExpression or Indeterminate, but it is a number

I apologize in advance for the lack of focus of my question. Consider the function: f[x_, y_] := x/(x + y); f[0,0] evaluates to ...
1
vote
2answers
47 views

Substituting values from an association thread into a table of expressions

I have asked a question here. Yet I am trying to do the same procedure with AssociationThread Suppose I have the following function which is a normal distribution: <...
1
vote
4answers
81 views

Distribute association over a list

I have a list {1,2,3,4,5,6} which I would like to associate to another list {a,b,c} by the rule ...
2
votes
1answer
63 views

Write repeated expressions within a rule more simply

Is it possible to shorten the length of a (delayed) rule (i.e. lhs :> rhs) when there are expressions which repeat several times? Those expressions involve ...
2
votes
1answer
43 views

Replacement rule does not recognize parity?

All of the following ...
3
votes
1answer
59 views

Using Replace for derivative

I have a small issue in understanding the workflow of Replace /. When I give this input: (y''[x]+y[x]) /. y[x] -> 1 I am getting just ...
4
votes
0answers
37 views

Odd behavior of StringReplace and other replacements—but only in certain contexts

When defining a function that uses StringReplace[...] on the lhs of a rule, StringReplace seems to balk at named patterns and ...
5
votes
1answer
144 views

How to map a function to the value parts of rules

I want to map the function to the value part of these rules and get the following result: ...
3
votes
1answer
52 views

Using the elements of one Matrix to form a new Matrix with specified rules

Given a matrix [a], how to get matrices [b] and [c] based on the following two rules? rule [a]->[b]: Strike out corresponding term in [a] and take product of the remaining two terms in the same ...
4
votes
2answers
61 views

Replace Solution arrow in list of list

I have solutions like ...
0
votes
2answers
61 views

Applying rules to functions with non numeric arguments

I am trying to do the following (it's a simplified version): ...
9
votes
1answer
110 views

SequenceCases does something odd with RuleDelayed arguments

I have a list of stuff. list = {a, b, b, a, b, a, a, a, b, a}; I want to split it up into subsequences where a single a is ...
1
vote
1answer
72 views

Make a new list of rules by matching up keys from two given lists of rules

Consider two lists of rules: ...
4
votes
1answer
108 views

Pattern matching natural powers as products

I thought that Mathematica would be smart enough to know that f[t]^2 should match a_ * b_ with ...
4
votes
2answers
291 views

Definition of a general rule

By defining: rule = Sqrt[expr_^2] :> expr; and writing: Sqrt[x^2] /. rule I get: x which is what is desired (...
6
votes
2answers
386 views

I'm not able to delete -> in {{x -> a}, {x -> b}, {x -> c, x -> d}}

Here is what I have done. Input DeleteCases[{{x -> a}, {x -> b}, {x -> c, x -> d}}, Rule, {2}] Output ...
1
vote
1answer
44 views

Defining a conditional statement for a function

I am trying to define a function that is zero when it is evaluated on real numbers and on a preset list of symbols. I am doing this by using ...
1
vote
1answer
47 views

How to deal with procedurally generated rules and patterns?

I'm trying to procedurally generate replacement rules of the following form ...
3
votes
2answers
89 views

Converting numbers and expressions

Trying to create a rule to convert negative numbers/expressions positive. So far: f[-x_]:> f[x] Trying to extend this rule to floats such as -1.0 and ...
9
votes
2answers
379 views

StringReplace with multiple patterns

I am experiencing what seems to be a strange behaviour with StringReplace while trying to add an extra pattern to an existing list of patterns. The problem is to translate a string into Morse code, ...
3
votes
1answer
46 views

How to make function act on (multiple) replacement variables [closed]

I have a function which returns an algebraic expression corresponding to a "jump" between two ordinates, for example $[x]=x_2-x_1$. The function applies for any choice of variables and labels. The ...
4
votes
4answers
106 views

ReplaceList doesn't apply rules down to subparts

Somewhat related to a previous question, I'm experimenting with ReplaceList to get the list of all possible transformations we can obtain by applying a rule to an expression. But I don't manage to ...
2
votes
0answers
58 views

General rule to rewrite function and argument into a new symbol

I am trying to convert Mathematica output into equations I can plug into C. I am presently trying to convert expressions of the form Derivative[1,0,0][f][t,x,y] ...
0
votes
1answer
66 views

Problem with replacement rules

I would like to apply substitution rules to an object I have defined, but I must be doing something wrong. Here are the relevant pieces of code. First I have defined a function ...
3
votes
1answer
57 views

Concisely operate on RHS of list of rules

I have a length-N list of rules l = {a -> 5, b -> 1, c -> 42} and an length-N vector of scalars... dl = {-1, .2, 5} ...
0
votes
0answers
52 views

Delayed Rule right-hand-side mis-evaluation

Outline I am trying to create a rule that will give me a minus sign if the number of times A is applied on X is odd where A is some οperator and X a random quantity. Some of the configurations of ...
1
vote
1answer
42 views

Filter out terms that include any combination of F[X] and G[-X]

I have the following problem which is closely linked to a previous question I asked some time ago (Replacement rule for terms that are separated by operators?). In this specific instance, suppose I ...
1
vote
1answer
45 views

Replace expressions

Let's consider the following example ...
0
votes
2answers
82 views

Suppress arguments in output for pretty print

I would like to define a rule that suppress any arguments of a function for visibility. I tried: rule = f_[x__] -> f While this works well with individual ...
1
vote
2answers
88 views

Correctly differentiate wrt product of variables

I have a function f(x) for which I would need to differentiate and then evaluate it to some product x = y*z. Naively, Mathematica does not accept: D[f[y*z], y*z] ...
6
votes
2answers
301 views

Is there a simple way to apply a function to the RHS of a substitution?

Suppose I have solved a system of equations, resulting in a solution of the form: ...
2
votes
2answers
70 views

1
2 3 4 5 6