# Is my expression too complicated for FullSimplify or am I doing something wrong?

I have a messily defined function $v(h, w)$ with $h, w \in \mathbb{R}$ and with a removable singularity at $h=1/2$, and I am trying to prove some of its properties using Mathematica. In particular I want to prove that $v(h,w) \in \mathbb{R}$, as opposed to possibly having nonzero imaginary part, and I want to prove that $v(h,w) = v(1-h, -w)$. I am defining the function in Mathematica as follows:

a[h_] = h / (2*h - 1)
q[h_, w_] = Sqrt[2*h - 1] * Sqrt[2*w]
v[h_, w_] = Exp[-w]*(2/Sqrt[Pi])*q[h,w]*Exp[(q[h,w]*a[h])^2] / ( Erfi[q[h,w]*a[h]] + Erfi[q[h,w]*(1 - a[h])] )

I apologize for its messiness. My initial hope was that Mathematica would tell me that this is just a well known special function with known properties which I could cite. My next hope was that I could at least use applications of FullSimplify with Assumptions to prove the properties. But I have not been successful at either approach.

To make my question more concrete, I am wondering why Mathematica does not simplify the following expression to True:

FullSimplify[ v[h, w] == v[1 - h, -w], Element[{w,h}, Reals] && h != 1/2]

One possibility is that I am wrong about the math. I've tried to rule this out by using Mathematica to prove special cases like the following, where I've also tried other values of $h$ besides $1/5$.

FullSimplify[ v[1/5, w] / v[1 - 1/5, -w] ]
FullSimplify[ v[1/5, w] - v[1 - 1/5, -w] ]
FullSimplify[ v[1/5, w] == v[1 - 1/5, -w] ]

Another possibility is that it is too hard for Mathematica. But I think the most likely explanation is that I'm using Mathematica wrong because I'm a newbie.

Update:
Inspired by @rcollyer's answer I took out a pencil and paper and figured out how to write this function as the reciprocal of a series that satisfies the properties by construction:

fterm[h_, w_, k_] = (((-4*w)^k) / (2*k+1)!!) * (h / (2*h-1)) * Exp[w]*(h^2 / (2*h-1))^k
f[h_, w_] = Sum[fterm[h, w, k] + fterm[1-h, -w, k], {k, 0, Infinity}]

Mathematica is still unable to directly verify that $f(h,w) = f(1-h,-w)$ on the appropriate domain, but $1/f(h,w)$ compares True to the original function $v(h,w)$. As a side note, I had hoped that in the process of verifying these properties I would find a formula that gets rid of the computational difficulty associated with the removable singularity at $h=1/2$ for free, but this did not happen.

-
Can you try and comment the following: Assume you want to prove v[h,w]/v[1-h,-w]-1==0 which is the first of your last three examples. Take the left side and put it on a common denominator. Then you try to solve num==0 where num is the numerator and if you can, you have to think about whether bad things happen in the denominator. This approach would be something like Numerator@Together[FullSimplify[v[h, w]/v[1 - h, -w] - 1]] == 0. For your real w and h the appearing roots should be transformable with Sqrt[-w]==I*Sqrt[w] for w>=0. Maybe you can solve this. – halirutan Sep 28 '12 at 2:14

Simplification in Mathematica is often a black art, and requires great use of your own intuition and knowledge to be effective. That said, I bring your attention to the series from of $\DeclareMathOperator{\erfi}{erfi}\erfi(z)$,

$$\erfi(z) = \frac{2}{\sqrt{\pi}}\sum^\infty_{k=1} \frac{z^{(2k+1)}}{k! (2k+1)}.$$

Consider what happens when we use that to combine the terms in the denominator of v[h, w]:

((Sqrt[2] h Sqrt[w])/Sqrt[-1 + 2 h])^(2 k + 1) +
(Sqrt[2] Sqrt[-1 + 2 h] (1 - h/(-1 + 2 h)) Sqrt[w])^(2 k + 1)

ignoring the $k! (2k+1)$, for now. FullSimplify will not tackle that even with the assumptions Element[{w,h}, Reals], but PowerExpand will and then you can use FullSimplify to get

(-(1/2) + h)^(-(1/2) - k) ((-1 + h)^(1 + 2 k) + h^(1 + 2 k)) w^(1/2 + k)

Similarly, for the denominator of v[1 - h, -w] you get

(-I) E^(I k Pi) (1/2 - h)^(-(1/2) - k) (-(1 - h)^(1 + 2 k) + (-h)^(2 k) h) w^(1/2 + k)

Note, the similarities.

I will leave the rest of the simplification to you.

