(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 7572, 224] NotebookOptionsPosition[ 7111, 204] NotebookOutlinePosition[ 7471, 220] CellTagsIndexPosition[ 7428, 217] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"interpolation2D", "[", RowBox[{ RowBox[{ RowBox[{"data_List", "?", "MatrixQ"}], " ", "/;", RowBox[{ RowBox[{"Last", "@", RowBox[{"Dimensions", "[", "data", "]"}]}], "\[Equal]", "3"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"xmin_", ",", "xmax_", ",", RowBox[{"dx_:", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"ymin_", ",", "ymax_", ",", RowBox[{"dy_:", "1"}]}], "}"}]}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"f", ",", "neibors", ",", "data2", ",", "xi", ",", "yi"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"data2", "=", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "y", ",", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"xi_", ",", "yi_"}], "]"}], "=", "\[IndentingNewLine]", RowBox[{"Fit", "[", RowBox[{ RowBox[{"neibors", "=", RowBox[{"data", "[", RowBox[{"[", RowBox[{"Ordering", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}], "-", RowBox[{"Most", "[", "#", "]"}]}], "]"}], "&"}], " ", "/@", "data"}], ",", "6"}], "]"}], "]"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"xi", "^", "2"}], ",", RowBox[{"xi", "*", "yi"}], ",", RowBox[{"yi", "^", "2"}], ",", "xi", ",", "yi", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"xi", ",", "yi"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}], "-", RowBox[{"Most", "[", RowBox[{"neibors", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}]}], "]"}], "\[Equal]", "0"}], ",", "\[IndentingNewLine]", RowBox[{"Last", "[", RowBox[{"neibors", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}], ",", RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}]}], "]"}]}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"x", ",", "xmin", ",", "xmax", ",", "dx"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", "ymin", ",", "ymax", ",", "dy"}], "}"}]}], "]"}], "//", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"#", ",", "1"}], "]"}], "&"}]}]}], " ", ";", "\[IndentingNewLine]", RowBox[{"Interpolation", "[", "data2", "]"}]}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.4802343991025867`*^9, 3.4802344178373213`*^9}, { 3.4802344638225794`*^9, 3.4802344687757998`*^9}, {3.4857546041808133`*^9, 3.4857546451357727`*^9}, {3.485754718920328*^9, 3.4857547260300217`*^9}, { 3.4857558394705267`*^9, 3.4857558422831526`*^9}, {3.485756568659443*^9, 3.4857565798786955`*^9}, {3.4857566102706823`*^9, 3.4857566387563334`*^9}}],\ Cell[BoxData[ RowBox[{ RowBox[{"data", "=", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", RowBox[{"-", "10"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "5", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "4"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"2", ",", "3", ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "4", ",", "8"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "5", ",", "10"}], "}"}], ",", RowBox[{"{", RowBox[{"3.", ",", "1", ",", RowBox[{"-", "9"}]}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "2", ",", "6"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"3", ",", "3", ",", "90"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "12"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "5", ",", "15"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "1", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "3", ",", "12"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"4", ",", "5", ",", "20"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "2", ",", "10"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "3", ",", "15"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "5", ",", "40.5"}], "}"}]}], "}"}]}], ";"}]], "Input",\ CellChangeTimes->{{3.4802339961917524`*^9, 3.4802340273802505`*^9}, { 3.4857564153400745`*^9, 3.4857564361378813`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"f", "=", RowBox[{"interpolation2D", "[", RowBox[{"data", ",", RowBox[{"{", RowBox[{"1", ",", "5", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "5", ",", "1"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.485754658980143*^9, 3.485754660995858*^9}}], Cell[BoxData[ TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1.`", ",", "5.`"}], "}"}], ",", RowBox[{"{", RowBox[{"1.`", ",", "5.`"}], "}"}]}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]], "Output", CellChangeTimes->{3.485758064882721*^9}] }, Open ]], Cell[BoxData[ RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", "1", ",", "5"}], "}"}]}], "]"}]], "Input"] }, WindowSize->{615, 901}, WindowMargins->{{4, Automatic}, {Automatic, 1}}, ShowSelection->True, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (June 19, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[568, 21, 3714, 91, 232, "Input"], Cell[4287, 115, 1835, 49, 112, "Input"], Cell[CellGroupData[{ Cell[6147, 168, 316, 8, 31, "Input"], Cell[6466, 178, 362, 13, 30, "Output"] }, Open ]], Cell[6843, 194, 264, 8, 31, "Input"] } ] *) (* End of internal cache information *)