integral using "int" function

조회 수: 1 (최근 30일)
kamar
kamar 2024년 9월 15일
댓글: kamar 2024년 9월 15일
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
Torsten
Torsten 2024년 9월 15일
편집: Torsten 2024년 9월 15일
There are many functions for which an analytical antiderivative does not exist or is hard to find. Your g1, g2 and g3 seem to belong to this class of functions because int does not succeed.
kamar
kamar 2024년 9월 15일
편집: Walter Roberson 2024년 9월 15일
than you
my code is
clear all;
clc;
close all;
% Define the symbolic variable t
syms t ;
t1 =0.39;
alpha1 =0.22; alpha2 = 0.135; alpha3 =0.05;
g=9.8;
w=sqrt(g/alpha1);
Tau=1.25;
L1=(alpha3*t1*w)/(w*t1+tanh(w*(Tau/2-t1)));
L2=(alpha2*t1*w*tanh(w*(Tau/2-t1)))/(1+(w*t1)+tanh(w*(Tau/2-t1)));
%if t>=0 && t<t1
f1=(L1/t1)*t;
f1dot=L1/t1;
f2=(L2/t1)*t;
f2dot=L2/t1;
f1x=(-g/(2*alpha1))*(f1 + f2)^2 +(1/2)*(f1dot + f2dot)^2;
f2y=(-g/(2*alpha1))*(-f1 + f2)^2 +(1/2)*(-f1dot + f2dot)^2;
F1xy=sqrt(f1x.^2+f2y.^2);
g1=int(F1xy,t)
hold on
fplot(g1, [0, t1]);
%elseif t>t1 && t<=(Tau-t1)
f3=((alpha3/Tau)*(t-(Tau/2)))+((2*alpha3*Tau^2*w^2)/(pi*(Tau^2*w^2+4*pi^2)))*sin((2*pi*t)/Tau);
f4=((4*alpha2*Tau^2*w^2)/(pi*(Tau^2*w^2+pi^2)))*sin(pi*t/Tau);
%%%%%%%%%%
f3dot=(alpha3/Tau)+((2*alpha3*Tau^2*w^2)/(pi*(Tau^2*w^2+4*pi^2)))*(2*pi/Tau)*cos(2*pi*t/Tau);
f4dot=((4*alpha2*Tau^2*w^2)/(pi*(Tau^2*w^2+pi^2)))*(pi/Tau)*cos(pi*t/Tau);
f3x=(-g/(2*alpha1))*(f3 + f4)^2 +(1/2)*(f3dot + f4dot)^2;
f3y=(-g/(2*alpha1))*(-f3 + f4)^2 +(1/2)*(-f3dot + f4dot)^2;
%
F2xy=sqrt(f3x.^2+f3y.^2);
g2=int(F2xy,t)
fplot(g2, [t1, Tau-t1]);
%elseif t>=(T-ts) && t<=T
f5=(2*alpha3-L1)+(L1/t1)*(t-(Tau-t1));
f5dot=(L1/t1);
f6=(L2/t1)*(Tau-t);
f6dot=-(L2/t1);
f3x=(-g/(2*alpha1))*(f5 + f6)^2 +(1/2)*(f5dot +f6dot)^2;
f3y=(-g/(2*alpha1))*(-f5 + f6)^2 +(1/2)*(-f5dot + f6dot)^2;
%
F3xy=sqrt(f3x.^2+f3y.^2);
g3=int(F3xy,t)
fplot(g3, [Tau-t1,Tau]);
hold off

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

답변 (2개)

John D'Errico
John D'Errico 2024년 9월 15일
편집: John D'Errico 2024년 9월 15일
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
John D'Errico
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
kamar 2024년 9월 15일
thank you

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


Torsten
Torsten 2024년 9월 15일
이동: Torsten 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
Torsten
Torsten 2024년 9월 15일
I wrote to only substitute these three lines. So you can use fplot as you did in your code.
kamar
kamar 2024년 9월 15일
thank you

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

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by