# Subtracting 2 histograms using ROOT

**URL:** <https://root-forum.cern.ch/t/subtracting-2-histograms-using-root/51902>\
**Category:** Newbie\
**Created:** [October 9, 2022, 2:55pm UTC](https://root-forum.cern.ch/t/subtracting-2-histograms-using-root/51902 "2022-10-09T14:55:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![roriana9](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/f4b2a3/32.png) [@roriana9](https://root-forum.cern.ch/u/roriana9)\
**Post date:** [October 9, 2022, 2:55pm UTC](https://root-forum.cern.ch/t/subtracting-2-histograms-using-root/51902/1 "2022-10-09T14:55:58Z")

</div>

Hello  
I am trying to subtract 2 histograms by using  
new-\>Add(h1, h2, -1.0, 1.0);  
it give me the expected number of entries, but the distribution is flat, while it is supposed to be gauss.  
here the code I am using, if anyone have any ideas let me know please.  
many thanks in advance.  
[dif.cc](https://root-forum.cern.ch/uploads/short-url/obkOi7X1V9dssRRDs11WBQlFQwR.cc) (578 Bytes)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 9, 2022, 3:04pm UTC](https://root-forum.cern.ch/t/subtracting-2-histograms-using-root/51902/2 "2022-10-09T15:04:39Z")

</div>

Your “ang” histogram has just one bin.

---

<div class="post-metadata">

**Author:** ![roriana9](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/f4b2a3/32.png) [@roriana9](https://root-forum.cern.ch/u/roriana9)\
**Post date:** [October 9, 2022, 4:49pm UTC](https://root-forum.cern.ch/t/subtracting-2-histograms-using-root/51902/3 "2022-10-09T16:49:03Z")

</div>

Thanks for your response, I edited it and it is working now
