Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16541
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Goodstein expansion |
| Date | 2014-02-09 09:39 +0000 |
| Message-ID | <ld7icf$e58$1@smc.vnet.net> (permalink) |
| References | <20140208090230.178B569E8@smc.vnet.net> |
| Organization | Time-Warner Telecom |
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@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.
>
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar
Re: Goodstein expansion Bob Hanlon <hanlonr357@gmail.com> - 2014-02-09 09:39 +0000
csiph-web