Why is this integral different when the variable is substituted?

In Mathematica, typing

Integrate[Abs[-0.7 - y]*(1 - Abs[y]), {y, -1, 1}]

yields 0.709, but typing

Integrate[Abs[x - y]*(1 - Abs[y]), {y, -1, 1}] /. x -> -0.7

yields 1/3. I am not experienced with Mathematica but I was hoping someone would be able to explain to me why these give different answers.

The general formula created for symbolic x seems to contain an error unfortunately:

sol = Integrate[Abs[x - y]*(1 - Abs[y]), {y, -1, 1}]
num = Table[{x, NIntegrate[Abs[x - y]*(1 - Abs[y]), {y, -1, 1}]}, {x, -2, 2, 0.1}]
Show[{Plot[sol, {x, -2, 2}], ListPlot[num]}]

If you explicitly specify x to be a real number the answer is correct:

Integrate[Abs[x - y]*(1 - Abs[y]), {y, -1, 1}, Assumptions -> x \[Element] Reals]
Plot[%, {x, -2, 2}]

Submitted as product feedback (CASE:3868504) with the following minimal working example:

f=-Abs[y-x] Abs[y] (* without the minus in front it is ok actually !! *)
sol=Integrate[f,{y,-1,1}];
numsol=Table[{x,NIntegrate[f,{y,-1,1}]},{x,-2,2,0.1}];
Show[{ListPlot[numsol],Plot[sol,{x,-2,2}]}]

(* with the assumption that x is a real number it is ok *)
f=-Abs[y-x] Abs[y] 
sol=Integrate[f,{y,-1,1},Assumptions->x\[Element]Reals];
numsol=Table[{x,NIntegrate[f,{y,-1,1}]},{x,-2,2,0.1}];
Show[{ListPlot[numsol],Plot[sol,{x,-2,2}]}]

@Alexander Dunlap , I am probably way out of my league in trying to assistant in issues such as this, but I was just watching a very introductory video entitled “Introduction to the Wolfram Language Part 2” by @Lowri Nia Knibbs Vaughan of Wolfram Research and thought I heard something that addressed this very issue, or something similar to it, but unfortunately I do not have the time right now to search though all 47 minutes of it to find what reminded me of what I thought may answer your question more directly, but I believe it was somewhere between 20 and 30 minutes into it. Hope this is not a waste of your time, but I wanted to share at least something as it seems the larger this community gets the more questions and the less people to answer them, at least in my experience back a year or two ago when only 4000 people were on here it seemed you could get an answer within a few hours now sometimes I see many questions are not getting any responses, even though we are about 14240 (at the time of writing this post, and growing more everyday) So I guess it means we each have to pitch in a bit more, and do what we can, when we can. Good luck and let me know if this helps. If and when I find more time I will try to find the actual time stamped location of the video and link more directly to it. By then however I hope you get an answer from someone in the group that can answer your question more directly.

Thanks Sander it took me longer to write my response, then it took Alexander to get a more accurate response from you :).

Yes I noticed that the symbolic expression was wrong, but I wanted to send a more clear-cut test-case. :slight_smile:

See my updated reply above, I submitted it as product feedback…

Thank you!!