# Solve with Integrate wouldn't produce correct answers

**URL:** <https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861>\
**Category:** Questions\
**Tags:** calculus, equation-solving, symbolic-computations\
**Created:** [April 12, 2024, 2:24am UTC](https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861 "2024-04-12T02:24:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhenyuzeng](https://avatars.discourse-cdn.com/v4/letter/z/ecb155/32.png) [@zhenyuzeng](https://community.wolfram.com/u/zhenyuzeng)\
**Post date:** [April 12, 2024, 2:24am UTC](https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861/1 "2024-04-12T02:24:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [April 12, 2024, 9:31am UTC](https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861/2 "2024-04-12T09:31:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zhenyuzeng](https://avatars.discourse-cdn.com/v4/letter/z/ecb155/32.png) [@zhenyuzeng](https://community.wolfram.com/u/zhenyuzeng)\
**Post date:** [April 12, 2024, 9:47am UTC](https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861/3 "2024-04-12T09:47:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adams](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/adams/32/31805_2.png) [@adams](https://community.wolfram.com/u/adams)\
**Post date:** [April 12, 2024, 8:53pm UTC](https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861/4 "2024-04-12T20:53:32Z")

</div>

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

```auto
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

```auto
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.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![zhenyuzeng](https://avatars.discourse-cdn.com/v4/letter/z/ecb155/32.png) [@zhenyuzeng](https://community.wolfram.com/u/zhenyuzeng)\
**Post date:** [April 13, 2024, 1:41am UTC](https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861/5 "2024-04-13T01:41:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adams](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/adams/32/31805_2.png) [@adams](https://community.wolfram.com/u/adams)\
**Post date:** [April 13, 2024, 4:37am UTC](https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861/6 "2024-04-13T04:37:57Z")

</div>

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.

```auto
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)}}

```

---

<div class="post-metadata">

**Author:** ![adams](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/adams/32/31805_2.png) [@adams](https://community.wolfram.com/u/adams)\
**Post date:** [April 13, 2024, 4:46am UTC](https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861/7 "2024-04-13T04:46:58Z")

</div>

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

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

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

```

---

<div class="post-metadata">

**Author:** ![anon21378091](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@anon21378091](https://community.wolfram.com/u/anon21378091)\
**Post date:** [April 13, 2024, 7:31am UTC](https://community.wolfram.com/t/solve-with-integrate-wouldnt-produce-correct-answers/23861/8 "2024-04-13T07:31:45Z")

</div>

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