+ 2

Make funtion f(x)=ln(x+1)-ln(x)

help me

1st Oct 2017, 5:55 AM
tri agustinus
4 Answers
+ 14
#include <cmath> ... double func(double x) { return log(x + 1) - log(x); } int main() { double num = 5.0; std::cout << func(num); }
1st Oct 2017, 6:06 AM
Babak
Babak - avatar
+ 7
@Oma Falk You will have to use brackets there. log(x+1/x) != log((x+1)/x)
1st Oct 2017, 8:22 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
#include <cmath> ... double mylog(double x) { return log(x + 1/x); }
1st Oct 2017, 6:36 AM
Oma Falk
Oma Falk - avatar
+ 3
@Kinshuk good idea (-:
1st Oct 2017, 10:56 AM
Oma Falk
Oma Falk - avatar