help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non linear equations: howto?


From: Søren Hauberg
Subject: Re: Non linear equations: howto?
Date: Sun, 19 Oct 2008 15:54:22 +0200

søn, 19 10 2008 kl. 15:30 +0200, skrev Fabrice DELENTE:
> 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

So, here x is a 5-vector.

> [x,info]=fsolve("f",[-10;10])

As a starting guess you use [-10; 10] which is a 2-vector. Your starting
guess should be a 5-vector, otherwise things just don't add up.

Søren




reply via email to

[Prev in Thread] Current Thread [Next in Thread]