Re: Lists of equations. Again
- To: mathgroup at smc.vnet.net
- Subject: [mg56365] Re: Lists of equations. Again
- From: Maxim <ab_def at prontomail.com>
- Date: Fri, 22 Apr 2005 06:25:47 -0400 (EDT)
- References: <d45arr$ijq$1@smc.vnet.net> <d47snc$53h$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
FindRoot[{x, y}, {x, 1}, {y, 1}] and FindRoot[{x, y}, {{x, 1}, {y, 1}}]
work exactly the same way -- there are no syntax errors in either of them.
If you read the documentation on FindRoot (in Built-in Functions)
carefully, you'll see that the last example there is FindRoot[{x^2 + y^2
== 1, y == x*Exp[x]}, {x, 0.1}, {y, 0.5}] -- the same syntax as I used.
The main concern is equations with vector variables, e.g.
FindRoot[{x == 1, y == {2, 3}}, {x, 0}, {y, {0, 0}}]
doesn't work (this time failing with FindRoot::nlnum message, and
supplying the jacobian doesn't help here) but
FindRoot[{x, y} == {1, {2, 3}}, {x, 0}, {y, {0, 0}}]
works without a problem. As you can see, in this case it is impossible to
thread Equal over lists as you suggest (and threading over y == {2, 3}
would be clearly wrong).
Maxim Rytin
m.r at inbox.ru
On Thu, 21 Apr 2005 09:45:16 +0000 (UTC), dh <dh at metrohm.ch> wrote:
> Hi Maxim,
> the problem is that your expression has syntax errors.
> 1) It look like FindRoot does not like tensor equations. You must expand
> the equations like e.g.:
> eq=MapThread[Equal,{Array[a, {2, 2}],IdentityMatrix[2]},2];
> 2) The second argument to FindRoot must contain a list of variables and
> start values. Sequence[..] is not a list. E.g. wrap your expression in a
> list:
> var={Sequence @@ (Flatten[#, 1] &)@Array[{a[##], 0} &, {2, 2}]}
>
> This then finally works:
> FindRoot[eq,var]
>
> Sincerely, Daniel
>
> Maxim wrote:
>> In version 5.0 FindRoot[{{x, y} == {1, 1}}, {x, 2}, {y, 2}] failed: it
>> complained about the non-numerical jacobian and just returned the
>> starting
>> point. This now works in version 5.1; however, there is still exactly
>> the
>> same problem with higher-dimensional lists:
>>
>> FindRoot[Array[a, {2, 2}] == IdentityMatrix[2],
>> Evaluate[Sequence@@ (Flatten[#, 1]&)@ Array[{a[##], 0}&, {2, 2}]]]
>>
>> This generates Thread::tdlen and FindRoot::njnum messages, indicating
>> that
>> there is again something wrong with the processing of lists. Strangely,
>>
>> FindRoot[Array[a, {2, 2}] - IdentityMatrix[2],
>> Evaluate[Sequence@@ (Flatten[#, 1]&)@ Array[{a[##], 0}&, {2, 2}]]]
>>
>> works without a problem (another possible way to resolve this issue is
>> to
>> specify Jacobian -> IdentityMatrix[4]).
>>
>> If the specified form of the jacobian doesn't have the correct
>> structure,
>> this often results in the kernel crash:
>>
>> FindRoot[x == {1, 2}, {x, {0, 0}}, Jacobian -> {{{1}, {1}}}]
>> (*crashes the kernel*)
>>
>> This may happen even if the structure is correct:
>>
>> FindMinimum[x^2, {x, 1},
>> Method -> {Newton, Hessian -> {{2}}}]
>> (*crashes the kernel*)
>>
>> Here the hessian is specified correctly, but unless the gradient is also
>> given explicitly as Gradient -> {2x}, all the other settings (Automatic,
>> Symbolic, FiniteDifference) lead to the kernel crash.
>>
>> Maxim Rytin
>> m.r at inbox.ru
>>
>