Tagged Questions

The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
3answers
61 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
35 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
93 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
224 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
66 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
63 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
410 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
174 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
151 views

Probablity weighted ReplaceAll

I'm looking for an elegant way of doing a probability weighted replacement rule, something like this ...
5
votes
1answer
220 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
188 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
53 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
96 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
93 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
78 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
224 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
88 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
88 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
60 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 ...
17
votes
1answer
507 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
65 views
3
votes
1answer
52 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
25 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
187 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
118 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
87 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
78 views
11
votes
2answers
213 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
109 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
83 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
138 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
295 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
127 views

Simple rule appears not to work

I have the following simple code ...
4
votes
3answers
186 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
256 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 ...