Subtracting the overlap of functions

Click For Summary
To subtract one function from another only where they overlap, it is sufficient to perform a straightforward subtraction, f(x) - g(x), in the overlapping region where both functions are non-zero. However, care must be taken in regions of non-overlap, as this can affect the outcome due to the functions potentially being zero. To ensure both functions remain non-negative before subtraction, one can restrict the functions to their non-negative ranges. A method to achieve this involves defining a region indicator function that is 1 where the functions overlap and 0 elsewhere, allowing for a clean subtraction. This approach effectively isolates the overlapping area for accurate evaluation.
2thumbsGuy
Messages
24
Reaction score
0
I have a fun project I'm trying to do and it's been a good number of years since I did any math higher than algebra. As such, I don't know how to approach this and would like some pointers.

I am trying to understand how I can subtract one function from another ONLY where the two functions overlap. The first part is easy enough (algebra), but the caveat is challenging to my grey matter. Can anyone advise me on how to approach this?

Thank you,

2thumbs
 
Physics news on Phys.org
If two functions overlap in some region, it means they're both non-zero in that region. And in the regions where there is no overlap between them, it means at least one of them is zero in that region.So when you write f(x)-g(x), it only changes the value of the functions in the regions that they have overlap and so you don't have to do anything special, just subtract them!
 
I didn't think it would be that simple... let me just do that and see what I come up with. Thanks!
 
2thumbsGuy said:
I didn't think it would be that simple... let me just do that and see what I come up with. Thanks!
Just one more point. If you write f(x)-g(x), and then calculate it in a region where f(x)=0, although there is no overlap, g(x) will change because it gets multiplied by a minus sign. So a little modification to a simple subtraction is needed.
 
OK, I find it to be desirable where f(x) >= 0 and g(x) >= 0, so how can I restrict the function to that range before performing the subtraction? Or is it specific to the function?

EDIT

Here are the graphs I came up with to evaluate your statement:

Graph 1 ( f(x) )
http://www.wolframalpha.com/input/?i=-x^4+3x

Graph 2 ( g(x) )
http://www.wolframalpha.com/input/?i=-x^2+4x

Graph 3 ( g(x) - f(x) )

You can see on graph 3 the function at the right goes happily off to infinity on the y axis. Obviously this is because f(x) goes off to negative infinity faster than g(x) goes to negative infinity, so when inverted, f(x) wins. But if I stop them at zero before the subtraction, then I get my tidy little graph... I think
 
Last edited:
2thumbsGuy said:
I have a fun project I'm trying to do and it's been a good number of years since I did any math higher than algebra. As such, I don't know how to approach this and would like some pointers.

I am trying to understand how I can subtract one function from another ONLY where the two functions overlap. The first part is easy enough (algebra), but the caveat is challenging to my grey matter. Can anyone advise me on how to approach this?

Thank you,

2thumbs

It depends on what you are trying to do when they do not overlap. A sketch: Let A be the region where they overlap, define XA as 1 on A and 0 outside A. Then define f1 = f* XA and g1=g*XA. Now f1-g1 = f-g on A and 0 outside A.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 72 ·
3
Replies
72
Views
5K
  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
2
Views
3K