Re: Assuming and Integrate
- To: mathgroup at smc.vnet.net
- Subject: [mg128325] Re: Assuming and Integrate
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Sun, 7 Oct 2012 01:30:54 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <20121006055312.C0D5B6908@smc.vnet.net>
f[m_, n_] = Assuming[Element[{n, m}, Integers],
Piecewise[{
{Integrate[Sin[n*x]*Sin[n*x], {x, 0, Pi}],
m == n},
{Integrate[Sin[n*x]*Sin[m*x], {x, 0, Pi}], m != n}}]]
Piecewise[{{Pi/2, m == n}}, 0]
f @@@ {{m, n}, {m, m}, {3, 2}, {3, 3}}
{Piecewise[{{Pi/2, m == n}}, 0],
Pi/2, 0, Pi/2}
Assuming[m == n, Simplify[f[m, n]]]
Pi/2
Bob Hanlon
On Sat, Oct 6, 2012 at 1:53 AM, <hamiltoncycle at gmail.com> wrote:
> When I try the line below in Mathematica 8 I get the answer 0 which is what I expect when m and n are different but not when m=n. Can anyone explain how to do this correctly?
>
> Assuming[Element[{n, m}, Integers], Integrate[Sin[n*x]*Sin[m*x], {x, 0, Pi}]]
>
> When m=n we should get Pi/2, as in this case:
>
> Assuming[Element[n, Integers], Integrate[Sin[n*x]*Sin[n*x], {x, 0, Pi}]]
>
> cheers, Robert
>
- References:
- Assuming and Integrate
- From: hamiltoncycle@gmail.com
- Assuming and Integrate