Solve with Integrate wouldn't produce correct answers

Hello,

In my book, there is an exercise:

f(x,y) is continuous over a closed region of D={(x,y)|x^2+y^2<=y,x>=0}, and f(x,y)=Sqrt[1-x^2-y^2]-8/Pi*Integrate[f(x,y),dy,dx]

In Mathematica

Solve[f[x, y] == 
   Sqrt[1 - x^2 - y^2] - 
    8/Pi*Integrate[
      f[x, y], {x, 0, 1/2}, {y, -Sqrt[1/4 - x^2] + 1/2, 
       Sqrt[1/4 - x^2] + 1/2}], f[x, y]] // Simplify

produces

{{f[x, y] -> 1/2 Sqrt[1 - x^2 - y^2]}}

But the right answer should be

Sqrt[1-x^2-y^2]+8/9/Pi-2/3

So, what the reason for Mathematica to produce that answer?

The answer of Solve is rubbish, and the reason may be that you fed it a integral functional equation, for which Solve is not prepared.

Here is a possible derivation of the solution:

reg = ImplicitRegion[x^2 + y^2 <= y && x >= 0, {x, y}];
eq = f[x, y] == Sqrt[1 - x^2 - y^2] -
   8/Pi*Inactive[Integrate][f[x, y], Element[{x, y}, reg]]
generalFormOfF = f[x, y] :> Sqrt[1 - x^2 - y^2] + c
eq /. generalFormOfF
% // Simplify
% /. Inactive[Integrate][a_ + b_, w__] :>
  Inactive[Integrate][a, w] + Inactive[Integrate][b, w]
% /. Inactive[Integrate][c, w__] :> Integrate[c, w]
Solve[%, c]
f[x, y] == Sqrt[1 - x^2 - y^2] + c /. %[[1]]
% /.
 Inactive@Integrate -> NIntegrate

Unfortunately, the exact value of the integral seems to take a very long time.

I think it’s okay if the Solve function cannot solve the problem, but it’s a bit unacceptable to give the wrong answer without any hint.

Solve considers the expressions declared as variables to be atomic objects. Effectively they are first replaced with new symbols and then solved for:

In[1]:= f[x, y] ==                                                              
    Sqrt[1 - x^2 - y^2] -                                                       
      8/Pi*Integrate[                                                           
         f[x, y], {x, 0, 1/2}, {y, -Sqrt[1/4 - x^2] + 1/2,                      
           Sqrt[1/4 - x^2] + 1/2}] /. f[x, y]->z // InputForm                   

Out[1]//InputForm= z == Sqrt[1 - x^2 - y^2] - z

In[2]:= Solve[%, z]//InputForm                                                  

Out[2]//InputForm= {{z -> Sqrt[1 - x^2 - y^2]/2}}

This is similar to

In[3]:= Solve[x==Sin[x], Sin[x]]

Out[3]= {{Sin[x] -> x}}

If you specify {x, y} as the variables then f[x, y] is treated as a function of the variables and Solve knows that it cannot solve the equation.

In[4]:= Solve[f[x, y] ==
   Sqrt[1 - x^2 - y^2] -
    8/Pi*Integrate[
      f[x, y], {x, 0, 1/2}, {y, -Sqrt[1/4 - x^2] + 1/2,
       Sqrt[1/4 - x^2] + 1/2}], {x, y}]//Head

Solve::nsmet: This system cannot be solved with the methods available to Solve.
    Try Reduce or FindInstance instead.

Out[4]= Solve

Do you think Mathematica should develop this function to calculate this kind of function?

Possibly, though currently the problem can easily be solved. You just need to separate the integral computation from the algebraic equation solving. The integral computation does take about 20 minutes.

f = Sqrt[1 - x^2 - y^2] + c;  

eqn = (c == -8/Pi*Integrate[f, {x, 0, 1/2}, 
   {y, -Sqrt[1/4 - x^2] + 1/2, Sqrt[1/4 - x^2] + 1/2}]);    

In[16]:= Solve[eqn, c]//FullSimplify//InputForm                                 

Out[16]//InputForm= 
{{c -> (32 - 24*Pi + 6*(-1)^(1/6)*Log[2 + (-1)^(1/6)*Sqrt[2]] + 
     3*Sqrt[3]*Log[5 - 2*Sqrt[6]] + 
     (3*I)*Log[(3 - Sqrt[6] + Root[36 + 60*#1^2 + #1^4 & , 3, 0])/3] - 
     3*Sqrt[3]*Log[Root[3 - 12*#1 + 34*#1^2 - 12*#1^3 + 3*#1^4 & , 2, 0]] + 
     3*((-I)*Pi + Log[-2 + (-1)^(1/6)*Sqrt[2]])*Root[16 - 4*#1^2 + #1^4 & , 1, 
       0])/(36*Pi)}}

And here’s the simple answer, that you probably expect your students to find…

In[21]:= Solve[eqn, c]//TrigToExp//FullSimplify//InputForm                      

Out[21]//InputForm= {{c -> -2/3 + 8/(9*Pi)}}

What computer configuration are you using? I’ve been calculating for 2 hours but still no results.