How to represent code log(1+A/x),A is a constant

I found a similar one,log(1+1/x)=rel_entr(x,x+1)+rel_entr(x+1,x),but I’m a green hand,I’m not sure I can do that

log(1+A/x) = log(1 + 1/(x/A)) , the RHS of which is in the form of the “similar one”.

So replace x by x/A in the “similar one”. I.e.,
log(1+A/x) = rel_entr(x/A,x/A+1)+rel_entr(x/A+1,x/A)

Note: Credit for the 'similar one" to @Michal_Adamaszek

Thank you for your kind help. I’ll have a try

I substituted the exact values into the two expressions and found that the results were a little different. Is that normal?

They will almost never be equal due to computations are done in finite precision floating point numbers.

Yes that is normal and you would learn about such in a numerical analysis course.