Message Boards Message Boards

0
|
7170 Views
|
6 Replies
|
4 Total Likes
View groups...
Share
Share this post:

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.

POSTED BY: Alexander Dunlap
6 Replies

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

POSTED BY: Alexander Dunlap

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

POSTED BY: Sander Huisman

@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.

POSTED BY: Brian Woytovich

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]}]

enter image description here

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}]

enter image description here

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}]}]
POSTED BY: Sander Huisman

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

POSTED BY: Brian Woytovich

Thank you!!

POSTED BY: Alexander Dunlap
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract