How to use bisection method to approximate values?

1 visualización (últimos 30 días)
Sajith Dharmasena
Sajith Dharmasena el 22 de Abr. de 2015
Comentada: Sajith Dharmasena el 25 de Abr. de 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 :)

Respuestas (1)

Nalini Vishnoi
Nalini Vishnoi el 24 de Abr. de 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 comentario
Sajith Dharmasena
Sajith Dharmasena el 25 de Abr. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by