FindRoot
has attribute HoldAll
. Therefore FF does evaluate in a way you do not expect.
I would just use StepMonitor
. Herr a quick fix:
FF[xx1_, xx2_] := Module[
{xxx1 = xx1, xxx2 = xx2, FF1, FF2},
ClearAll[FileC];
FileC = CreateFile[];
OpenWrite[FileC];
WriteString[
FileC,
ToString[#,InputForm]& @ Sin[xxx1], "\n",
ToString[#,InputForm]& @ Cos[xxx2]
];
Close[FileC];
ClearAll[DataC];
DataC = Import[FileC, "Table"];
ClearAll[FF1, FF2];
FF1 = xxx1*DataC[[1, 1]];
FF2 = xxx2*DataC[[2, 1]];
{FF1, FF2}
];
FindRoot[{Sin[x1], Cos[x2]} == {0., 0.}, {{x1, Pi/4}, {x2, Pi/4}},
StepMonitor :> (Print["Step to x1 = ", x1, " x2: ", x2]; FF[x1, x2])
]
FilePrint @ FileC