The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
1answer
45 views

Return the incomming expression on false

when I have an expression, that is unknown to mathematica, it is returned exactly the same, as it was called. For example SeeFlyingPigs[1,2] called on the line ...
7
votes
5answers
226 views

Select a particular rules out of a list

rule = {beta -> 4, alpha -> 2, x -> 4, z -> 2, w -> 0.8} Select[rule, beta] Select[rule, beta &] Select[rule, beta -> _ &] How would I ...
6
votes
1answer
175 views

Better replacement rules to perform this change of variables?

In cosmology, it is common to work with both a normal time variable t and a “conformal” time variable τ, which is defined such ...
4
votes
1answer
67 views

Is Replace doing double work?

In an answer to this question, rm -rf used the function Replace with level spefication to do a series of replacements inside out. As far as I can see, the order of substitutions when more than one ...
2
votes
1answer
85 views

replace RHS of rule

is there an elegant way of replacing the RHS of a rule with the value of some function of it. Say I have {{a -> 1.2}, {a -> 2.3}} and I want to replace ...
2
votes
1answer
42 views

How can I drop the “belongs to integers” part from Reduce output?

I have this Mathematica line: Reduce[1/(E^0)^x + 1/(E^1)^x + 1/(E^3)^x == 0, x] that gives the output: ...
1
vote
1answer
72 views

Transform a rule to a list of rules

How can this rule a -> {1, 2, 3} be transformed into this {a -> 1, a -> 2, a -> 3} by way of a function? ...
1
vote
3answers
82 views

How to distribute but skipping one level

I would like to write a Rule that mimics built-in Distribute[], but one that distributes ...
1
vote
3answers
92 views

Randomly changing matrix entries

1.Write a block of code that generates a 4x4 matrix with randomized real number entries each between 0 & 1, then selects 3 matrix entries at random, and finally replaces these 3 entries with a ...
0
votes
2answers
39 views

How do I generate a list of delayed rules? [duplicate]

I want a list like this: {x :> Print[1], x :> Print[2], x :> Print[3], x :> Print[4], x :> Print[5]} I tried: ...
4
votes
1answer
100 views

Simplifying a b = 1 in non-commutative products?

Yesterday, I try to define some rules for non-communicative multiplication, here. I find some quite helpful rules, but things still do not work properly; the distributive rule can't be applied (e.g.: ...
5
votes
2answers
244 views

Define a rule of derivative in NonCommutativeMultiply?

In tensor calculation, I need to do the following thing: Define a derivative operator Drv[fun,i], such that ...
1
vote
2answers
70 views

Make a partition with a rule

I wrote this line of code : {{1, 1, 1}, {1, 1}} /. ((x___ /; Length[x] > 2) -> Partition[x, 2, 1]) generates this error : Partition::pdep: Depth 1 ...
3
votes
1answer
65 views

How can I create a set (list) provide a kind of rule/algorithm?

Example: S = {r ∈ Q : r² < 2} Let S be the set of all rational numbers whose squares are less than 2. It follows that 1 ∈ S, 4/3 ∈ S, but 3/2 doesn't ∈ S because 9/4 ≥ 2. Thank you.
6
votes
6answers
431 views

Convert a list of rules into 2 lists of integers

If I have a list of n number of rules, what is a concise way of breaking the data into 2 lists of the first and second part of the rule? This works, but seems like an unnecessary amount of code to ...
1
vote
4answers
185 views

How to extract only real solutions from the result of Solve

For Example, I have the following polynomial equations: $$ \left\{ \begin{array}{ll} \dfrac{2025 (208 x+5 (y-3446))}{52 (y+90)^2}+\dfrac{300 (8 x-21 y+1920) (y-80)}{7 (x+30)^3}+\frac{300 (80 x-21 ...
7
votes
2answers
153 views

Probablity weighted ReplaceAll

I'm looking for an elegant way of doing a probability weighted replacement rule, something like this ...
6
votes
2answers
319 views

Converting hierarchies of rules to associations

The impossibility of MatchQ-ing inside and Association MatchQ-ing Associations (MMA 10) explains a problem I have. I would like ...
1
vote
4answers
193 views

How to find all symbols in an expression and perform an operation on them?

========== motivation =========== Suppose, for example, I have an incoming expression like m = (3-I)x + 4(x y)/(Cos[y]) I want to find all the symbols in ...
1
vote
1answer
58 views

Devising a sparse array rule

Suppose I have a matrix A={{1, 2}, {3, 4}} that defines the positions of non-zero values in a sparse array: ...
0
votes
2answers
103 views

Discrete ContourPlot3D with restrictions

I have the follow simple condition between integers: k - 2 h - l == 0, which describe a plane that I plot with: ...
5
votes
2answers
107 views

ReplaceAll performance problem: packed arrays on the LHS are unpacked when the RHS is too long

The following is one of the most mysterious performance problems I encountered and came up while extending the booleval function mentioned here. I am looking for a ...
1
vote
1answer
79 views

How to create list of delayed rules? [duplicate]

I am trying to make a ButtonBar that prints the name of the card in question. What I have so far is as follows: ...
10
votes
1answer
231 views

StringReplace, ReplaceAll and Rule interact in a bizarre way

I have the following pair of things: ClearAll[foo, labeledFoo]; labeledFoo = {"FooBarBazQuux", foo}; This works like you'd expect: ...
0
votes
1answer
91 views

How do I apply a rule to every element in a matrix? [closed]

I need to apply a set of rules (I used Which) to every element in a matrix, but the rules are dependent on the position [[i, j]] ...
2
votes
1answer
112 views

Applying rules to rewrite expressions that contain patterns

I'm trying to write a rule that can rewrite a pattern that exists in another expression. For some reason, this is proving to be more challenging than I expected ... most likely because I'm not totally ...
0
votes
0answers
64 views

Is there a faster way to do Normal[SparseArray[{{1,1,1}→1.2, {1,1,2}→20.2, …, {m,n,p}→0.3}]]?

I have a list of the form {{1,1,1}→1.2, {1,1,2}→20.2, ..., {m,n,p}→0.3} and I want to create an $m \times n \times p$ array, $A$, where the value of $A[[i,j,k]]$ is ...
1
vote
0answers
42 views

How to apply an rule to factors matching a certain form

Suppose we have many expressions involving irrational ArcTan expressions (such as ArcTan[Sqrt[3],5]) along with other irrational factors (such as ...
18
votes
1answer
513 views

What does ImageSize -> 1 -> 1 mean?

On the page http://www.wolfram.com/language/gallery/blur-faces-in-an-image/ the example code has ImageSize -> 1 -> 1. I am unfamiliar with this chaining of ...
0
votes
1answer
66 views
3
votes
1answer
53 views

Assign the Background rule in Grid (the positions can be described by a integer function)

For example, this code Grid[Transpose[Table[{n, n^2}, {n, 1, 10}]], Frame -> All, Background -> {{1 -> Red, 4 -> Red, 9 -> Red}}] produces , in ...
0
votes
0answers
28 views

How to pass rules to packages [duplicate]

EDIT: After helpful comment from @Mr.Wizard I added the working implementation below for future reference. I wrote a module that does something with variables provided in form of a rule. It works ...
5
votes
2answers
199 views

How to “ReplaceAll” using a set of conditional expressions instead of a list of rules [closed]

Suppose that I have two linear functions f[x_] := f0 + f1 x g[x_] := g0 + g1 x and a (possibly rather complicated) set of conditional expressions, obtained ...
0
votes
3answers
120 views

How to find the Mean of results given as a list of Rules?

How can we find the mean of the following type of data? ...
0
votes
1answer
92 views

How to convert the expression '{a->a0, b->b0}' to the expression 'a=a0; b=b0'? [duplicate]

How to convert the expression '{a->a0, b->b0}' to the expression 'a=a0; b=b0'? I think this is a common question and do not know if someone has asked it before. Any help or suggestion will be ...
0
votes
2answers
79 views
11
votes
2answers
220 views

ReplaceRepeated seemingly omits some rules

Is there a simple way in Mathematica to prevent rule reordering? Let me give an example: ...
2
votes
2answers
113 views

Converting a date to a calendar quarter

I have a list that includes dates. I need to convert each date to be the last day of the quarter that it's in. So for example I want {2013,7,1,0,0,0} to become {2013,9,30,0,0,0}. Actually I don't ...
1
vote
1answer
90 views

using rules to look up values

I have a lookup table with about 30 rows. Column 1 has the value I want to search for and column 2 has the value I want returned. It seemed like I should be able to use rules to do this, but clearly ...
1
vote
2answers
148 views

ReplaceAll a list of rules to an equation

Given the following equation and rule, how would I Solve the equation for tr, k and ...
1
vote
1answer
75 views

Exporting data which includes rule as number only and use lhs as label

I use listD1 = Table[FindRoot[(*my eqns depending on k*), {k, conc}] to get a list of solutions for the different values of ...
0
votes
2answers
321 views

How to implement this simple product rule in mathematica [duplicate]

Firstly i have defined a simple function below. dotPro[a_, b_] := a[1]*b[1] + a[2]*b[2]; Then i create two terms using the above function. ...
1
vote
1answer
132 views

Simple rule appears not to work

I have the following simple code ...
4
votes
3answers
190 views

Renaming and indexing list of rules

I have a list of rules that represents a list of parameters to be applied to a circuit model (Wolfram SystemModeler model): ...
7
votes
2answers
261 views

How to replace a variable that was assigned a value before

Question How to make the replacement $f[x] \to f[y]$ for an abitrary function $f$ if $x$ was assigned a value before? Example 1 How can I make the replacement $x +1 \to y + 1$ if I have assigned ...