Symbolic Integration Help

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

 Risposta accettata

Walter Roberson
Walter Roberson il 23 Gen 2011
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 Commenti

Walter Roberson
Walter Roberson il 23 Gen 2011
It simplifies a bit to
-(-arctan(z1*B1/sqrt(1+z1^2+B1^2))+arctan(z2*B1/sqrt(1+z2^2+B1^2)))/B1
under the assumption that the values involved are real.
Devin Rohan
Devin Rohan il 24 Gen 2011
Thanks, I figured out how to do integrate it symbolically, but it is really slow. I think I'll have to use that solution you came up with. How did you find that solution? When I typed in syms x B1 z1 z2 s=int(1/((1+x^2)*sqrt(1+x^2+B1^2)),z1,z2), MATLAB said it couldn't find a solution.
Walter Roberson
Walter Roberson il 25 Gen 2011
I used Maple, and I told Maple to assume real values and to assume z1<=z2 . That got me the less compact solution in a small number of seconds. To make it more compact, I ran it through a number of potential transformations and picked the most compact answer out of them.
In this particular case, when I told Maple to rewrite in terms of Heaviside functions and then to simplify the answer, it was able to simplify the B1^2 and abs(B1) components. I do not entirely trust Maple's Heaviside conversions, but Maple's conversion to signum provided an answer that could obviously be simplified to the one Heaviside came up with.
Walter Roberson
Walter Roberson il 25 Gen 2011
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
Christopher Creutzig il 26 Gen 2011
>> 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)

Accedi per commentare.

Più risposte (1)

Paulo Silva
Paulo Silva il 23 Gen 2011

0 voti

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).

Community Treasure Hunt

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

Start Hunting!

Translated by