Solving non-linear equations - not enough input arguments

16 visualizaciones (últimos 30 días)
LuC
LuC el 24 de Mayo de 2016
Comentada: John D'Errico el 24 de Mayo de 2016
Hello,
I have some data that I approximated with a polynomial of degree 9, p(x), and I have a non-linear function (with unknown coefficients that is supposed to fit the data). I found a Taylor series of that function, ts(x). In order to find the coefficients, I would like to solve the system p(x) = ts(x).
function f = ts1( x )
% Taylor series expansion
A = 70.94;
B = x(1);
C = x(2);
D = x(3);
E = x(4);
%system of equations
f(1) = B*C*D - 1161; % x^1
f(2) = -D*(C*((B^3*E)/3 + B^3/3) + (B^3*C^3)/6) - 22.21; % x^3
f(3) = D*(C*((14*B^5*E)/45 + B*((2*B^4*E)/9 + B^4/5)) + (B^2*C^3*((B^3*E)/3 + B^3/3))/6 + B*C*((B^4*C^4)/120 + (B*C^2*((B^3*E)/3 + B^3/3))/3)) + 0.2839; % x^5
f(4) = -D*(C*(B*((2*B^6*E)/15 + ((4*B^7*E^2)/9 + (8*B^7*E)/5)/(12*B) + B^2*((2*B^4*E)/15 + B^4/7)) + (22*B^7*E)/105 + (B^3*E*((2*B^4*E)/9 + B^4/5))/3) +...
C*((B^3*E)/3 + B^3/3)*((B^4*C^4)/120 + (B*C^2*((B^3*E)/3 + B^3/3))/3) + (B^2*C^3*((14*B^5*E)/45 + B*((2*B^4*E)/9 + B^4/5)))/6 + B*C*((B^3*C^4*((B^3*E)/3 + ...
B^3/3))/60 + B^2*C^2*((B^4*C^4)/5040 + (B*C^2*((B^3*E)/3 + B^3/3))/60) + (4*B*C^3*((B^3*E)/3 + B^3/3)^2 + 8*B^2*C^3*((14*B^5*E)/45 + B*((2*B^4*E)/9 + B^4/5)))/(24*B*C))) - 0.001837; % x^7
f(5) = D*(C*((10*B^9*E)/63 + B*(((4*B^9*E^2)/5 + (12*B^9*E)/7)/(18*B) + B^2*((2*B^6*E)/21 + ((4*B^7*E^2)/9 + (8*B^7*E)/5)/(20*B) + B^2*((2*B^4*E)/21 + B^4/9)) + (B*((4*B^7*E^2)/9 + (8*B^7*E)/5))/20 +...
(2*B^4*E*((2*B^4*E)/15 + B^4/7))/3) + (B^3*E*((2*B^6*E)/15 + ((4*B^7*E^2)/9 + (8*B^7*E)/5)/(12*B) + B^2*((2*B^4*E)/15 + B^4/7)))/3 + (B^5*E*((2*B^4*E)/9 + B^4/5))/5) + B*C*((B*C*(4*B*C^3*((B^3*E)/3 + ...
B^3/3)^2 + 8*B^2*C^3*((14*B^5*E)/45 + B*((2*B^4*E)/9 + B^4/5))))/480 + (12*B^2*C^3*(B*((2*B^6*E)/15 + ((4*B^7*E^2)/9 + (8*B^7*E)/5)/(12*B) + B^2*((2*B^4*E)/15 + B^4/7)) + (22*B^7*E)/105 + (B^3*E*((2*B^4*E)/9 + B^4/5))/3) + ...
12*B*C^3*((B^3*E)/3 + B^3/3)*((14*B^5*E)/45 + B*((2*B^4*E)/9 + B^4/5)))/(36*B*C) + B^2*C^2*((B^3*C^4*((B^3*E)/3 + B^3/3))/2520 + B^2*C^2*((B^4*C^4)/362880 + (B*C^2*((B^3*E)/3 + B^3/3))/2520) + (4*B*C^3*((B^3*E)/3 + B^3/3)^2 + ...
8*B^2*C^3*((14*B^5*E)/45 + B*((2*B^4*E)/9 + B^4/5)))/(480*B*C)) + 2*B*C^2*((B^3*E)/3 + B^3/3)*((B^4*C^4)/5040 + (B*C^2*((B^3*E)/3 + B^3/3))/60)) + C*((B^3*E)/3 + B^3/3)*((B^3*C^4*((B^3*E)/3 + B^3/3))/60 + ...
B^2*C^2*((B^4*C^4)/5040 + (B*C^2*((B^3*E)/3 + B^3/3))/60) + (4*B*C^3*((B^3*E)/3 + B^3/3)^2 + 8*B^2*C^3*((14*B^5*E)/45 + B*((2*B^4*E)/9 + B^4/5)))/(24*B*C)) + (B^2*C^3*(B*((2*B^6*E)/15 + ((4*B^7*E^2)/9 + (8*B^7*E)/5)/(12*B) + ...
B^2*((2*B^4*E)/15 + B^4/7)) + (22*B^7*E)/105 + (B^3*E*((2*B^4*E)/9 + B^4/5))/3))/6 + C*((B^4*C^4)/120 + (B*C^2*((B^3*E)/3 + B^3/3))/3)*((14*B^5*E)/45 + B*((2*B^4*E)/9 + B^4/5))) + 4.552e-06; % x^9
end
My main looks like this:
x0 = [-0.0095, 0.0014, 4.0000, 0.0165];
f = solve(@ts1, x0, options)
and the error is:
Error using ts1 (line 5)
Not enough input arguments.
Error in sym>funchandle2ref (line 1211)
S = sym(x());
Error in sym>tomupad (line 1114)
x = funchandle2ref(x);
Error in sym (line 151)
S.s = tomupad(x);
Error in solve>getEqns (line 410)
a = formula(sym(a));
Error in solve (line 227)
[eqns,vars,options] = getEqns(varargin{:});
  1 comentario
ashish ahir
ashish ahir el 24 de Mayo de 2016
Please simplify your question, Make it more readable and understandable,

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 24 de Mayo de 2016
The way you’ve written your code, I believe you want the fsolve function instead.
Try this:
f = fsolve(@ts1, x0, options)
  1 comentario
John D'Errico
John D'Errico el 24 de Mayo de 2016
Definitely the case. Anyway, solve would surely fail to find a solution, though vpasolve might succeed.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Communications Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by