Wolfram mathematica 隐式函数的FindFit-mathematica

Wolfram mathematica 隐式函数的FindFit-mathematica,wolfram-mathematica,implicit,test-data,Wolfram Mathematica,Implicit,Test Data,我想将一些测试数据拟合到一些隐式函数中 我想将一些参数拟合到一个光学方程f(x,y)=a,其中a是一个已知变量。我的测试数据和函数更复杂,但是我得到的数据点比变量多。不可能将我想要拟合的方程转换成显式形式,如f(x)=y,因此我附加了一些代码来获得基本思想 Test = {{0, 1}, {0.1, 0.9}, {1.1, 0}}; Ftest = a*x^2 + b*y^2 FindFit[Test, Ftest == 2, {a, b}, {x, y}]; 但是,这会导致一个错误:坐标

我想将一些测试数据拟合到一些隐式函数中

我想将一些参数拟合到一个光学方程f(x,y)=a,其中a是一个已知变量。我的测试数据和函数更复杂,但是我得到的数据点比变量多。不可能将我想要拟合的方程转换成显式形式,如f(x)=y,因此我附加了一些代码来获得基本思想

Test = {{0, 1}, {0.1, 0.9}, {1.1, 0}};

Ftest = a*x^2 + b*y^2

FindFit[Test, Ftest == 2, {a, b}, {x, y}];
但是,这会导致一个错误:坐标数(1)不等于变量数\
(2). >>

您可以将其设置为最小二乘最小化:

data = {{0, 1}, {0.1, 0.9}, {1.1, 0}}
Ftest[x_, y_] := a*x^2 + b*y^2
fit = FindMinimum[ Total[(Ftest @@@ data - 2)^2] , {a, b}] 
ContourPlot[ (Ftest[x, y] /. fit[[2]]) == 2 , {x, 0, 1.5}, {y, 0, 
  1.5}, Epilog -> {Red, Point /@ data}]

要使用拟合函数,需要求解y,最终得到:

fit = NonlinearModelFit[data, Sqrt[2 - a*x^2]/Sqrt[b], {a, b}, x]

Plot[fit[x], {x, 0, 1.2}, Epilog -> {Red, Point /@ data}, 
 AspectRatio -> 1]