9
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
Use Inner
Inner[Power, var, #, Times] & /@ expo
(* {x[1],x[2],x[3] x[4],x[2] x[5]} *)
8
votes
Accepted
Generate vectors with a certain property
Solution without recursion.
gen[n_Integer?Positive] := FoldList[#2 (#1 + #2) &, 0, #] & /@ Tuples[{0, 1}, n - 1]
For ...
7
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
This feels like I was just following the directions in the OP:
Times @@ (var^#) & /@ expo
4
votes
Issue with variable within Sum[] bounds
There appears to be a closed-form solution for specified values of $n$.
I haven't found the general formula for when $n$ is some positive integer. Here are the results for $n=1, 2,\ldots,8$. (Note ...
4
votes
Accepted
How to find intersecting linear equations between two lists?
Can intersect using Intersection once all right-hand-sides are zero. Just use Together on the quotient of left-hand-sides as the ...
4
votes
4
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
Here is another Inner strategy:
Inner[OperatorApplied[Power], expo, var, Times]
3
votes
How to find intersecting linear equations between two lists?
Follow the idea by @Daniel Lichtblau ( +1 );
Using RegionEqual( or ForAll[{x, y}, Equivalent[expr1, expr2]] // Resolve);
...
3
votes
How to find intersecting linear equations between two lists?
Reduce the list
SubtractSides/@List@@FullSimplify[Reduce[Or@@Join[list1,list2]]]
(* {x + 2 y == 0, 3 x - y == 0, 3 x - 2 y == 0, x - y == 0} *)
Sort by slope
<...
3
votes
How to find intersecting linear equations between two lists?
To get an overview, draw a picture:
...
3
votes
How to optimize performance with DeleteDuplicates?
I build upon A. Kato's idea to use a normalization: First turn each element into a unique representative of the equivalence class. Then run vanilla DeleteDuplicates....
3
votes
How to optimize performance with DeleteDuplicates?
This answer is for the case where the order does matter. While OP's question asks for case where the order does not matter at any level.
First of all rules can be ...
2
votes
How to implement this zip function? zip[g,{f[{a,b}],f[{c,d}]}] to f[{g[{a,c}],g[{b,d}]}]
Inspired by @E. Chan-López and @Tapiocaweasel's answers, another variant is:
zip[h_, expr : {f_[__] ..}] := f[h /@ Thread[{##}[[1]] & @@@ expr]]
2
votes
How to implement this zip function? zip[g,{f[{a,b}],f[{c,d}]}] to f[{g[{a,c}],g[{b,d}]}]
A variant of the @Edmund's answer is as follows:
zip[h_, expr : {f_[__] ..}] := expr[[1, 0]][h /@ Thread[Splice@*List @@@ expr]]
zip[g, {f[{a, b}], f[{c, d}]}]
<...
2
votes
How to implement this zip function? zip[g,{f[{a,b}],f[{c,d}]}] to f[{g[{a,c}],g[{b,d}]}]
Your case is very specific and as such the affect can be achieved with MapApply and Part.
...
2
votes
How to find intersecting linear equations between two lists?
Something bland (as equations are linear 2D:
...
2
votes
Standalone Table Invocation Using NextPrime to Generate Sequence of Division of Integers
Your description doesn't match you expected result. This reproduces your expected result:
Divide @@ Comap[{#*2 &, Prime}][Range[10]]
Since you asked ...
2
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
expo . Log@var // Exp
(* {x[1],x[2],x[3] x[4],x[2] x[5]} *)
1
vote
Issue with variable within Sum[] bounds
It's not really an answer.
I think that does not have finite closed-form expression in terms of very large class of special functions.
...
1
vote
Accepted
Transforming an expression into function
This is because Plot, like other similar functions such as Sum or Do, localizes its variable ...
1
vote
Standalone Table Invocation Using NextPrime to Generate Sequence of Division of Integers
Table[Prime[n]/(2 n), {n, 1, 10}]
NestList[NextPrime[Numerator[#]]/(Denominator[#] + 2) &, 3/4, 8]
$$\left\{1,\frac{3}{4},\frac{5}{6},\frac{7}{8},\frac{11}{...
1
vote
Accepted
Standalone Table Invocation Using NextPrime to Generate Sequence of Division of Integers
[extended comment]
It's difficult to figure out exactly what you're asking. If you want Table specifically to perform operations on previous intermediate results, ...
1
vote
1
vote
Insert several rows and problem with Return
m = Table[i*(j + 2), {i, 3}, {j, 3}];
v1 = Range[10, 12];
v2 = Range[20, 22];
Using Fold:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
function-construction × 2498functions × 532
list-manipulation × 280
plotting × 120
calculus-and-analysis × 113
pattern-matching × 112
evaluation × 111
functional-style × 103
programming × 98
performance-tuning × 73
equation-solving × 71
scoping × 69
syntax × 66
variable-definitions × 65
matrix × 64
argument-patterns × 63
replacement × 54
recursion × 52
symbolic × 51
differential-equations × 47
expression-manipulation × 46
options × 46
core-language × 42
conditional × 40
numerical-integration × 38