蓝桥杯 如何计算 X^X = 10 来求X呢?

题目中有说道:X的取值范围大于2小于3

高数书上中方程的近似解有讲到到;(同济第六版180页)

ln(x^x)- ln(10)=0;

x*ln(x) -ln(10)=0;

假设:F(x) =  X*ln(X)- ln(10);

则第一次循环的时候为:刚开始时  ans = 3 ;

              ans = ans -F(x)/F(x)'

一下是六次的解:

 1 #include<iostream>
 2 #include<algorithm>
 3 #include<cstdio>
 4 #include<cstring>
 5 #include<queue>
 6 #include<string>
 7 #include<cmath>
 8 using namespace std;
 9 int main()
10 {
11     double MM  = log((double)10),ans = 3.0;//表示ln(10)的值;
12     int T = 6;                            
13     while(T--)
14     {
15         ans =  ans - (ans*log((double)ans)-MM)/(1+(log((double)ans)));
16     }
17     printf("%.6lf
",ans);
18 }
原文地址:https://www.cnblogs.com/lovychen/p/4409985.html