蓝桥杯 如何计算 X^X = 10 来求X呢?
生活随笔
收集整理的这篇文章主要介绍了
蓝桥杯 如何计算 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\n",ans); 18 }
总结
以上是生活随笔为你收集整理的蓝桥杯 如何计算 X^X = 10 来求X呢?的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 【转载】Linux Shell-条件测试
- 下一篇: MongoDB学习笔记~为IMongoR