Questions tagged [expression-construction]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
46
votes
3answers
16k views

How to form a block-diagonal matrix from a list of matrices?

For example, like this: I know Join works, but it is a bit troublesome for multiple matrices. I also tried DiagonalMatrix, but ...
17
votes
2answers
602 views

Additive SparseArray Assembly

The goal is to assemble a SparseArray in an additive fashion. Let us assume we have a large List of indices (some will be ...
11
votes
1answer
282 views

Why can't a string be formed by head String?

Since everything is an expression in Mathematica, why must a string object be formed by "abc" but not by a String[abc] ...
15
votes
2answers
2k views

Need help coding/creating a recursive list

I have two lists A and B, each with 99 real numbers. I want to form a list, C, whose ...
8
votes
2answers
190 views

Using `With[…]` with a list specification as a variable [duplicate]

If you have some defined function, say f[a_, b_ c_, x], one can initialize this by using With[...] as ...
3
votes
1answer
336 views

Arrange equation in normal form

Is there a way, or if not, how could one define a function which takes an equation in any form (for example as given by FullSimplify): $$(A+X_0) x+By=3x$$ and ...
5
votes
1answer
276 views

How to represent 1 as Symbol[“Integer”]

Maybe this is a boring question, but I cannot figure it out. Because every expression has a Head, and Head[1] is ...
2
votes
2answers
727 views

Generating complete lists of polynomials

I would like to generate a list of all $3$-variable Laurent polynomials with non-negative integer coefficients using a looping construct so that I can, one-by-one, check them for specific ...
7
votes
3answers
1k views

How to create a large sparse block matrix

I need to generate a very large sparse block matrix, with blocks consisting only of ones along the diagonal. I have tried several ways of doing this, but I seem to always run out of memory. The ...
6
votes
4answers
732 views

Concatenating strings, unevaluated expressions and evaluated expressions/values

Maybe this is something very simple to some of you. Anyway, I think this can be useful to many others like me. I would like to build an output that involves strings, unevaluated expressions and ...
7
votes
2answers
200 views

Constructing expressions using Sum vs Array[… Plus] vs Plus@@Table[…]

For constructing a sum of terms which are symbolic, I noticed that in addition to ...
6
votes
1answer
3k views

Order of operations, precedence in Mathematica [duplicate]

I get confused in the order of operations in Mathematica. For example, f /@ 10^{1, 2, 3} {10, 100, 1000} In my head, that ...
5
votes
3answers
179 views

How to make RawBoxes to be Expression

expr = First@ Level[Values@ WolframLanguageData["Plot", EntityProperty["WolframLanguageSymbol", "DocumentationExampleInputs"]], {3}] Plot[Sin[...
5
votes
3answers
560 views

Getting a usable expression tree

I need to get the expression tree for some expression. expr //TreeForm The above grabs the expression tree but it isn't in some sort of usable format. Just an ...
3
votes
1answer
182 views

Write Integer powers as products

I need to wirte all occasions of (a+b)^3,Ftp^2, Sin[th]^2, ...etc as (a+b)*(a+b)*(a+b), Ftp*Ftp, Sin[th]*Sin[th], ...etc ...
2
votes
1answer
262 views

How to overload the operator “*” as KroneckerProduct [closed]

Can I use the expression below a * b * c * d for short to instead KroneckerProduct[a,b,c,d] automatically when a,b,c,d are ...
2
votes
2answers
886 views

How to find the lowest power of variable in expression?

If I have expression like a1/x +a2/x^2 + a3/x^3 I want to return 1/x^3. In general case, ...
1
vote
1answer
191 views

The best method of constructing a product of consecutive terms

I am new to Mathematica, I am searching for a way to create an expression with a sequence of terms such as: (x-1)/x (x-2)/x (x-3)/x (x-4)/x … (x-n)/x
0
votes
1answer
810 views

Convert string to function with an argument

I am trying to build an expression by first writing it out as a string and then using ToExpression to convert it to an expression. However, I cannot figure out how to make expression recognize x as an ...
0
votes
1answer
44 views

Nest expressions of several arguments

I have the following function: Q[r_, f_, s0_] := Q[r, f, s0] = F[r, s0] D[f[s0], s0] By calling Q[r, Q[r, f, s0], s0] I ...
-5
votes
1answer
74 views

Translation of GLSL expression (2) [closed]

What's the most compact WL translation of this GLSL expression: length(max(vec2(x,y),s)) ?