X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=has_root.m;fp=has_root.m;h=0000000000000000000000000000000000000000;hb=437324f2edf6b26c772080f8cbe3b321dda8d70f;hp=ffd96666b0bca58366fc5b641c43a2893cf3b16c;hpb=f32a60e5aceefce5b4b7497b9d295c8175297110;p=octave.git diff --git a/has_root.m b/has_root.m deleted file mode 100644 index ffd9666..0000000 --- a/has_root.m +++ /dev/null @@ -1,34 +0,0 @@ -function has_root = has_root(fa, fb) - ## Use the intermediate value theorem to determine whether or not some - ## function has an odd number of roots on an interval. If the function - ## in question has an even number of roots, the result will be - ## incorrect. - ## - ## Call the function whose roots we're concerned with 'f'. The two - ## parameters `fa` and `fb` should correspond to f(a) and f(b). - ## - ## - ## INPUTS: - ## - ## * ``fa`` - The value of `f` at one end of the interval. - ## - ## * ``fb`` - The value of `f` at the other end of the interval. - ## - ## OUTPUTS: - ## - ## * ``has_root`` - True if we can use the I.V.T. to conclude that - ## there is a root on [a,b], false otherwise. - ## - - ## If either f(a) or f(b) is zero, the product of their signs will be - ## zero and either a or b is a root. If the product of their signs is - ## negative, then f(a) and f(b) are non-zero and have opposite sign, - ## so there must be a root on (a,b). The only case we don't want is - ## when f(a) and f(b) have the same sign; in this case, the product of - ## their signs would be one. - if (sign(fa) * sign(fb) != 1) - has_root = true; - else - has_root = false; - end -end