How to use bisection method to approximate values?

2 Ansichten (letzte 30 Tage)
Sajith Dharmasena
Sajith Dharmasena am 22 Apr. 2015
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 :)

Antworten (1)

Nalini Vishnoi
Nalini Vishnoi am 24 Apr. 2015
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 Kommentar
Sajith Dharmasena
Sajith Dharmasena am 25 Apr. 2015
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by