How to use bisection method to approximate values?

조회 수: 2 (최근 30일)
Sajith Dharmasena
Sajith Dharmasena 2015년 4월 22일
댓글: Sajith Dharmasena 2015년 4월 25일
Okay so I have a function that spits out y values for a range of x values. For example I'm numerically integrating the function y = integral( x^2 + 2x + 6) using trapezoidal method from 0 to 2. So for say, x = 0:0.05:2 I have the corresponding y values. But now using this result, I want to find x values for a range of y values. Does anybody know how to write the code for this using the bisection method? Your help will be greatly appreciated :)

답변 (1개)

Nalini Vishnoi
Nalini Vishnoi 2015년 4월 24일
Can you provide more information about the problem? As I understand it, if you are integrating over x and it ranges from 0 to 2, that would mean that there is a single unique value of y. The value would not change as long as the limits of the integration are fixed. Could you please clarify the following information:
1. Do the limits of the integral change?
2. How does y depend on x if the limits of integration are constant?
3. Is the relationship one to one meaning one x value correspond to one unique y value and vice versa?
You can check how to implement a general bisection problem in MATLAB here .
  댓글 수: 1
Sajith Dharmasena
Sajith Dharmasena 2015년 4월 25일
Yes the relationship is one to one. Okay so I'm numerically integrating a function using the midvalue method. So say I've defined my function as
function [y] = mid(b,N) where b is the upper limit of the integral and N is the number of sections. So as you can tell as I increase N, y will converge to its exact value (also the integral goes from 0 to b).
But what I really want is to find the b value for a given y value. So for example, say I got y = 2.3 with mid(1.5,400). I want to write a new function that will spit b = 1.5 if I input y = 2.3 and N = 400. But I'm not sure how to do it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by