Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2014

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Goodstein expansion

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132323] Re: Goodstein expansion
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Sun, 9 Feb 2014 04:48:26 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20140208090230.178B569E8@smc.vnet.net>

Clear[baseForm, goodsteinForm]


baseForm[n_Integer?NonNegative, b_Integer: 2] :=
 Module[{id = IntegerDigits[n, b]},
   id.(HoldForm[b^#] & /@
      Range[Length[id] - 1, 0, -1])] /;
  2 <= b <= 36


goodsteinForm[n_Integer?NonNegative, b_Integer: 2] :=
 Module[{id = IntegerDigits[n, b]},
   id.(HoldForm[b^#] & /@
      (baseForm[#, b] & /@
        Range[Length[id] - 1, 0, -1]))] /;
  2 <= b <= 36



n = 87;
b = 2;


baseForm[n, b]


HoldForm[2^0] + HoldForm[2^1] +
   HoldForm[2^2] + HoldForm[
     2^4] + HoldForm[2^6]


n == % // ReleaseHold


True


goodsteinForm[n, b]


HoldForm[2^0] + HoldForm[
     2^HoldForm[2^0]] +
   HoldForm[2^HoldForm[2^1]] +
   HoldForm[2^HoldForm[2^2]] +
   HoldForm[2^(HoldForm[2^1] +
          HoldForm[2^2])]


Because HoldForm is nested in goodsteinForm, ReleaseHold must be called
twice. (I consider this an "unexpected" behavior of ReleaseHold.)


n == % // ReleaseHold // ReleaseHold


True



b = 5;


baseForm[n, b]
2*HoldForm[5^0] +
   2*HoldForm[5^1] +
   3*HoldForm[5^2]


n == % // ReleaseHold


True


goodsteinForm[n, b]


2*HoldForm[5^0] +
   2*HoldForm[5^HoldForm[5^0]] +
   3*HoldForm[
       5^(2*HoldForm[5^0])]


n == % // ReleaseHold // ReleaseHold


True



Bob Hanlon




On Sat, Feb 8, 2014 at 4:02 AM, Brambilla Roberto Luigi (RSE) <
Roberto.Brambilla at rse-web.it> wrote:

>
> The Goodstein expansion of integers  (see for instance  Stillwell," Roads
> to Infinity", pag.47)
>
> Given an integer n we can write it as sum of powers of  2
>
> 87=2^6+2^4+2^2+1=2^(2^2+2)+2^(2^2)+2^2+2^0
>
> More generally assuming an integer b as a base, we can write  n as a sum
> of power of b with coefficients <b
> es.:  b=5
>
> 87=3*5^2+2*5^1+2*5^0.
>
> I can do it by means of a long and obvious routine with lots  of  If[]
>  and While[].
> May be someone can do it by means of the recursive properties of
> Mathematica language?
> Many thanks to all the friends of this group!
> Roberto
>
>
>
>
>
> RSE SpA ha adottato il Modello Organizzativo ai sensi del D.Lgs.231/2001,
> in=
>  forza del quale l'assunzione di obbligazioni da parte della Societ=E0
> avvie=
> ne con firma di un procuratore, munito di idonei poteri.
> RSE adopts a Compliance Programme under the Italian Law (D.Lgs.231/2001).
> Ac=
> cording to this RSE Compliance Programme, any commitment of RSE is taken
> by=
>  the signature of one Representative granted by a proper Power of
> Attorney.=
>  Le informazioni contenute in questo messaggio di posta elettronica sono
> ris=
> ervate e confidenziali e ne e' vietata la diffusione in qualsiasi modo o
> for=
> ma. Qualora Lei non fosse la persona destinataria del presente messaggio,
> La=
>  invitiamo a non diffonderlo e ad eliminarlo, dandone gentilmente
> comunicazi=
> one al mittente. The information included in this e-mail and any
> attachments=
>  are confidential and may also be privileged. If you are not the correct
> rec=
> ipient, you are kindly requested to notify the sender immediately, to
> cancel=
>  it and not to disclose the contents to any other person.
>
>
>




  • References:
  • Prev by Date: Re: Embedding CDF in a Google Spreadsheet Form
  • Next by Date: Re: Goodstein expansion
  • Previous by thread: Goodstein expansion
  • Next by thread: Re: Goodstein expansion