Solving Integral for an Unknown Interval

Is it possible to solve an integral for an interval/ limit of integration without the symbolic toolbox? My problem is of the same form as:(∫f(x)dx)/Z on the interval[-a,a]is equal to (∫g(x)dx)/Y on the interval [-c,c], where Z, a, and Y are known values and c is the unknown variable.

 채택된 답변

Friedrich
Friedrich 2011년 7월 18일

0 개 추천

Hi,
so doing something like this:
function out = test_func( c )
out = quad(@lhs,-.25,.25) ./10 - quad(@rhs,-c,c)./6;
function out_lhs = lhs(x)
out_lhs = sqrt(5.^2 - x.^2);
end
function out_rhs = rhs(x)
out_rhs = sqrt(2.5^2 - x.^2);
end
end
And call it through:
fzero(@test_func,1)

추가 답변 (2개)

Friedrich
Friedrich 2011년 7월 18일

0 개 추천

Hi,
no. You can't get a symbolic solution without the symbolic math toolbox. When you know c you can use the quad function:

댓글 수: 4

John
John 2011년 7월 18일
I am actually trying to find the numeric value for c. I knew there was a way to solve the integral with the symbolic toolbox and then solve for c, however I was wondering if there was a more efficient way to do this without the toolbox. The problem is like(∫sqrt(5^2-x^2)dx)/10 [-25,.25]=(∫sqrt(2.5^2-x^2)dx)/6 [-c,c] solving for c.
Friedrich
Friedrich 2011년 7월 18일
Why not calculate it manually and than hardcode it. Or do your functions change during runtime?
John
John 2011년 7월 18일
The functions have the possibility to change during runtime, so I would not like to have to calculate each time.
Friedrich
Friedrich 2011년 7월 18일
Ah okay. Not sure if this will work fine but you could use the fzero function and search the root of (∫sqrt(5^2-x^2)dx)/10 [-25,.25] - (∫sqrt(2.5^2-x^2)dx)/6 [-c,c] , where you solve the integradl with quad

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

Bjorn Gustavsson
Bjorn Gustavsson 2011년 7월 18일

0 개 추천

One super-tool you should take a long look at is the Chebfun tools: http://www2.maths.ox.ac.uk/chebfun/
and my Q-D stab would be something like this:
I_of_f = quadgk(f(x)/Z,-a,a);
c = @(a,Z,Y,f,g) fminsearch(@(c) (I_of_f-quadgk(@(x) g(x)/Y,-c,c))^2,1)
I think that should work...

질문:

2011년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by