| Eduardo Morras on Sun, 14 Apr 2019 09:57:00 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Muller implementation don't know where is the problem |
Hello, I'm trying to implement muller root finding algorithm but I get this error
? \r muller.gp
*** syntax error, unexpected $end: ...eak());a=b;b=c;c=res;);res
***
I've checked the '(' and '{' pairs and I'm disoriented on why does it have a syntax error.
Anyone can help?
Thanks
**** MULLER ROOT FINDING ****
f(x,N)=
{
y = 1+sen(x);
}
muller(a,b,c,N)=
{
my(f1,f2,f3,d1,d2,g1,g2,a1,a2,a0,res,x,y,z,i,j,k,l,m);
res = 0;
i = 0;
for(i=1,10000000
f1 = f(a,N);
f2 = f(b,N);
f3 = f(c,N);
d1 = f1 - f3;
d2 = f2 - f3;
h1 = a - c;
h2 = b - c;
a0 = f3;
a1 = ( ( (d2 * h1 *h1) - (d1 * h2 * h2) ) / ( (h1 * h2) * (h1 - h2) ) );
a2 = ( ( (d1 * h2) - (d2 * h1) ) / ( (h1 * h2) * (h1 - h2) ) );
x = ( (-2 * a0) / (a1 + abs(sqrt(a1 * a1 - 4 * a0 * a2))) );
y = ( (-2 * a0) / (a1 - abs(sqrt(a1 * a1 - 4 * a0 * a2))) );
if(x >= y,
res = x + c,
res = y + c
)
l = floor(res * 1000);
m = floor(c * 1000);
if(l==m, break());
a = b;
b = c;
c = res;
);
res //==== Here is the error
}
--- ---
Eduardo Morras <emorrasg@yahoo.es>