Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6192275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:54:56+00:00 2026-05-24T02:54:56+00:00

I have been doing python programming for my project and I have just started.

  • 0

I have been doing python programming for my project and I have just started. This might be another trivial question. I have this code in which I need to use a value calculated in the function poly_root() which is x. That value should be used as u in the bezier() function. After poly_root() function it should go to bezier() function with its calculated value. I dont know if I am doing it in the correct way. There is no error but it doesnt print t from the bezier() function. Thank you very much.

import copy

import math

poly = [[-0.8,3], [0.75,2], [-0.75,1], [0.1,0]]

def poly_diff(poly):
    """ Differentiate a polynomial. """
    newlist = copy.deepcopy(poly)

    for term in newlist:
        term[0] *= term[1]
        term[1] -= 1

    return newlist

def poly_apply(poly, x):
    """ Apply values to the polynomial. """

    sum = 0.0 # force float

    for term in poly:
        sum += term[0] * (x ** term[1])

    return sum

def poly_root(poly, start, n, r_i):
    """ Returns a root of the polynomial, with a starting value."""

    poly_d = poly_diff(poly)
    x = start # starting guess value
    counter = 0

    while True:
        if (n >= 0) and (n < 1):
            break

        x_n = x - (float(poly_apply(poly, x)) / poly_apply(poly_d, x))

        if x_n == x:
            break

        x = x_n # this is the u value corresponding to the given time which will be used in bezier equation

        n -= 1
        counter += 1

    if r_i:
        #print [x, counter])
        return [x, counter]
    else:
        #print x
        return x
    bezier(x)

def bezier(value) :
    """ Calculates control points using rational bezier curve equation"""

    u = value
    w = 5

    t = math.pow(1-u,3) * points[0][0] + 3 * u * math.pow(1-u,2) * points[1][0] \
        + 3 * (1-u) * math.pow(u,2) * points[2][0] + math.pow(u,3) * points[3][0]

    t = t * w

    d = math.pow(1-u,3) * w + 3 * u * w * math.pow(1-u,2) + 3 * (1-u) * w \  
        * math.pow(u,2) + math.pow(u,3) * w  


    t = t / d
    print t

if __name__ == "__main__" :
    poly_root(poly, 0.42, 1, 0)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:54:57+00:00Added an answer on May 24, 2026 at 2:54 am

    In this part of code:

    if r_i:
        #print [x, counter])
        return [x, counter]
    else:
        #print x
        return x
    bezier(x)
    

    bezier(x) is unreachable. You need to rewrite it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing a little reading on Flow Based Programming over the last
I'm starting to learn Excel Programming and have been doing the development in Excel
Since I've started to use jQuery, I have been doing a lot more JavaScript
We have been doing some research into physically isolating the secure and non-secure sections
I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been
Alright, I have been doing the following (variable names have been changed): FileInputStream fis
My background is primarily as a Java Developer, but lately I have been doing
I would like to compare two dates in javascript. I have been doing some
I have recently been doing a bit of investigation into the different types of
I've not used C++ very much in the past, and have recently been doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.