2
$\begingroup$

I have an array in which every element is a fraction (some are real , some are a sum of real + complex part). I want to find the smallest common denominator in order to obtain a factor * array containing only integer numbers (real and complex).

Any ideas?

An example array:

A = {1/24 + 7i/32, 83/25, 4/78 + 9i/17...}
$\endgroup$
4
$\begingroup$

How about (with i changed to a proper imaginary unit: I)

A = {1/24 + 7 I/32, 83/25, 4/78 + 9 I/17};

den = Denominator[A]

{96, 25, 663}

lcm = LCM @@ den

530400

A*lcm // Expand

{22100 + 116025 I, 1760928, 27200 + 280800 I}


Indeed, lcm is smaller than Times @@ den == 1591200.

$\endgroup$
  • $\begingroup$ Denominator[A] is enough with I instead of i. $\endgroup$ – Kuba Dec 5 '16 at 15:20
  • $\begingroup$ Ha! That's what you get blindly assuming that the OP's input is correct ;) $\endgroup$ – corey979 Dec 5 '16 at 15:25
  • $\begingroup$ You could also use GCD @@ A $\endgroup$ – Carl Woll Apr 25 '17 at 14:43
0
$\begingroup$

In:

A = {1/24 + 7 I/32, 83/25, 4/78 + 9 I/17};
Denominator[Plus @@ A] A

Out:

{22100 + 116025 I, 1760928, 27200 + 280800 I}
$\endgroup$
  • $\begingroup$ Consider an array like {1/2,1/2} $\endgroup$ – LLlAMnYP Apr 25 '17 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.