Re: RowReduce::luc when using NSolve
- To: mathgroup at smc.vnet.net
- Subject: [mg99171] Re: [mg99135] RowReduce::luc when using NSolve
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Wed, 29 Apr 2009 06:05:26 -0400 (EDT)
- References: <200904280844.EAA28589@smc.vnet.net>
mereandor wrote:
> I try to solve a linear equation with the following input to mathematica:
>
> NSolve[{BesselJ[0, 20] - BesselJ[0, 20] r[0] == 3 I BesselJ[0, 60 I] t[0], BesselJ[0, 20] + BesselJ[0, 20] r[0] == BesselJ[0, 60 I] t[0]}, {r[0], t[0]}]
>
> but I get
>
> RowReduce::luc: Result for RowReduce of badly conditioned matrix \
> {{-0.167025+0. I,-1.61061*10^9-<<21>> I,0.167025+0. I},{<<1>>}} may \
> contain significant numerical errors. >>
>
> This is only the simplest instance of my problem (2(n+1) equations in equally numbered variables). If I don't write the equations down literally but insert them into NSolve as a Table[] statement I don't even get the warning. Then the equations are solved only partially expressing t[n] as linear combination of r[n].
>
> I use Mathematica 6.0
>
> How can I resolve this?
>
> Thanks in advance for any help!
The input is ill conditioned from the point of view of numeric linear
algebra.
Your coefficient matrix is, up to sign,
coeffmat = {{BesselJ[0,20],3*I*BesselJ[0,60*I]},
{-BesselJ[0,20],BesselJ[0,60*I]}};
At machine precision, the second singular value is sufficiently smaller
than the first as to make condition number effectively infinite.
In[21]:= InputForm[SingularValueList[N[coeffmat]]]
Out[21]//InputForm= {1.863870820026589*^25}
An exact computation (or using smaller tolerance in the machine
arithmetic) confirms this.
In[22]:= InputForm[N[SingularValueList[coeffmat]]]
Out[22]//InputForm=
{1.863870820026589*^25 - 1.697734891411824*^9*I,
0.16702466434058325 - 3.0814879110195774*^-33*I}
This shows the condition number to be around 10^26, far too large to
guarantee any accurate digits at machine precision.
One way around the problem would be to specify higher WorkingPrecision
for NSolve. How high can be a matter of trial and error. Since we
already know the condition number ballpark, we'll just use something
around 3 times that large (this is more than sufficient).
In[24]:= InputForm[NSolve[{BesselJ[0,20] - BesselJ[0,20]*r[0] ==
3*I*BesselJ[0,60*I]*t[0],
BesselJ[0,20] + BesselJ[0,20]*r[0] == BesselJ[0,60*I]*t[0]},
{r[0], t[0]}, WorkingPrecision->80]]
Out[24]//InputForm=
{{r[0] ->
-0.7999999999999999999999999999999999999999999999999999999999999999\
99999999999999999999999999595998`79.69897000433602 -
0.60000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000164508`79.69897000433602*I,
t[0] ->
5.66754261149722224656310043127626802663146216598465500176280137045\
12841969591052271352247`79.69897000433602*^-27 -
1.70026278344916667396893012\
93828804079894386497953965005288404111353852590877315681405674`79.69897000433\
602*^-26*I}}
Daniel Lichtblau
Wolfram Research
- References:
- RowReduce::luc when using NSolve
- From: mereandor <mereandor@gmail.com>
- RowReduce::luc when using NSolve