Re: Euclidean Algorithm in Mathematica



Well, thanks!

I need a slighty different example.

I would like to call the first two remainders within
a new function without defining the variables
alpha and beta outside first.

So I don't want to have this line first
{alpha, beta} = myRemainders[12, 7]

but something of the shape
g[a, b] = alpha + beta where
alpha is the first entry of the result of
myRemainders[a, b] and beta the second one.

Many thanks,
Nena

Jean-Marc Gulliet wrote:

Nena wrote:
Excellent! Thanks!

Just one little alternation.
Let alpha and beta be the first two remainders with
the condition that they are both less than the square root
of a. And also alpha > beta.

How can I list alpha and beta separately?
So that I can treat alpha and beta as variables for further
manipulations. For example to calculate
g[alpha_, beta_] := alpha^2 + beta^2

For example

In[1]:=
Remainder[a_, b_] := a - Quotient[a, b]*b
Remainder[a_, 0] := 0
myRemainders[a_, b_] := Module[{lst},
lst = FixedPointList[{Last[#1], Remainder @@ #1} &, {a, b}];
Select[lst, #1[[2]] < Sqrt[a] &, 2][[All, 2]]]

In[4]:=
{alpha, beta} = myRemainders[12, 7]

Out[4]=
{2,1}

In[5]:=
alpha

Out[5]=
2

In[6]:=
beta

Out[6]=
1

In[7]:=
alpha^2 + beta^2

Out[7]=
5

Regards,
Jean-Marc

.



Relevant Pages

  • Re: Euclidean Algorithm in Mathematica
    ... How can I manage to take hold of alpha and beta ... So what you are looking for is the second column (where the remainders are stored) of the second and third elements of the list (the first element is just the pair of initial values ...
    (sci.math.symbolic)
  • Re: Euclidean Algorithm in Mathematica
    ... And also alpha> beta. ... I'm looking for the first two remainders which appear in the ... Euclidean Algorithm *and* are less than the square-root of the ...
    (sci.math.symbolic)
  • I forget the Induction Joke ...
    ... Drama in one act with 4 characters: The Grand Alpha, The Grand Beta, ... The Grand Omicron, and The Candidate. ... Please define a compact set. ...
    (rec.org.mensa)
  • Re:Re: Alpha, beta, ....
    ... Firefox 3 was done at alpha 3 (when i never hit a bug again and it pa? ... hanges to beta 1. ... I for one was happy to see Firefox 3 as in 7.10, ... There must be a different than gnash tool to play swf as I don't have gnash? ...
    (Ubuntu)
  • Re: The Dangerous Liberty of Engineering vs. Lukewarm Dominionism
    ... with alpha, beta, and gamma also part of a smooth mani- ... violates CPT invariance, ...
    (sci.space.policy)