Write a program using Bisection method and method of false position.

In summary, the speaker is new to programming and is feeling overwhelmed about an assignment that requires them to write a program that finds the root of a specific equation using two methods. They ask for guidance on where to start and the language needed, and are given an example of pseudo code using a loop.
  • #1
DaisyShafi
2
0
Hello everyone.
I'm new here and I'm not not a computer science student.
But, I have to take programming to complete my degree.
So, now I'm in a great depression about this assignment.
My lecturer ask me to write a program to find root of an equation f(x)=0 for specific f. Both methods are need to be in my assignment.
So, where should I start?
 
Physics news on Phys.org
  • #2
Hello DaisyShafi,

First, write your two methods using pseudo code.

What language do you need to use?

J.
 
  • #3
What language ? English.
Can you show me the step?
Do I need to include the f(x) polynomial equation into the coding?
 
  • #4
What computer language?

Pseudo code is writing something like:

Code:
for the integer n given as an argument:
while n > 0 do
     n <- n -1
 
  • #5


Hello, welcome to the world of programming! Don't worry, even if you are not a computer science student, you can still learn and write programs. Let's start with understanding the Bisection method and the method of false position.

The Bisection method is a numerical method for finding the root of a function by repeatedly bisecting an interval and determining which subinterval contains the root. This method is based on the intermediate value theorem, which states that if a continuous function takes on positive and negative values at two points, then it must also take on the value of zero at some point in between.

The method of false position, also known as the regula falsi method, is similar to the Bisection method but instead of bisecting the interval, it approximates the root by finding the intersection of the line connecting the two function values at the endpoints of the interval. This method is faster than the Bisection method but may not always converge to the root.

Now, for your assignment, you can start by understanding the algorithm for both methods and then translating it into code. You can use any programming language of your choice. Here are some steps to get you started:

1. Define the function f(x) that you want to find the root for.
2. Choose an initial interval [a,b] such that f(a) and f(b) have opposite signs.
3. Implement the Bisection method:
a. Calculate the midpoint c = (a+b)/2
b. If f(c) = 0, then c is the root.
c. If f(a) and f(c) have opposite signs, then the root lies in the interval [a,c].
d. If f(b) and f(c) have opposite signs, then the root lies in the interval [c,b].
e. Repeat steps a-d until the desired accuracy is reached.

4. Implement the method of false position:
a. Calculate the slope of the line connecting (a,f(a)) and (b,f(b)).
b. Find the x-intercept of this line.
c. If f(x-intercept) = 0, then the x-intercept is the root.
d. If f(a) and f(x-intercept) have opposite signs, then the root lies in the interval [a,x-intercept].
e. If
 

Related to Write a program using Bisection method and method of false position.

1. How does the bisection method work?

The bisection method is an algorithm used to find the root of a function by narrowing down the search interval in each iteration. It works by first finding two points in the interval where the function has opposite signs. This interval is then divided in half and the process is repeated until the root is found within a certain tolerance.

2. What is the difference between the bisection method and the method of false position?

The main difference between the bisection method and the method of false position is the way in which the new interval is chosen in each iteration. In the bisection method, the midpoint of the interval is always chosen as the new point, while in the method of false position, the new point is chosen based on the slope of the function at the two endpoints of the interval.

3. When should I use the bisection method and when should I use the method of false position?

The bisection method is a more reliable method for finding the root of a function, as it is guaranteed to converge as long as the function is continuous and has opposite signs at the endpoints of the interval. The method of false position, on the other hand, may converge faster but is not guaranteed to converge for all functions.

4. How do I choose the initial interval for the bisection method and method of false position?

The initial interval for both methods should be chosen such that the function has opposite signs at the endpoints. It is also important to choose an interval that is small enough to contain only one root but not too small that it may miss the root altogether.

5. Can the bisection method and method of false position be used for all types of functions?

The bisection method and method of false position can be used for any continuous function. However, they may not be as efficient for functions with multiple roots or rapidly changing slopes. In these cases, other methods such as Newton's method may be more appropriate.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
11
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
Replies
1
Views
9K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • New Member Introductions
Replies
3
Views
71
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
Replies
8
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
16
Views
3K
Back
Top