I am trying to take a free-form input Function to create a list using NestList.
Manipulate[list2 = NestList[f, .8, 10], {f, (1/3) x^3, InputField[_, String]},
ControlType -> InputField]
Which generates this output:
{0.8, ((x^3)/3)[0.8], ((x^3)/3)[((x^3)/3)[0.8]], ((x^3)/ 3)[((x^3)/3)[((x^3)/3)[0.8]]], ((x^3)/ 3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[0.8]]]], ((x^3)/ 3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[0.8]]]]], ((x^3)/ 3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[0.8]]]]]], (( x^3)/3)[((x^3)/ 3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[0.8]]]]]]], (( x^3)/3)[((x^3)/ 3)[((x^3)/ 3)[((x^3)/ 3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[0.8]]]]]]]], ((x^3)/ 3)[((x^3)/ 3)[((x^3)/ 3)[((x^3)/ 3)[((x^3)/ 3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[0.8]]]]]]]]], ((x^3)/ 3)[((x^3)/ 3)[((x^3)/ 3)[((x^3)/ 3)[((x^3)/ 3)[((x^3)/ 3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[((x^3)/3)[0.8]]]]]]]]]]}
I would like to have a numeric output.
Answer
As I have mentioned in comment the problem is that (1/3)x^3 is not a proper function definition. Applying this to Your starting value will give You, as one can expect:
(* => (1/3)x^3 [.8]*)
Natural way is to use pure function form for it: (1/3)#^3&.
Manipulate[
list2 = NestList[f, .8, 10],
{f, (1/3) #^3 &, InputField[_]}, ControlType -> InputField]

But it does not look good in InputField, it is also not convenient to type. The following solution will fix that:
Manipulate[
list2 = NestList[f /. x -> # &, .8, 10],
{f, (1/3) x^3, InputField[_]}, ControlType -> InputField]

Comments
Post a Comment