コード例 #1
0
def g(theta_deg: float) -> float:
    return math.sin(math.radians(theta_deg))**2 - 0.5

    if "__main__" == __name__:

        theta_deg_seq = sequential(g, 0.0, 1e-5, 1e-3, 180)
        theta_rad_seq = np.deg2rad(theta_deg_seq)
        print(f"sin({theta_deg_seq:g}[deg]) ** 2 =", np.sin(theta_rad_seq)**2)
コード例 #2
0
ファイル: yield.py プロジェクト: kangwonlee/15ecab
def main():
    root_finding.epsilon = 1e-9
    r_init = root_finding.epsilon
    delta_r = 1e-6
    result = root_finding.sequential(problem_to_solve, r_init, delta_r)
    print "result =", result
    print "f(result)=", problem_to_solve(result)

    result_bisection = root_finding.bisection(problem_to_solve, result - delta_r, result)
    print "result_bisection =", result_bisection
    print "f(result_bisection) =", problem_to_solve(result_bisection)

    help(root_finding.sequential)
コード例 #3
0
ファイル: yield.py プロジェクト: kangwonlee/15ecab
def main():
    root_finding.epsilon = 1e-9
    r_init = root_finding.epsilon
    delta_r = 1e-6
    result = root_finding.sequential(problem_to_solve, r_init, delta_r)
    print "result =", result
    print "f(result)=", problem_to_solve(result)

    result_bisection = root_finding.bisection(problem_to_solve,
                                              result - delta_r, result)
    print "result_bisection =", result_bisection
    print "f(result_bisection) =", problem_to_solve(result_bisection)

    help(root_finding.sequential)
コード例 #4
0
ファイル: use_sequential.py プロジェクト: kangwonlee/15ecab
# -*- coding: cp949 -*-
import root_finding

def f2(x):
    return float(x*x) - 3.0

print root_finding.sequential(f2, 0.01)

print root_finding.sequential(root_finding.func, 0.01)
コード例 #5
0
import numpy as np

from root_finding import sequential


def f(x_i):
    return x_i**2 - 10


if "__main__" == __name__:

    sqrt_10_seq = sequential(f, 0.0, 1e-5, 1e-3, 6)

    print(f"{sqrt_10_seq:g} ** 2 =", sqrt_10_seq**2)
コード例 #6
0
 def test_sequential(self):
     result = rf.sequential(f, 2.0, 1e-4)
     self.assertAlmostEqual(0.0, f(result), places=3)