integral using "int" function
이전 댓글 표시
Hello everyone
I used function "int" to integral three functions F1xy, F2xy and F3xy and plot g1 ,g2 and g3 but does not works , can you help me to solve this problem?
result exicution
>>
g1 =
int((((615013805111497776896056633613405*t^2)/3569704090242693994614716226338816 - 8918236563554137/2305843009213693952)^2 + ((6125818010313341771482361107925645*t^2)/3569704090242693994614716226338816 - 5551856489561907/144115188075855872)^2)^(1/2), t)
g2 =
int((((245*(t/25 - (5423799145652977*sin((4*pi*t)/5))/36028797018963968 + (2927085600657033*sin((8*pi*t)/5))/144115188075855872 - 1/40)^2)/11 - ((7356568495562081*cos((8*pi*t)/5))/72057594037927936 - (1703936755052999*cos((4*pi*t)/5))/4503599627370496 + 1/25)^2/2)^2 + ((245*(t/25 + (5423799145652977*sin((4*pi*t)/5))/36028797018963968 + (2927085600657033*sin((8*pi*t)/5))/144115188075855872 - 1/40)^2)/11 - ((1703936755052999*cos((4*pi*t)/5))/4503599627370496 + (7356568495562081*cos((8*pi*t)/5))/72057594037927936 + 1/25)^2/2)^2)^(1/2), t)
g3 =
int((((245*((5000333870613589*t)/18014398509481984 - 444897748731878793/1801439850948198400)^2)/11 - 5551856489561907/144115188075855872)^2 + ((245*((1584380140315613*t)/18014398509481984 - 378191502634271457/1801439850948198400)^2)/11 - 8918236563554137/2305843009213693952)^2)^(1/2), t)
댓글 수: 3
kamar
2024년 9월 15일
편집: Walter Roberson
2024년 9월 15일
kamar
2024년 9월 15일
편집: Walter Roberson
2024년 9월 15일
답변 (2개)
Not everything you write down will have a simple, algebraic solution. As much as people seem to think they are, computers are not godlike beings, with infinite abilities and power, able to do anything you ask of them. That happens only on TV and in the movies. And suppose they were? Why would they be willing to follow our demands anyway? ;-)
syms t
kernel1 = (((615013805111497776896056633613405*t^2)/3569704090242693994614716226338816 - 8918236563554137/2305843009213693952)^2 + ((6125818010313341771482361107925645*t^2)/3569704090242693994614716226338816 - 5551856489561907/144115188075855872)^2)^(1/2)
So we see the sqrt of a degree 4 polynomial in t. Int fails. Its probably not going to have any nice form you will write down. And that int refuses to perform the integration is it telling you exactly that. If you have limits of integration, then of course it is trivial, since a numerical integration will suffice.
int(kernel1,t)
int fails, as I said. A numerical integration wil work of course. But you need to have limits for the integration.
vpaintegral(kernel1,t,[1,2])
Is there ANYTHING you can do? As long as you stay away from any singularities....
fplot(kernel1)
We see a fairly simple functional form. In fact, it should look vaguely quadratic. So consider this...
kernel1Approx = taylor(kernel1,t,order = 10);
vpa(kernel1Approx,5)
I see the Taylor series seems to have flipped the sign, using the wrong branch of the sqrt. That is easily fixed, though arguably worth reporting as a bug.
kernel1Approx = -kernel1Approx;
And we can easily enough plot the integral now.
fplot(int(kernel1Approx,t),[0,5])
As I said, the function is actually very close to being a quadratic polynomial. Only the constant and quadratic term are effectively non-zero. But we can also evaluate that result, to see if int agrees with the numerical integration.
vpa(int(kernel1Approx,t,[1,2]))
Be careful though. It looks like the approximation may have some issues near zero, where there may be some sort of higher order singularity at zero. Square roots can do that to you. But as long as I safely away from zero, the truncated Taylor series approximation seems pretty good. Anyway, effectively, you can use that approximation for the integral, and now you have a nice, closed form solution. i even plotted the integral above. The ther expressions look to be similar.
댓글 수: 6
kamar
2024년 9월 15일
편집: Walter Roberson
2024년 9월 15일
John D'Errico
2024년 9월 15일
Sorry, by the way. For some reason, Answers is not displaying symbolic expressions when I save the results. So I guess you will need to do as I did in my answer to see what happens.
John D'Errico
2024년 9월 15일
편집: John D'Errico
2024년 9월 15일
Yes. That is your code. It is not at all relevant. My point is two-fold.
- You CANNOT perform the integrations you want to do. Just wanting it to work is not sufficient.
- You CAN approximate those integration kernels as simple polynomials, thus just truncated Taylor series approximations. And having done so, now you can perform the integrations you want to perform.
So what is your question? I showed exactly what you can and cannot do, and I showed you exactly what you need to do to fix it.
kamar
2024년 9월 15일
편집: Walter Roberson
2024년 9월 15일
John D'Errico
2024년 9월 15일
Ok. And surely you read my answer?????
Did you bother to see that I showed the plot of the integral of the first of those functions, where I performed a definite integration of the Truncated Taylor series approximation? I did this:
fplot(int(kernel1Approx,t),[0,5])
Again, I am sorry that it does not seem to show up in answers as a pretty plot, but when I do it on the screen it does show. Only when I save it does it fail. The Answers bug has been reported.
kamar
2024년 9월 15일
Your code to produce g1, g2 and g3 does not matter.
You don't get analytic expressions for the antiderivatives of g1, g2 and g3 from "int".
But if you specify numerical values for the limits of integration, you can use "vpaintegral" to get numerical values for the definite integrals. For this, replace
g1=int(F1xy,t)
g2=int(F2xy,t)
g3=int(F3xy,t)
by
g1=@(tt)arrayfun(@(tt)vpaintegral(F1xy,t,0,tt),tt)
g2=@(tt)g1(t1) + arrayfun(@(tt)vpaintegral(F2xy,t,t1,tt),tt)
g3=@(tt)g2(Tau-t1) + arrayfun(@(tt)vpaintegral(F3xy,t,Tau-t1,tt),tt)
댓글 수: 3
kamar
2024년 9월 15일
편집: Walter Roberson
2024년 9월 15일
Torsten
2024년 9월 15일
I wrote to only substitute these three lines. So you can use fplot as you did in your code.
kamar
2024년 9월 15일
카테고리
도움말 센터 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

