int of symbolic function not returning the integral

17 ビュー (過去 30 日間)
Liam Callaghan
Liam Callaghan 2021 年 6 月 18 日
コメント済み: Liam Callaghan 2021 年 6 月 23 日
I am trying to get the respective x-axis values for equal spacing along a function by calculating the limits of the integral that outputs the arc length, where the integral output is known (spacing increment). However, the int function is outputting:
int((((5204138152017503*a^5)/140737488355328 - (2930562179140953*a^4)/70368744177664 + (3626385061401385*a^3)/140737488355328 - (1491432682786067*a^2)/140737488355328 + (515258452258509*a)/140737488355328 - 3771558310026235/4503599627370496)^2 + 1)^(1/2), a)
opposed to the actual integral.
Relevant script:
%xu and yu are just x and y values for the function
f1 = polyfit(xu,yu,6);
p1 = polyval(f1,xu);
q = diff(f1);
syms a
f0 = ((q(1)*a^5)+(q(2)*a^4)+(q(3)*a^3)+(q(4)*a^2)+(q(5)*a)+q(6));
g0 = sqrt(1 + f0^2);
F = int(g0,a);
How do I get the actual integral out in a useful form?

採用された回答

Divija Aleti
Divija Aleti 2021 年 6 月 21 日
Hi Liam,
The "int" function cannot solve all integrals since symbolic integration is such a complicated task. It is also possible in this case that no analytic or elementary closed-form solution exists.
For more information, have a look at the 'Tips' section of the following link:
Hope this helps!
Regards,
Divija

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 6 月 21 日
It looks to me as if you are defining an arc length. However, for an arc length, f0 would have to be the derivative of a function. Which function?
f0 = ((q(1)*a^5)+(q(2)*a^4)+(q(3)*a^3)+(q(4)*a^2)+(q(5)*a)+q(6));
It is not the derivative of the function expressed through the q coefficients, at least not at that stage. Let's look further back
q = diff(f1);
well, that certainly looks like it might be a derivative. But is it?
f1 = polyfit(xu,yu,6);
No! The output of polyfit() is numeric, and diff() applied to a numeric vector is the finite difference operator, not the derivative. You are computing
q = f1(2:end) - f1(1:end-1)
not taking the derivative of a polynomial implied by f1.
I suspect that you should be doing
syms a
f1 = polyfit(xu,yu,6); %f1 is numeric
f0 = poly2sym(f1, a); %symbolic
g0 = sqrt(1 + diff(f0,a)^2);
F = int(g0, a)
You are unlikely to get a closed form solution. Closed form solutions might be possible in terms of the Elliptic Integral if diff(f0,a)^2 was degree no more than 4 (which would require that diff(f0,a) be of degree no more than 2, which would be for the case of fitting a cubic)
  1 件のコメント
Liam Callaghan
Liam Callaghan 2021 年 6 月 23 日
Thank you!

サインインしてコメントする。

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by