How to get results from symbolic variable integration

2 次查看(过去 30 天)
Pretty straight forward, I'm trying to do integration with symbolic variables.
I'm doing some complex integration with a mix of high degree polynomials and trig functions.
This is what I tried so far:
syms x
b4 = (x^127+x^32-x^12+78*x^2-5*cos(x))
int(b4, 0, 1)
I was hoping to get some number for the answer, but instead, I got this:
ans =
int((x^127+x^32-x^12+78*x^2-5*cos(x)), x, 0, 1)
I don't know why this is happening. How do I get the actual answer in numbers?

采纳的回答

Walter Roberson
Walter Roberson 2016-7-27
There is no readily-found closed-form solution for your actual integral. You will need to use vpa() or double() to request numeric integration.
  2 个评论
Hosup Song
Hosup Song 2016-7-28
so would i have to do something like
b4 = (((1+x^3+x^i)^(1/2))*((1/0.00149912)*(cos(x)-30*(6-11*sin(1)+...
6*cos(1))*x^2+(192-336*sin(1)+168*cos(1))*x-36+57*sin(1)-24*cos(1))))
A = int(b4, 0, 1)
double(A)
Would this give me a numeral value for the answer?

请先登录,再进行评论。

更多回答(1 个)

Andrei Bobrov
Andrei Bobrov 2016-7-27
in R2016a
>> syms x
b4 = (x^127+x^32-x^12+78*x^2-5*cos(x));
int(b4, 0, 1)
ans =
1425581/54912 - 5*sin(1)
>>
  1 个评论
Hosup Song
Hosup Song 2016-7-27
编辑:Walter Roberson 2016-7-27
ok i guess that was a bad example to use, since it works out nicely. The actual function I'm using is
b4 = (((1+x^3+x^i)^(1/2))*((1/0.00149912)*(cos(x)-30*(6-11*sin(1)+...
6*cos(1))*x^2+(192-336*sin(1)+168*cos(1))*x-36+57*sin(1)-24*cos(1))))
I'm trying to integrate this and when I use int(b4, 0, 1), i get ans =
int((x^3 + x^1i + 1)^(1/2)*((1885688952269973342506590723*x)/77371252455336267181195264 + (5867504283985271*cos(x))/8796093022208 + (1423673755532221964006035379175*x^2)/4951760157141521099596496896 - 1657186126350190416636264063127/2475880078570760549798248448), x, 0, 1)
How do i get rid of this.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by