I have a doubt in C! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I have a doubt in C!

Can anyone please tell me how to get the value of logx using taylor series? Do we need to write a program using while loop? Please help me out!

11th Dec 2020, 5:20 PM
Ujwal Sai Simha Y
Ujwal Sai Simha Y - avatar
4 Answers
+ 2
Please clarify, do you wish to implement a series for log(x) [base 10], or for any given log base x? Yes, a while loop would be used when trying to achieve a standard of precision. A for loop would be used if you wish to generate a given number of terms.
11th Dec 2020, 9:53 PM
Brian
Brian - avatar
+ 3
Ujwal Sai Simha Y very well. Here are a couple of tips: To check for precision in a while loop make the condition a comparison of the current term with the smallest error value (epsilon) that you will tolerate. Bear in mind that your epsilon cannot be any smaller than the epsilon for the variable data type (float, double, long double). The data type epsilons are defined in <float.h> as FLT_EPSILON, DBL_EPSILON, and LDBL_EPSILON respectively. After you implement the Taylor series for ln(x) [natural log, base e], it is easy to convert to any base by using log[b](x) = ln(x)/ln(b).
12th Dec 2020, 3:34 PM
Brian
Brian - avatar
+ 2
@Brian Sir Thank you very much! I am a beginner in C and I need some help from seniors! I hope you will help me in the future as well! Thank you very much!
12th Dec 2020, 3:37 PM
Ujwal Sai Simha Y
Ujwal Sai Simha Y - avatar
+ 1
@Brian Yes sir! My doubt has been clarified! I was trying to find the value of log x to the base e using taylor series!
12th Dec 2020, 10:16 AM
Ujwal Sai Simha Y
Ujwal Sai Simha Y - avatar