フィルターのクリア

Why is my integration output the mathematical expression and not the solution?

1 回表示 (過去 30 日間)
Ayush Kumar
Ayush Kumar 2023 年 3 月 13 日
コメント済み: Star Strider 2023 年 3 月 13 日
I am trying to solve the following question:
and I have utlised the following script to achieve so:
syms x
func = ((x^3*cos(x/2)+1/2)*(sqrt(4-x^2)));
int(func,x,-2,2)
But MATLAB keeps returning the explicit form of the function back instead of computing it, as shown below:
ans =
int((4 - x^2)^(1/2)*(x^3*cos(x/2) + 1/2), x, -2, 2)
What am I doing wrong that is making it not compute but merely display the function?
The answer should be or π.
  4 件のコメント
Walter Roberson
Walter Roberson 2023 年 3 月 13 日
The output IBP is the same as the input. At the limits +/- 2 the function is 0.
Star Strider
Star Strider 2023 年 3 月 13 日
Running integrateByParts correctly this time (that I had not done previously, proving once again that paying close attention to the documentation is always appropriate) produces —
syms x
func = ((x^3*cos(x/2)+1/2)*(sqrt(4-x^2)));
F = int(func,x,-2,2)
iBP1 = integrateByParts(F,diff(sqrt(4-x^2)))
Fi1 = release(iBP1)
Fi1 = simplify(Fi1, 500)
iBP2 = integrateByParts(F,diff((x^3*cos(x/2)+1/2)))
Fi2 = release(iBP2)
Fi2 = simplify(Fi2, 500)
F =
int((4 - x^2)^(1/2)*(x^3*cos(x/2) + 1/2), x, -2, 2)
iBP1 =
-int((4 - x^2)^(1/2)*(2*x^3*cos(x/2) - ((x^2 - 4)*(x^3*cos(x/2) + 1/2))/x^2 + ((x^2 - 4)*(3*x^2*cos(x/2) - (x^3*sin(x/2))/2))/x + 1), x, -2, 2)
Fi1 =
-int((4 - x^2)^(1/2)*(2*x^3*cos(x/2) - ((x^2 - 4)*(x^3*cos(x/2) + 1/2))/x^2 + ((x^2 - 4)*(3*x^2*cos(x/2) - (x^3*sin(x/2))/2))/x + 1), x, -2, 2)
Fi1 =
-Inf
iBP2 =
-int(x^3*cos(x/2)*((4 - x^2)^(1/2) + ((4 - x^2)^(1/2)*(x^3*cos(x/2) + 1/2)*((x^3*cos(x/2))/4 - 6*x*cos(x/2) + 3*x^2*sin(x/2)))/(3*x^2*cos(x/2) - (x^3*sin(x/2))/2)^2 - (x*(x^3*cos(x/2) + 1/2))/((4 - x^2)^(1/2)*(3*x^2*cos(x/2) - (x^3*sin(x/2))/2))), x, -2, 2)
Fi2 =
-int(x^3*cos(x/2)*((4 - x^2)^(1/2) + ((4 - x^2)^(1/2)*(x^3*cos(x/2) + 1/2)*((x^3*cos(x/2))/4 - 6*x*cos(x/2) + 3*x^2*sin(x/2)))/(3*x^2*cos(x/2) - (x^3*sin(x/2))/2)^2 - (x*(x^3*cos(x/2) + 1/2))/((4 - x^2)^(1/2)*(3*x^2*cos(x/2) - (x^3*sin(x/2))/2))), x, -2, 2)
Fi2 =
NaN
I ran this in MATLAB Online, since it requires more than the allotted 55 seconds to run it here. It turns out that different definitions of (as described in the documentation) produce different results, neither of them finite.
.

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

回答 (1 件)

VBBV
VBBV 2023 年 3 月 13 日
func = @(x) ((x.^3.*cos(x./2)+1/2).*(sqrt(4-x.^2)));
integral(func,-2,2)
If you use integral it will work as you expected
  1 件のコメント
VBBV
VBBV 2023 年 3 月 13 日
編集済み: VBBV 2023 年 3 月 13 日
Read int help page for more information

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by