[Top][All Lists]

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

Fwd: Bisection-Octave

From: Kai Torben Ohlhus
Subject: Fwd: Bisection-Octave
Date: Fri, 22 Feb 2019 12:43:48 +0100

On Thu, Feb 21, 2019 at 3:45 PM Peshawa Salih <address@hidden> wrote:
On Thu, Feb 21, 2019 at 1:39 PM Kai Torben Ohlhus <address@hidden> wrote:
On Thu, Feb 21, 2019 at 3:15 AM Peshawa Salih <address@hidden> wrote:
Dear Sir/Madam,


I am using Octave to solve and equation and to find a root using bisection method. The method works for one value, but in fact I want to calculate for a vector of values.
I wonder if this method of fining root or other methods support entering vector array of values?


Can you give a small, but meaningful, example of your system you want to solve?  Did you try the functions mentioned in the manual ?

> Dear Kai,
> Thank you for the email,

> I have not used those provided in the link yet. I will type my example and uploaded as Octave file.

>  X=85:-1:50;
>     Y=5:1:40;
>     Xr=X*pi/180;
>     Yr=Y*pi/180;
>     N=(Xr.*cosd(Y))-(Yr.*cosd(X)); 
>     D=(cosd(Y)-cosd(X));            
>     C=N./D;
>     for j= length(C);
>     y= @(F) (F*pi/180)+cotd(F)-C(j);
>     end
>     FL=30;
>     FR=70;
>         for i= 1:1000
>           FM=(FL+FR)/2;
>             if y(FL)*y(FM) < 0
>               FR=FM;
>             else
>               FL=FM;
>             end
>           if abs (y(FL)) < 1.0E-10;        
>           break
>           end
>         end
>   fprintf('Number of iterations: %d\n', i);
>   fprintf('phi_note: %f\n', FL);

> Regards
> Peshawa Salih

Dear Peshawa Salih,

Please use bottom-posting [1] for this mailing-list and keep the mailing-list in the CC, as many people are having better ideas than I have ;-)

Your example is not clear to me.  Your problem seems to be:  Find a real scalar `F`, such that   `y(F) = 0`,  where  `y` : R --> R^36.  But in your code despite the for loop over 36 elements, you get a function `y` of scalar input and output and only the last C(36) is taken for `y`.

And why do you write the bisection method yourself?


Attachment: Bisection2.m
Description: Text Data

reply via email to

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