As shown below, I have written code to find the numerical solution of the equation for an arbitrary number of variables.
variableN = 3;
solveEquations[a_] := Module[
{x}
,
Table[x[i], {i, 0, variableN}] /. FindRoot[
Catenate[
{
{x[0] == 1}
, Table[x[i] == Gamma[a, x[i - 1]], {i, 1, variableN}]
}
]
, Table[{x[i], 1}, {i, 0, variableN}]
]
]
The calculations in the code are trivial, but the actual system I want to solve is much more complex.
Anyway, the code works fine for most inputs.
In[304]:= {solveEquations[1], solveEquations[2]}
Out[304]= {{1., 0.367879, 0.692201, 0.500474}, {1., 0.735759,
0.831674, 0.797364}}
However, errors are acquired for certain inputs.
In[3]:= solveEquations[1.]
During evaluation of In[3]:= FindRoot::nlnum: The function value {0.,1. -1. 2.71828^(-1. x$4490[0.]),1. -1. 2.71828^(-1. x$4490[1.]),1. -1. 2.71828^(-1. x$4490[2.])} is not a list of numbers with dimensions {4} at {x$4490[0],x$4490[1],x$4490[2],x$4490[3]} = {1.,1.,1.,1.}.
(omitted)
Out[3]= {x$4490[0], x$4490[1], x$4490[2], x$4490[3]} /.
FindRoot[
Catenate[{{x$4490[0] == 1},
Table[x$4490[i] == Gamma[1., x$4490[i - 1]], {i, 1, variableN}]}],
Table[{x$4490[i], 1}, {i, 0, variableN}]]
After investigating the cause, I found that if the first argument of the incomplete gamma function is 1. , the contents of [] in the second argument are also converted to real numbers.
In[6]:= {Gamma[2., x[0]], Gamma[1., x[0]]}
Out[6]= {Gamma[2., x[0]], E^-x[0.]}
The error occurs since x[0] and x[0.] are different.
Is this result inevitable? or
is there any good solution?
Thanks,