Skip to main content
19 votes
Accepted

How to calculate $\prod\limits_{p}\frac{p^2+1}{p^2-1}$?

A Trace reveals the problem: ...
Michael E2's user avatar
  • 241k
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 ...
KennyColnago's user avatar
  • 15.3k
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,...
Αλέξανδρος Ζεγγ's user avatar
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}}$$ ...
Mariusz Iwaniuk's user avatar
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 $...
Javier Garcia's user avatar
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 ...
march's user avatar
  • 24k
8 votes
Accepted

How to simplify Sum's and Product's of arbitrary length?

...
Bob Hanlon's user avatar
  • 161k
8 votes
Accepted

How can I tell `Dot` to behave automatically linear?

Use TensorExpand[] instead: ...
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 ...
Carl Woll's user avatar
  • 131k
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 ...
John Doty's user avatar
  • 13.9k
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: ...
Henrik Schumacher's user avatar
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[]: ...
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: ...
kglr's user avatar
  • 399k
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 ...
rhermans's user avatar
  • 37k
6 votes
Accepted

N[Product] and NProduct give different results

A bit of re-writing can get around this: ...
chuy's user avatar
  • 11.2k
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....
matrix42's user avatar
  • 7,180
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 ...
Henrik Schumacher's user avatar
6 votes

Smoother ways for setting up a Product function with j=0 and j != i

Using InterpolatingPolynomial: ...
Roman's user avatar
  • 49.3k
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: ...
J. M.'s missing motivation's user avatar
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: ...
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
cvgmt's user avatar
  • 79.4k
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 ...
Domen's user avatar
  • 30.6k
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 ...
George Datseris's user avatar
5 votes
Accepted

Calculating the series expansion of a theta function

Try the following code with an example: ...
Somos's user avatar
  • 4,985
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 ...
Somos's user avatar
  • 4,985
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$: ...
cesar guerra's user avatar
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 ...
Szabolcs's user avatar
  • 236k
5 votes
Accepted

Dropping non-commutative product in the end

You can simply replace NonCommutativeMultiply by Times as follows: ...
Lukas Lang's user avatar
  • 34.4k
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}
eldo's user avatar
  • 82.4k
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 ...
Daniel Lichtblau's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible