[Date Index]
[Thread Index]
[Author Index]
Re: Please help, factorisation question
*To*: mathgroup at smc.vnet.net
*Subject*: [mg98346] Re: Please help, factorisation question
*From*: Valeri Astanoff <astanoff at gmail.com>
*Date*: Wed, 8 Apr 2009 02:46:55 -0400 (EDT)
*References*: <gra1aq$24f$1@smc.vnet.net>
On 5 avr, 12:31, plshlp <n... at live.be> wrote:
> thank you for your solution
>
> I regret to say that i had failed to specify that the elements of the list nn are rationals a/b, not integers
>
> can you think of a way to modify the algorithm so it gives a result in this case ?
>
> Many thanks,
Good day,
Let me re-state your problem : given a list of fractions,
you want to select which ones can be factored into
fractions from the list, and output the many possible
decompositions.
Assuming you know the greatest exponent allowed
for any one rational factor, seems to me you could simply
use "Reduce" to solve your problem.
Here is the way I would do it :
In[1]:= myFactor[numbers_List, kmax_Integer: 2] :=
Module[{n,kk,red,tra},
n = Length[numbers];
kk = Array[k, n];
red = Reduce[And @@ ((0 <= # <= kmax) & /@ kk) &&
(Times @@ (numbers^kk)) == #, kk, Integers] & /@ numbers;
tra = Transpose[{numbers, kk /. Solve /@ red}] /.
(nn_List /; IntegerQ[nn[[1]]] && Length[nn] == n) :>
Transpose@{numbers, nn};
DeleteCases[tra, {_, 0}, 4] /. {{{_, 1}}} -> {} /.
{x_, {{{x_, 1}}, y___List}} -> {x, y}
];
In[2]:= s = {5/4, 4/3, 17/12, 5/3, 16/9};
In[3]:= myFactor[s]
Out[3]= {{5/4, {}}, {4/3, {}}, {17/12, {}}, {5/
3, {{5/4, 1}, {4/3, 1}}}, {16/9, {{4/3, 2}}}}
One can check that 5/3 = 5/4 * 4/3
and 16*9 = (4/3)^2 are the only "factorable" fractions,
given the input list and the maximum exponent (kmax=2).
V.Astanoff
Prev by Date:
**2-defensive prime number**
Next by Date:
**Wolfram Lightweight Grid Manager--available free to Premier Service subscribers and sites**
Previous by thread:
**Re: Please help, factorisation question**
Next by thread:
**Minimize goes into infinite loop?**
| |