Hi All,
I have the following example FindRoot function as part of a Nest function.
Clear[del]
del[x_] := Module[{y, dP, res, OP},
res := {y} /. FindRoot[y^2 + 2 y - x, {y, 0}];
OP := res[[1]];
dP := OP + 1;
Nest[(# + dP/#)/2 &, 1.5, 2]
]
del[name] /. name -> 3
Mathematica doesn't recognise the "name" symbol and returns the following error:
"FindRoot::nlnum: The function value {0. -1. name} is not a list of numbers with dimensions {1} at {y$21486} = {0.}.
ReplaceAll::reps: {FindRoot[y$21486^2+2 y$21486-name,{y$21486,0}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing."
If you set Nest to apply zero times or replace it with a function that doesn't repeat the code works fine. It also works if you replace FindRoot with a simple assignment for symbol "OP". However, it doesn't work if you use Solve instead of FindRoot. Can anyone shine any light on this?
Many thanks for any help.
Attachments: