"news.neostrada.pl" <guru59622cfr34ff@hotmail.com> wrote in message <gld0td$3oh$1@atlantis.news.neostrada.pl>...
> Sorry for my language mistakes  It's not my mother language.
>
> I try to write script which find roots of this equation
> f(H)=Q(and there is http://en.wikipedia.org/wiki/Manning_formula)
> using http://en.wikipedia.org/wiki/Secant_method
>
> So I input Q and other constants and I want find H.
> Unfortunately, it's result in COMPLEX numbers.
> What's wrong?
>
> ====================
> function [h]=glebokosc_norm(Q,s,n,B,M,H)
> R=((B*H+M*(H.^2))./(B+2.*H.*((1+(M.^2)).^(1./2)))).^(2./3);
> A=B.*H+M.*(H.^(1./2));
> Q_oblicz=(s.^0.5).*A.*R./n;
> h=QQ_oblicz;
> ===================
> Q=input('Podaj wydatek Q= ');
> s=input('Podaj spadek linii energii s= ');
> M=input('Podaj nachylenie skarp M= ');
> B=input('Podaj szeroko
You are getting complex values because somewhere you are taking either the 1/2 power or the 2/3 power of a negative number. Better check each stage of your computation to find out where this is occurring.
Roger Stafford
