Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3625

Re: sequence of functions

From Albert Retey <awnl@gmx-topmail.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: sequence of functions
Date 2011-07-09 11:42 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iv9erd$dfk$1@smc.vnet.net> (permalink)
References <iv6hbv$sau$1@smc.vnet.net>

Show all headers | View raw


Am 08.07.2011 11:07, schrieb rych:
> I would like to build a function sequence inductively, for example
> f[n][x]=f[n-1][2x]+f[n-1][2x-1], f[0][x] = x(1-x)
>
> This is what I tried in Mathematica,
>
> ClearAll["Global`*"]
> f[n_] = Function[x, Simplify[f[n - 1][2 x] + f[n - 1][2 x - 1]]];
> f[0] = Function[x, x (1 - x)];
>
> f[2][x]
> Out:
> -20 + 64 x - 64 x^2
>
> ?f
> Out:
> Global`f
> f[0]=Function[x,x (1-x)]
> f[n_]=Function[x,Simplify[f[n-1][2 x]+f[n-1][2 x-1]]]
>
> My questions: it doesn't seem to cache the previous f[n-1] etc? If I
> do it this way instead,
> f[n_] := f[n] = Function[...
>
> Then it does cache the f[n-1] etc. but still in the unevaluated form,
> Global`f
> f[0]=Function[x,x (1-x)]
> f[1]=Function[x$,Simplify[f[1-1][2 x$]+f[1-1][2 x$-1]]]
> f[2]=Function[x$,Simplify[f[2-1][2 x$]+f[2-1][2 x$-1]]]
> f[n_]:=f[n]=Function[x,Simplify[f[n-1][2 x]+f[n-1][2 x-1]]]
>
> How do I force the reduction so that I see f[1] = -2 (1 - 2 x)^2, etc.
> in the definitions?

I think this is what you want:

ClearAll["Global`*"]
f[n_] := f[n] = Block[{x},
     Function @@ {{x}, Simplify[f[n - 1][2 x] + f[n - 1][2 x - 1]]}
     ];
f[0] = Function[x, x (1 - x)];

hth,

albert

Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

sequence of functions rych <rychphd@gmail.com> - 2011-07-08 09:07 +0000
  Re: sequence of functions "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-07-09 11:38 +0000
  Re: sequence of functions Albert Retey <awnl@gmx-topmail.de> - 2011-07-09 11:42 +0000

csiph-web