Re: [math-fun] Equation mixing integers and reals
----- Original Message ---- From: Simon Plouffe <simon.plouffe@gmail.com> To: math-fun <math-fun@mailman.xmission.com> Sent: Tuesday, September 16, 2008 10:54:41 AM Subject: Re: [math-fun] Equation mixing integers and reals Hello, Concerning the general problem of finding an integer relation. Here is an algorithm for 3 values, that is : if we are looking for aX + bY + Z ? 0 where a,b are 2 real numbers and X,Y,Z three integers. do {| a - b |} = c a <- b b <- c od { } is the fractional part. If we iterate this, after a certain amount of iterations we find 3 integers where the equation is near 0. I could generalize this example to more ; Here is the program in Maple : pseudoLLL:=proc(s) local a, b, c, d, nn, k,i, aa, ss, g, h,m,z; aa:=s: nn:=nops(aa): k:=[seq(frac(abs(aa[i]-aa[i+1])),i=1..nn-1),frac(abs(aa[1]-aa[nn]))]; ss:=evalf(k): g:=sort([seq([convert(1+ss[j],string),j],j=1..nn)],lexorder[2]): h:=[seq(g[i][3],i=1..nn)]: m:=[seq(k[h[z]],z=1..nn)]: return(m); end: This will work with a vector of real numbers up to a certain precision. I could make it to work with Maple 11, but they changed the syntax and the calling sequence again for the sort function (#@!$!@#($&!). For n=3 there, it can be worked out this way : L3:=proc(x, y, z) local a, b, c, d, k1, k2, k3, ll; a := x; b := y; c := z; k1 := frac(abs(a - b)); k2 := frac(abs(b - c)); k3 := frac(abs(a - c)); ll := sort([k1, k2, k3]); a := ll[1]; b := ll[2]; c := ll[3]; RETURN(a, b, c) end: Simon Plouffe -------------------------------------------- I don't understand this at all. The return values are real numbers between 0 and 1, not integers. For example, in Maple 12:
L3(evalf(Pi), evalf(exp(1)), evalf(sqrt(2))); 0.304068266, 0.423310826, 0.727379092
Gene
On Tue, Sep 16, 2008 at 11:19 AM, Eugene Salamin <gene_salamin@yahoo.com> wrote:
I don't understand this at all. The return values are real numbers between 0 and 1, not integers. For example, in Maple 12:
L3(evalf(Pi), evalf(exp(1)), evalf(sqrt(2))); 0.304068266, 0.423310826, 0.727379092
Gene
Yeah, he should be keeping the integer part of the differences for the answer rather than throwing them away and returning the fractional part. This code just says "here's a lattice point near zero" without telling you the coefficients. -- Mike Stay - metaweta@gmail.com http://math.ucr.edu/~mike http://reperiendi.wordpress.com
Here is an example with sin(1),sin(2) and sin(3) (symbolic values not NUMERIC). 1230145 sin(1) - 1121529 sin(2) - 108616 sin(3) after 10 iterations : the error is 10^(-6), BUT this is a pseudo-algorithm it will find vectors but not necessarly the best ones for a precision of 0.000001 for exp(1), Pi and gamma I find : Pi - 4 exp(1) + 3 gamma + 6 is almost 0. for Pi, exp(1) and sqrt(2) I find : -122*exp(1)+71*2^(1/2)+71+51*Pi = 0.518956568491*10^(-5). which is not so bad. I presume that this very naive algorithm is just the tip of the iceberg, actualy to find approximations of the order of 10^(-100) with small coefficients is another game...! Simon Plouffe
--- Simon writes: for exp(1), Pi and gamma I find : Pi - 4 exp(1) + 3 gamma + 6 is almost 0. for Pi, exp(1) and sqrt(2) I find : -122*exp(1)+71*2^(1/2)+71+51*Pi = 0.518956568491*10^(-5). which is not so bad. --------- Nice approximations. However these solutions are not on my initial problem, because you add constants (+6 at the end of the first one, and +71 inserted in the second one). Christian.
On Tue, Sep 16, 2008 at 12:40 PM, Christian Boyer <cboyer@club-internet.fr> wrote:
--- Simon writes:
for exp(1), Pi and gamma I find :
Pi - 4 exp(1) + 3 gamma + 6 is almost 0.
for Pi, exp(1) and sqrt(2) I find :
-122*exp(1)+71*2^(1/2)+71+51*Pi = 0.518956568491*10^(-5).
which is not so bad.
---------
Nice approximations. However these solutions are not on my initial problem, because you add constants (+6 at the end of the first one, and +71 inserted in the second one).
True, but you can use this algorithm to solve yours: just divide through by, say gamma, and then solve as above. You'll get a solution A(pi/gamma) + B(e/gamma) + C ~= 0, which you can then turn into Api + Be + Cgamma ~= 0. -- Mike Stay - metaweta@gmail.com http://math.ucr.edu/~mike http://reperiendi.wordpress.com
participants (4)
-
Christian Boyer -
Eugene Salamin -
Mike Stay -
Simon Plouffe