Symbolic Integration Help
9 ビュー (過去 30 日間)
古いコメントを表示
I want to integrate this function, with respect to x...
y=1/((1+x^2)*(1+x^2+B1^2)^.5)
and B1 is a changing variable. If B1 is a constant, I carried out the symbolic integration like this...
y=sprintf('1/((1+x^2)*(1+x^2+(%1.3f)^2)^.5)',B1); s=int(y,z1,z2);
where z1 and z2 are my limits of integration and it works. How can I perform this integration when B1, z1, and z2 are changing? I tried doing a for loop, but it didn't work.
for x=1:100 y(x)=sprintf('1/((1+x^2)*(1+x^2+(%1.3f)^2)^.5)',B1(x)); s(x)=int(y(x),z1(x),z2(x)); end
0 件のコメント
採用された回答
Walter Roberson
2011 年 1 月 23 日
The complete answer is messy because you have not specified that B1, z1,or z2 are real, or that z1 <= z2. If you make those assumptions, you get
|
/ / 2 \
1 | | z1 B1 |
- ---- |arctan|-------------------------|
|B1| | | (1/2) |
| |/ 2 2\ |
\ \\1 + z1 + B1 / |B1|/
/ 2 \\
| z2 B1 ||
- arctan|-------------------------||
| (1/2) ||
|/ 2 2\ ||
\\1 + z2 + B1 / |B1|//
|
I will post later if I find a more compact solution.
5 件のコメント
Walter Roberson
2011 年 1 月 25 日
By the way, see the "real" modifier of "syms" to allow you to add the assumption that a particular symbolic variable is real.
Christopher Creutzig
2011 年 1 月 26 日
>> syms x B1 z1 z2 real
>> s=int(1/((1+x^2)*sqrt(1+x^2+B1^2)),z1,z2)
s =
-(atan((z1*(B1^2)^(1/2))/(B1^2 + z1^2 + 1)^(1/2)) - atan((z2*(B1^2)^(1/2))/(B1^2 + z2^2 + 1)^(1/2)))/(B1^2)^(1/2)
その他の回答 (1 件)
Paulo Silva
2011 年 1 月 23 日
Use the function syms to declare symbolic variables and subs to replace a variable with a specific value, you might also need to use the function vectorize to convert symbolic expressions to char (just in case you want to plot something).
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!