1 Star 0 Fork 0

Time-Coder/IterativeRootFinder

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

寻找函数迭代根

IterativeRootFinder.py 提供了一个寻找函数迭代根的类。用于寻找定义在 [0, 1] 上的严格单调递增的连续自映射函数的二次迭代根。方法如下:

import math
import numpy as np
import matplotlib.pyplot as plt
from IterativeRootFinder import *

# 定义一个待求迭代根的函数 g
def g(x):
    return math.sin(math.pi/2*x)

# 在 ]0, 1[ 范围内任选两个数 Lambda 和 Mu
Lambda = 0.5
Mu = 0.5

# 定义一个 [0, 1] 映射到 [0, 1] 的严格单调递增的连续自映射 alpha
def alpha(t):
    return t

# 将 g, Lambda, Mu, alpha 传入 IterativeRootFinder
root_finder = IterativeRootFinder(g, Lambda, Mu, alpha)

# 绘制 g(x), f(x), f(f(x)) 的图像
x = np.linspace(0, 1, 300)
yf = np.zeros((300,))
yg = np.zeros((300,))
yff = np.zeros((300,))

for i in range(x.shape[0]):
    yg[i] = g(x[i])
    yf[i] = root_finder.f(x[i])
    yff[i] = root_finder.f(root_finder.f(x[i]))

plt.plot(x, yg, label="y = g(x)")
plt.plot(x, yf, color=(140/255,117/255,112/255), label="y = f(x)")
plt.plot(x, yff, 'r--', label="y = f(f(x))", linestyle='--', dashes=(4, 4))
plt.legend(loc='upper left')

plt.xlim(0, 1)
plt.ylim(0, 1)
ax = plt.gca()
ax.set_aspect(1)

plt.show()

您可直接运行 main.py,也可修改 main.py 以适应您的需求。

空文件

简介

用户寻找函数迭代根的 Python 程序 展开 收起
取消

发行版

暂无发行版

贡献者 (1)

全部

语言

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/time-coder/IterativeRootFinder.git
git@gitee.com:time-coder/IterativeRootFinder.git
time-coder
IterativeRootFinder
IterativeRootFinder
main

搜索帮助