全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3124 1
2016-11-14
假设方程形式f(x)=exp(exp(-x)),求这个方程与g(x)=x的交点,即exp(exp(-x))=x,则可以使用下面的形式进行 求解:
fixedpoint(ftn,x0,tol):
ftn:表示所要求的方程f(x);注意:不是f(x)-x,要注意和迭代的区别
x0:表示初始的x值。
tol:表示当呈现运行时的精度,即|xn-xn-1|<tol时停止,选取此时的x作为exp(exp(-x))=x的解。
> ftn1 <- function(x) return(exp(exp(-x)))
> fixedpoint(ftn1, 2, tol = 1e-6)
At iteration 1 value of x is: 1.144921
At iteration 2 value of x is: 1.374719
At iteration 3 value of x is: 1.287768
At iteration 4 value of x is: 1.317697
At iteration 5 value of x is: 1.307022
At iteration 6 value of x is: 1.310783
At iteration 7 value of x is: 1.309452
At iteration 8 value of x is: 1.309922
At iteration 9 value of x is: 1.309756
At iteration 10 value of x is: 1.309815
At iteration 11 value of x is: 1.309794
At iteration 12 value of x is: 1.309802
At iteration 13 value of x is: 1.309799
At iteration 14 value of x is: 1.3098
Algorithm converged
[1] 1.3098
> exp(exp(-1.3098))
[1] 1.3097

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2017-10-23 17:47:39
请问fixedpoint这个函数需要加载什么包吗?我直接运行,结果显示找不到这个函数
谢谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群