Mathematica: Parabolic Fit using Predefined Program and ErrorBarPlots Module

  • Context: Mathematica 
  • Thread starter Thread starter Hoiya
  • Start date Start date
  • Tags Tags
    Fit Mathematica
Click For Summary
SUMMARY

The discussion focuses on performing a parabolic fit using Mathematica with the ErrorBarPlots module. The user encounters an error related to matrix inversion due to the poorly conditioned matrix generated from their data. The matrix inversion results in significant numerical errors, as indicated by the disparity between the largest and smallest singular values. The issue is inherent to the matrix properties rather than a flaw in Mathematica itself.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of matrix operations and conditions
  • Knowledge of parabolic fitting techniques
  • Experience with error analysis in data fitting
NEXT STEPS
  • Explore Mathematica's SingularValueList function for matrix analysis
  • Learn about matrix conditioning and its impact on numerical precision
  • Investigate alternative fitting methods in Mathematica
  • Study error propagation techniques in data analysis
USEFUL FOR

Data scientists, mathematicians, and researchers involved in statistical modeling and data fitting using Mathematica.

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 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 4 ·
Replies
4
Views
4K