Mathematica Mathematica: Parabolic Fit using Predefined Program and ErrorBarPlots Module

  • Thread starter Thread starter Hoiya
  • Start date Start date
  • Tags Tags
    Fit Mathematica
Click For Summary
The discussion centers on an error encountered while performing a parabolic fit using a predefined program in Mathematica, specifically related to matrix inversion. The user is attempting to invert a matrix derived from their data, but receives a warning about significant numerical errors due to the matrix being badly conditioned. The largest singular value is noted to be significantly larger than the smallest, indicating potential precision loss during inversion. This issue is attributed to the characteristics of the matrix rather than a fault in Mathematica itself. The conversation highlights the importance of understanding matrix properties when performing numerical computations.
Hoiya
Messages
2
Reaction score
0
I'm using a predefinied program... but I don't know because give me this error:

Clear["Global`*"]

Remove["Global`*"]

<< "ErrorBarPlots`"


xdata = {180, 200, 220, 240, 260, 280, 300, 320, 340, 360}

{180, 200, 220, 240, 260, 280, 300, 320, 340, 360}


ax = First[xdata]

180

bx = Last[xdata]

360

apx = 2./(bx - ax)

0.0111111

bpx = (bx + ax)/(bx - ax)

3

xdata1 = xdata*apx - bpx

{-1., -0.777778, -0.555556, -0.333333, -0.111111, 0.111111, 0.333333, \
0.555556, 0.777778, 1.}


xdata1 = xdata

{180, 200, 220, 240, 260, 280, 300, 320, 340, 360}


ydata1 = {13.8, 16.3, 18.2, 19.7, 20.4, 20.4, 19.8, 18.7, 17, 15}

{13.8, 16.3, 18.2, 19.7, 20.4, 20.4, 19.8, 18.7, 17, 15}


s = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}

{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}


numpt = 10

10


matD = {{Sum[1/(s[])^2, {i, numpt}],
Sum[xdata1[]/(s[])^2, {i, numpt}],
Sum[(xdata1[])^2/(s[])^2, {i, numpt}]}, {Sum[
xdata1[]/(s[])^2, {i, numpt}],
Sum[(xdata1[])^2/(s[])^2, {i, numpt}],
Sum[(xdata1[])^3/(s[])^2, {i,
numpt}]}, {Sum[(xdata1[])^2/(s[])^2, {i, numpt}],
Sum[(xdata1[])^3/(s[])^2, {i, numpt}],
Sum[(xdata1[])^4/(s[])^2, {i, numpt}]}}

{{999.9999999999999`, 269999.99999999994`,
7.619999999999999`*^7}, {269999.99999999994`, 7.619999999999999`*^7,
2.2355999999999996`*^10}, {7.619999999999999`*^7,
2.2355999999999996`*^10, 6.777167999999999`*^12}}

MatrixForm[matD]

\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"999.9999999999999`", "269999.99999999994`", "7.619999999999999`*^7"},
{"269999.99999999994`", "7.619999999999999`*^7",
"2.2355999999999996`*^10"},
{"7.619999999999999`*^7", "2.2355999999999996`*^10",
"6.777167999999999`*^12"}
},
GridBoxAlignment->{
"Columns" -> {{Center}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]},
Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset[0.2], {
Offset[0.4]},
Offset[0.2]}, "RowsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$,
MatrixForm[BoxForm`e$]]]\)


matDinver = Inverse[matD]

Inverse::luc: Result for Inverse of badly conditioned matrix {{1000.,270000.,7.62*10^7},{270000.,7.62*10^7,2.2356*10^10},{7.62*10^7,2.2356*10^10,6.77717*10^12}} may contain significant numerical errors. >>

{{0.5965, -0.00453068, 8.23864*10^-6}, {-0.00453068,
0.0000348201, -6.39205*10^-8}, {8.23864*10^-6, -6.39205*10^-8,
1.18371*10^-10}}

can anybody help me?
 
Physics news on Phys.org
If you do SingularValueList[matD] you see that your largest singular value is 6.8E12 and the smallest is 1.7E0. So a matrix inversion can be expected to lose about 12 digits of precision. This isn't an issue with Mathematica, it is a feature of the matrix itself.
 

Similar threads

  • · Replies 18 ·
Replies
18
Views
5K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K