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!
eqn = {
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]};
FindRoot[eqn,
{{r[0], 5}, {t[0], 3}}, WorkingPrecision -> 30]
{r[0] -> -0.8000000000000000000000000000000000000000000000000000000301`30. -
0.6000000000000000000000000000000000000000000000000000000222`30.*I,
t[0] -> 5.66754261149722224656310043127626802663146216598467`30.*^-27 -
1.700262783449166673968930129382880407989438649795398`30.*^-26.\
700262783449166673968930129382880407989438649795398`30.**I}
soln = FindRoot[eqn,
{{r[0], -0.8 - 0.6 I}, {t[0], 0}}]
{r(0)->-0.8-0.6 I,t(0)->5.66754*10^-27-1.70026*10^-26 I}
eqn /. soln
{True,True}
Bob Hanlon
---- mereandor <mere...@gmail.com> wrote:
=============
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
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 -> 30]
?
Regards
Jens
Hi,
look at the order of magnitude of your coefficients and you will see
where the problem comes from.
However, why do you want to calculate with approximate numbers (using
NSolve) if you have an accurate input.
Simply use Solve and you will get an accurate result.
Daniel