How to use bisection method to approximate values?

2 次查看(过去 30 天)
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