Exemple #1
0
def incremental_search():
    form = rootAlgorithms()
    result = []
    message = []
    if request.method == 'POST':
        f_x = form.function.data
        x_0 = form.x_0.data
        h = form.inter_h.data
        n = form.n_max.data
        tol = form.tol.data
        x = symbols('x', real=True)
        parser = parse_expr(f_x, locals())
        data = busqueda_incremental(parser, x_0, h, n, tol)

        if len(data[1]):
            result = zip(*[i for i in data[1].values()])
        else:
            result = ""

        message = data[0]
        #form.result.data = result

    return render_template("incremental_search.html",
                           form=form,
                           result=result,
                           message=message)
Exemple #2
0
def multiple_roots():
    form = rootAlgorithms()
    result = []
    message = []
    if request.method == 'POST':
        f_x = form.function.data
        f_x_derivate = form.first_derivate.data
        f_x_derivate_2 = form.second_derivate.data
        n_max = form.n_max.data
        x_n = form.x_0.data
        tol = form.tol.data
        x = symbols('x', real=True)
        parser_f = parse_expr(f_x, locals())
        parser_f_derivate = parse_expr(f_x_derivate, locals())
        parser_f_derivate_2 = parse_expr(f_x_derivate_2, locals())
        data = multipleRoots_method(tol, x_n, n_max, parser_f,
                                    parser_f_derivate, parser_f_derivate_2)
        print(data)

        if len(data[0]) > 0:
            result = zip(*[i for i in data[0].values()])
        else:
            result = ""

        message = data[1]

    return render_template("multiple_roots.html",
                           form=form,
                           result=result,
                           message=message)
Exemple #3
0
def bisection():
    form = rootAlgorithms()
    result = []
    message = []
    if request.method == 'POST':
        inter_a = form.inter_a.data
        inter_b = form.inter_b.data
        f_x = form.function.data
        n = form.n_max.data
        tol = form.tol.data
        x = symbols('x', real=True)
        parser = parse_expr(f_x, locals())
        data = biseccion(parser, inter_a, inter_b, n, tol)

        if len(data[1]):
            result = zip(*[i for i in data[1].values()])
        else:
            result = ""

        message = data[0]
        #form.result.data = result[1]

    return render_template("bisection.html",
                           form=form,
                           result=result,
                           message=message)
Exemple #4
0
def newton():
    form = rootAlgorithms()
    result = []
    message = []
    if request.method == 'POST':
        f_x = form.function.data
        f_x_derivate = form.first_derivate.data
        x_n = form.x_0.data
        tol = form.tol.data
        n = form.n_max.data
        x = symbols('x', real=True)
        parser_f = parse_expr(f_x, locals())
        parser_f_derivate = parse_expr(f_x_derivate, locals())
        data = newton_method(x_n, tol, n, parser_f, parser_f_derivate)

        if len(data[1]) > 0:
            result = zip(*[i for i in data[1].values()])
        else:
            result = ""

        message = data[0]

    return render_template("newton.html",
                           form=form,
                           result=result,
                           message=message)
Exemple #5
0
def secant():
    form = rootAlgorithms()
    result = []
    message = []

    if request.method == 'POST':
        f_x = form.function.data
        x_0 = form.x_0.data
        x_1 = form.x_1.data
        tol = form.tol.data
        n = form.n_max.data
        x = symbols('x', real=True)
        parser = parse_expr(f_x, locals())
        data = secante_method(x_0, x_1, tol, n, parser, f_x)

        if len(data[1]):
            result = zip(*[i for i in data[1].values()])
        else:
            result = ""

        message = data[0]

    return render_template("secant.html",
                           form=form,
                           result=result,
                           message=message)
Exemple #6
0
def fixed_point():
    form = rootAlgorithms()
    result = []
    message = []
    if request.method == 'POST':
        f_x = form.function.data
        g_x = form.function_g.data
        x_0 = form.x_0.data
        tol = form.tol.data
        n = form.tol.data
        x = symbols('x', real=True)
        parser_f = parse_expr(f_x, locals())
        parser_g = parse_expr(g_x, locals())
        data = puntoFijo(f_x, g_x, parser_f, parser_g, x_0, tol, n)

        if len(data[1]):
            result = zip(*[i for i in data[1].values()])
        else:
            result = ""

        message = data[0]

    return render_template("fixed_point.html",
                           form=form,
                           result=result,
                           message=message)
Exemple #7
0
def steffenson():
    form = rootAlgorithms()
    result = []
    if request.method == 'POST':
        f_x = form.function.data
        x_0 = form.x_0.data
        tol = form.tol.data
        n = form.n_max.data
        result = steff(f_x, x_0, tol, n)
        #form.result.data = result
        result = zip(*[i for i in result.values()])

    return render_template("steffenson.html", form=form, result=result)
Exemple #8
0
def muller():
    form = rootAlgorithms()
    result = []
    message = []
    if request.method == 'POST':
        f_x = form.function.data
        x_0 = form.x_0.data
        x_1 = form.x_1.data
        x_2 = form.x_2.data
        x = symbols('x', real=True)
        parser = parse_expr(f_x, locals())
        result = muller_method(x_0, x_1, x_2, parser)

    return render_template("muller.html",
                           form=form,
                           result=result,
                           message=message)