Edit: it turns out I can't leave well enough alone. As I mentioned in a comment, PowerExpand assumes that $h\text{,}w\in\mathbb{R}$ and $h\text{,}w\ge0$. The latter requirement may cause problems, but PowerExpand accepts the option Assumptions to alter the default. Here's what happens to the first denominator when the four possibilities of positivity are considered:

PowerExpand[
denom1,
Assumptions -> LessEqual[#1, #2] && LessEqual[#3, #4]
] & @@@ {{w, 0, h, 0}, {w, 0, 0, h}, {0, w, h, 0}, {0, w, 0, h}} //
FullSimplify[#, {h, w} \[Element] Reals && k \[Element] Integers] &

$$-i (-1)^k \left(\frac{1}{2}-h\right)^{-k-\frac{1}{2}} \left(h^{2 k+1}+(h-1)^{2 k+1}\right) w^{k+\frac{1}{2}}$$ $$\left(h-\frac{1}{2}\right)^{-k-\frac{1}{2}} \left(h^{2 k+1}+(h-1)^{2 k+1}\right) w^{k+\frac{1}{2}}$$ $$-i \left(\frac{1}{2}-h\right)^{-k-\frac{1}{2}} \left((h-1) (i (h-1))^{2 k}+h (i h)^{2 k}\right) w^{k+\frac{1}{2}}$$ $$\left(h-\frac{1}{2}\right)^{-k-\frac{1}{2}} \left(h^{2 k+1}+(h-1)^{2 k+1}\right) w^{k+\frac{1}{2}}$$

The code itself isn't terribly complex, but let me walk you through it.

PowerExpand[
denom1,
Assumptions -> LessEqual[#1, #2] && LessEqual[#3, #4]
] &

is a pure function taking 4 arguments labelled #i. This is then applied to a list containing the 4 possible orderings of the conditions, i.e. {w, 0, h, 0} corresponds to w <= 0 && h <= 0 in the Assumptions, using the second short hand form of Apply. Essentially,

f[#1, #2]& @@@ {{a, b}, {c, d}}

becomes

{f[a,b], f[c,d]}

The entire list is then fed into FullSimplify with the assumption of reality included. I tried including the positivity assumptions, too, but it tended to convolute the result.

Applied to the second denominator you get,

$$-i \left(\frac{1}{2}-h\right)^{-k-\frac{1}{2}} \left(h^{2 k+1}+(h-1)^{2 k+1}\right) w^{k+\frac{1}{2}} \left( \begin{array}{cc} \{ & \begin{array}{cc} -(-1)^k & w<0 \\ (-1)^k & \text{True} \\ \end{array} \\ \end{array} \right)$$ $$-i \left(\frac{1}{2}-h\right)^{-k-\frac{1}{2}} \left(h^{2 k+1}+(h-1)^{2 k+1}\right) w^{k+\frac{1}{2}} \left( \begin{array}{cc} \{ & \begin{array}{cc} -(-1)^k & w<0 \\ (-1)^k & \text{True} \\ \end{array} \\ \end{array} \right)$$ $$-i (-1)^k \left(\frac{1}{2}-h\right)^{-k-\frac{1}{2}} \left(h^{2 k+1}+(h-1)^{2 k+1}\right) w^{k+\frac{1}{2}}$$ $$-i (-1)^k \left(\frac{1}{2}-h\right)^{-k-\frac{1}{2}} \left(h^{2 k+1}+(h-1)^{2 k+1}\right) w^{k+\frac{1}{2}}$$

End Edit

As an additional note, if you look at

Series[v[h, w]/v[1 - h, -w], {h, 0, 5}, {w, 0, 5}]

you get

$$\left(1+O\left(w^{11/2}\right)\right)+h O\left(w^7\right)+h^2 O\left(w^{11/2}\right)+h^3 O\left(w^{11/2}\right)+h^4 O\left(w^{11/2}\right)+h^5 O\left(w^{11/2}\right)+O\left(h^6\right)$$

which provides a strong indication that they are equal.

-
An additional note: PowerExpand assumes that the variables are real and positive. – rcollyer Sep 28 '12 at 2:55
I couldn't follow this answer completely, but I've added an update based on this idea of expanding the erfi series. – intermath Sep 29 '12 at 2:20
@intermath the essence of the idea is that you prove that two denominators are related to each other via the series. The trick is to massage the denominators into identical forms by moving extraneous terms into the numerator, and this has to be done in each quadrant of the $w\text{,}h$ plane. For the second denominator, note that one simplification relates directly to the fact $w\leq0$. (Hint: the piece-wise portion.) Once that is done, the numerators should be equal. – rcollyer Sep 29 '12 at 2:41