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

  • SEARCH
  • Home
  • 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 6324525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:43:14+00:00 2026-05-24T16:43:14+00:00

I have posted a part of my code below. Newton() function calls Bezier() function.

  • 0

I have posted a part of my code below. Newton() function calls Bezier() function. The Bezier() function has a list from where I get p0 and p3. What I am trying to do is, in 1st iteration the program should take the first and second items from the plist as p0 and p3. Then in 2nd iteration, p0 and p3 are the second and third items and so on. With each iteration, the p0 and p3 values should change. It’s like the new p0 is the old p3. I could not put this in the code properly. Thank you.

import math

w = 1.0

def Newton(poly):
    """ Returns a root of the polynomial"""
    x = 0.5  # initial guess value
    counter = 0
    epsilon = 0.000000000001
    poly_diff = poly_differentiate(poly)

    while True:
        x_n = x - (float(poly_substitute(poly, x)) / float(poly_substitute(poly_diff, x)))
        counter += 1
        if abs(x_n - x) < epsilon :
            break
        x = x_n
        print "\tIteration " , counter , " : ", x_n

    print "u: ", x_n
    Bezier(x_n)

def Bezier(x_n) :
    """ Calculating sampling points using rational bezier curve equation"""
    u = x_n
    plist = [0.5, 0.1, 0.4, 0.35, 0.8, 0.6, 1.0, 0.2, 0.7, 0.9] # list of parameter values of the phonemes

    for i in range(len(plist) - 1) :
        p0 = plist[i]
        p3 = plist[i + 1] 
        p1 = p0
        p2 = p3
        print p0, p3   
        p_u = math.pow(1 - u, 3) * p0 + 3 * u * math.pow(1 - u, 2) * p1 \
            + 3 * (1 - u) * math.pow(u, 2) * p2 + math.pow(u, 3) * p3
        p_u = p_u * 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
        p_u = p_u / d

    print "p(u): ", p_u
    return plist

if __name__ == "__main__" :
  • 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-24T16:43:15+00:00Added an answer on May 24, 2026 at 4:43 pm

    Change the top of your Bezier function to look like

    def Bezier(x_n, p0, p3) :
        """ Calculating sampling points using rational bezier curve equation"""
        u = x_n
        p1 = p0
        p2 = p3
    

    getting rid of that loop and the plist completely.

    Then, in your time function (from my answer to your previous question getting a boundary of an item from another list), change it to look like:

    def time() :
        tlist = [0.0, 0.12, 0.16, 0.2, 0.31, 0.34, 0.38, 0.46, 0.51] # list of start time for the phonemes
        plist = [0.5, 0.1, 0.4, 0.35, 0.8, 0.6, 1.0, 0.2, 0.7, 0.9] # list of parameter values of the phonemes
    
        total_frames = math.floor(tlist[-1] / 0.04)
        t_u = 0.0
        i = 0
        while i < len(tlist) - 1:
            # if the number is in the range
            # do the calculations and move to the next number
            if t_u > tlist[i] and t_u < tlist[i + 1] :
                print "\n The t_u value:", t_u, 'is between',
                print "start:", tlist[i], " and end: ", tlist[i+1]
                poly = poly_coeff(tlist[i], tlist[i + 1], t_u)
                Newton(poly, plist[i], plist[i+1])
                t_u = t_u + 0.04 # regular time interval
    
            # if the number is at the lower boundary of the range no need of calculation as u = 0
            elif t_u == tlist[i] :
                print "\n The t_u value:", t_u, 'is on the boundary of',
                print "start:", tlist[i], " and end: ", tlist[i+1]
                print "u : 0"
                Bezier(0, plist[i], plist[i+1])
                t_u = t_u + 0.04 # regular time interval
    
            # if the number is at the upper boundary of the range no need of calculation as u = 1
            elif t_u == tlist[i + 1] :
                print "\n The t_u value:", t_u, 'is on the boundary of',
                print "start:", tlist[i], " and end: ", tlist[i+1]
                print " u : 1"
                Bezier(1, plist[i], plist[i+1])
                t_u = t_u + 0.04 # regular time interval
    
            # if the number isn't in the range, move to the next range
            else :
                i += 1
    

    The only changes are putting the plist there and passing the plist values to Newton and Bezier.

    The only changes to you Newton function are to change the first line to

    def Newton(poly, p0, p3):
    

    and the last line to

        Bezier(x_n, p0, p3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the working code pasted below which has a function called FormatStatus() as
Ok so the title may have been confusing so i have posted 2 code
I have already posted a question about this, but the situation has changed sufficiently
I am sorry if this has been posted before. I have searched many websites
I have a table generated from some PHP code that lists a SMALL amount
I have a pagination script which I have posted below, the problem is I
I trying to display image in picture box. The application have two part. First
I am trying to write the strstr function from scratch. I went through my
The following code was part of an answer I have received to solve a
I have posted a question about multilanguage database design here, [] What are best

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.