19
votes
Accepted
16
votes
François Viète's approximation to π
You could use
VietePiApprox[n_] := (Times @@ NestList[Sqrt[2 + #] &, Sqrt[2], n])/ 2^(n + 1)
SetAttributes[VietePiApprox, Listable]
which approximates Pi as ...
9
votes
François Viète's approximation to π
Well, FoldList also can finish this job:
2/Times @@ (1/2 FoldList[Sqrt[2 + #] &, ConstantArray[Sqrt[2.], 10]])
By the way,...
9
votes
Accepted
Closed form of product of Gamma function
Workaround:
$$\Gamma \left(\frac{k}{n}\right)=\frac{\Gamma \left(\frac{k}{n}+1\right)}{\frac{k}{n}}$$
...
8
votes
How to compute the partial trace of a 4x4 matrix?
You can achieve this by partitioning your matrix and performing a tensor contraction. To be clear, having:
$$ \rho_{AB} = \sum_{ijkl} \rho_{ij}^{kl} | ij \rangle \langle kl |$$
the partial trace over $...
8
votes
Accepted
multiplication of vector spaces
Here's a take that allows one to keep track of the order of things carefully. Note that this is similar in nature to the answer here.
Annihilation operators
We first construct the annihilation ...
8
votes
Accepted
8
votes
Accepted
7
votes
Accepted
Series expansion of a certain infinite product
One idea is to convert the product to a sum by using Log, then convert to a series, and then convert back using Exp, although ...
7
votes
Accepted
Cross product without reordering (noncommutative)
It's handy to use a wrapper for things like vectors with nonstandard properties. So, choose a name like ncVec for your non-commutative vectors. Define its behavior ...
7
votes
Smoother ways for setting up a Product function with j=0 and j != i
Just for fun, here all functions $l$ in one go as a vector l:
...
7
votes
Smoother ways for setting up a Product function with j=0 and j != i
You can always directly supply an edited index list to Product[]:
...
Community wiki
7
votes
How to simplify Sum's and Product's of arbitrary length?
rule1 = Sum[a_Times, b : {i_, __}] :> Select[FreeQ[i]][a] Sum[Select[Not@*FreeQ[i]][a], b]
rule2 = Product[Power[a_, b_.], c_] :> Product[a, c]^b;
Examples:
...
7
votes
How to define replacement rule for Minkowski inner product
Mi = DiagonalMatrix[{1,-1,-1,-1}]
Dotp[{qm[0], qm[1], qm[2], qm[3]}, {qn[0], qn[1], qn[2], qn[3]}] /. Dotp[t1_List, t2_List] :> (t1.Mi.t2)
Or
...
6
votes
Accepted
6
votes
François Viète's approximation to π
Clear[VietePiApprox];
VietePiApprox[n_] := Product[FunctionExpand[Cos[Pi/2^(i + 1)]], {i, 1, n}];
Table[VietePiApprox[i], {i, 1, 10}]
% - 2.0/Pi
{0.070487, 0....
6
votes
How to write down a product with omitted terms?
Long form:
Product[(ρ[i] - ρ[j]), {i, 1, m}, {j, i + 1, m}] Product[(ρ[i] - ρ[j]), {i, 1, m}, {j, 1, i - 1}]
By observing that each factor occurs twice (up to ...
6
votes
Smoother ways for setting up a Product function with j=0 and j != i
Using InterpolatingPolynomial:
...
6
votes
Accepted
How to plot multifactorial function?
The immediate cure is to instead use the Chebyshev polynomial of the second kind, $U_n(x)$, in the definition:
...
6
votes
Numeric evaluation of a matrix product integral
This is a little on the exploratory/speculative side, so caveat emptor.
Letting $f(x)=\log(1+x)$, if we try three different Riemann-like discretizations:
...
Community wiki
6
votes
How to type following expression in Mathematica
Product[x[a]/(b - a), {a, Range[3]}, {b, Complement[Range[3], {a}]}]
-(1/4) x[1]^2 x[2]^2 x[3]^2
6
votes
Accepted
Pattern recognition for products of variables
It works as expected. It matches the whole expression at once:
Cases[a[1] b[1] a[2] b[2], x___ a[k_] b[k_], All]
(* {a[1] a[2] b[1] b[2]} *)
If you want to get all ...
5
votes
Accepted
hermitian matrix-vector product does not give real result
I feel kind of dumb, but I found the answer to my own question in Mathematica's documentation. The function ComplexExpand is what I should be using.
Doing
...
5
votes
Accepted
Calculating the series expansion of a theta function
Try the following code with an example:
...
5
votes
Why is this product equal to zero, when the correct result is 2+GoldenRatio?
The problem seems to be that the function
f[n_, x_:(Sqrt[5]-1)/2] := Product[
1 / (1 - x^k/(1 - x^(2*k))), {k, 2, n}];
when called with ...
5
votes
Closed form of product of Gamma function
The indeterminate can be overcome using the full identity for $\Gamma(nz)$:
$$\Gamma(nz)=(2\pi)^{(1-n)/2}n^{nz-1/2}\prod_{k=0}^{n-1}\Gamma(z+\frac{k}{n})$$
and taking the limit as $z\rightarrow 0$:
...
5
votes
Accepted
How to handle excluded values in a summation or product in Mathematica
I assume you are asking how to exclude a single value from summation, i.e. the $i \ne j$ part in your $\sum_{i=0, i\ne j}^n$ example.
You can simply use a conditional, such as ...
5
votes
Accepted
Dropping non-commutative product in the end
You can simply replace NonCommutativeMultiply by Times as follows:
...
5
votes
Pattern recognition for products of variables
p = a[1] b[1] a[2] b[2];
SequenceCases[List @@ p, {a[k_], b[k_] ...} :> k]
{1, 2}
5
votes
Why do I get different results for the products of two identical expressions?
Bug in NProduct maybe. For that second one, rote conversion to logs, then NSum, then Exp ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
products × 116matrix × 20
summation × 16
simplifying-expressions × 15
special-functions × 11
tensors × 11
list-manipulation × 10
vector × 8
calculus-and-analysis × 7
symbolic × 7
dot × 7
numerics × 5
series-expansion × 5
number-theory × 5
conditional × 4
plotting × 3
function-construction × 3
replacement × 3
pattern-matching × 3
expression-manipulation × 3
rule × 3
prime-numbers × 3
functions × 2
numerical-integration × 2
bugs × 2