Non linear equations: howto?
Fabrice DELENTE
fdelente at mail.cpod.fr
Sun Oct 19 08:30:14 CDT 2008
Hello.
I'd like to solve numerically 6 equations like
f(1)=0
f(2)=2
f(3)=3
f(4)=4
f(5)=2.5
f(6)=-4
where f(x) is defined by
f(x)=(a*x+b)*exp(c*x+d)+e
a, b, c, d and e being the unknowns of my system.
I tried using octave with these commands:
function y = f (x)
y(1) = (x(1)*1+x(2))*exp(x(3)*1+x(4))+x(5)
y(2) = (x(1)*2+x(2))*exp(x(3)*2+x(4))+x(5)-1
y(3) = (x(1)*3+x(2))*exp(x(3)*3+x(4))+x(5)-3
y(4) = (x(1)*4+x(2))*exp(x(3)*4+x(4))+x(5)-4
y(5) = (x(1)*5+x(2))*exp(x(3)*5+x(4))+x(5)-2.5
y(6) = (x(1)*6+x(2))*exp(x(3)*6+x(4))+x(5)+4
endfunction
[x,info]=fsolve("f",[-10;10])
but octave answers
error: invalid vector index = 3
error: evaluating binary operator *' near line 2, column 32
error: evaluating binary operator +' near line 2, column 34
error: evaluating argument list element number 1
error: evaluating binary operator *' near line 2, column 23
error: evaluating binary operator +' near line 2, column 40
error: evaluating assignment expression near line 2, column 8
error: called from f'
error: fsolve: evaluation of user-supplied function failed
How can I give a vector size? Is octave a good tool for solving this kind of
problem? Do you know of any tool that would do the job?
Thanks!
--
Fabrice DELENTE
More information about the Help-octave
mailing list