Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

inverse method / formula for this?

  • 16-04-2009 12:45am
    #1
    Closed Accounts Posts: 259 ✭✭


    Good day

    i have this: x^1 + x^2 + x^3 + x^4

    where x can be a decimal value of between 1 and 10

    if i have a number: 2342 - what is the value of each x?

    is there a multiple root finding algorithm for this?


Comments

  • Closed Accounts Posts: 6,151 ✭✭✭Thomas_S_Hunterson


    You could solve (for x) the equation:
    x^4 + x^3 + x^2 + x^1 = 2342

    What is it for? There are algebraic techniques or you could just use interpolation/estimation (hint, newton-raphson, (6<x<7), assuming it's just the first positive real root that you're looking for)


  • Closed Accounts Posts: 259 ✭✭weiss


    To tell the truth, i don't how to phrase the question which is why I asked a mod (before you replied) that the thread be removed.

    i calculate total combinations for numbers 1 - 10, based on a set of numbers, lets say [2,3,4,2]

    (10 ^ 0) * 2 = 2
    (10 ^ 1) * 4 = 40
    (10 ^ 2) * 3 = 300
    (10 ^ 3) * 2 = 2000

    total: 2 + 40 + 300 + 2000 = 2342

    now i'd like to know an inverse method, where by i get [2,3,4,2] using 10 as the base.

    so all i know is 10 and 2342, need to find what the roots are.


  • Closed Accounts Posts: 259 ✭✭weiss


    dr math probably better explains the calculation of total combinations.

    http://mathforum.org/library/drmath/view/56114.html


  • Closed Accounts Posts: 259 ✭✭weiss


    should have added that the way i tried to do it was using division/modulus

    2432 / (10 ^ 3) = 2
    432 / (10 ^ 2) = 4
    32 / (10 ^ 1) = 3
    2 / (10 ^ 0) = 2

    this is ok, but if i have a set of [10,1,10,1]

    (10 ^ 0) * 10 = 10
    (10 ^ 1) * 1 = 10
    (10 ^ 2) * 10 = 1000
    (10 ^ 3) * 1 = 1000

    total: 10 + 10 + 1000 + 1000 = 2020

    2020 / (10 ^ 3) = 2
    20 / (10 ^ 2) = 0
    20 / (10 ^ 1) = 2
    0 / (10 ^ 0) = 0

    [2,0,2,0]

    i need the original set [10,1,10,1] if possible, must be a formula/method to do this?


  • Closed Accounts Posts: 6,151 ✭✭✭Thomas_S_Hunterson


    I don't think this is possible given the overflow in mod arithmetic.

    What you want to do is somewhat akin to telling someone a number and asking them what two numbers you added to get that number. Obviously there are an infinitude of possibilities.

    2020 could be given as [2,0,2,0], [10,1,10,1], [2020,0,0,0], [2010,1,0,0] etc


  • Advertisement
  • Closed Accounts Posts: 259 ✭✭weiss


    yeah..i'm not able to illustrate/describe it properly unfortunately.

    possibly i need to look at multiple root finding algorithms or factoring algorithm..


  • Closed Accounts Posts: 6,151 ✭✭✭Thomas_S_Hunterson


    weiss wrote: »
    yeah..i'm not able to illustrate/describe it properly unfortunately.

    possibly i need to look at multiple root finding algorithms or factoring algorithm..
    No I'm saying what you want to do is not possible.

    As it stands, the function you are trying to apply to the vector is not injective and therefore no inverse exists.


  • Closed Accounts Posts: 259 ✭✭weiss


    hmm, no disrespect intended Sean_K but i don't believe its impossible, i've just failed to describe what it is i need to do in mathematical terms.

    i see a way to use trial division.

    if the result of a division is zero, this means the previous division was wrong.

    As in previous example: 2020

    In reverse order, start with 1000,decreasing by power of 10 for each element we want.

    First result is 2

    The second division results in zero, but during calculation of total number, its not possible to get result of zero..so it must be 1000 / (10 ^ 2) = 10

    first is now 1, second is 10 ..continue for rest.

    to be honest, i've not described what it is i want to do very well, apologies for that.

    thank you for helping.


  • Closed Accounts Posts: 6,151 ✭✭✭Thomas_S_Hunterson


    Ok I think i see what you mean now; The set is comprised of integer values between 1 and 10? (sorry I assmued zero could be included).

    This should be possible. Thinking about it quickly, subtract 1111 from the initial 4 digit integer (wrapping around from 0 to 9). Then split it out using the modulus/division method above and then add 1 to each of the numbers you end up with. (works in my head, i think)

    /edit: sorry about the confusion, I tend to scan posts.


  • Closed Accounts Posts: 6,151 ✭✭✭Thomas_S_Hunterson


    Alternatively, working iteratively through the 4 digit number starting at the least significant digit:
    Take it's value as the element of the set except if it's zero, in which case, the element of the set will be 10 and then subtract one from the next digit.

    So on a computer you might repeatedly integer-divide the number by 10.

    Take the remainder as your element of the set, except, as above of it is zero, in which case 10 goes in your set and 1 gets subtracted from the quotient.


  • Advertisement
  • Closed Accounts Posts: 15,552 ✭✭✭✭GuanYin


    I'm guessing you want to keep this now?

    Sean K has obviously put time and effort into answering, it would be kinda rude to delete but it's up to you guys.


  • Closed Accounts Posts: 259 ✭✭weiss


    no delete, its ok now


  • Closed Accounts Posts: 2,696 ✭✭✭mark renton


    weiss wrote: »
    should have added that the way i tried to do it was using division/modulus

    2432 / (10 ^ 3) = 2
    432 / (10 ^ 2) = 4
    32 / (10 ^ 1) = 3
    2 / (10 ^ 0) = 2

    this is ok, but if i have a set of [10,1,10,1]

    (10 ^ 0) * 10 = 10
    (10 ^ 1) * 1 = 10
    (10 ^ 2) * 10 = 1000
    (10 ^ 3) * 1 = 1000

    total: 10 + 10 + 1000 + 1000 = 2020

    2020 / (10 ^ 3) = 2
    20 / (10 ^ 2) = 0
    20 / (10 ^ 1) = 2
    0 / (10 ^ 0) = 0

    [2,0,2,0]

    i need the original set [10,1,10,1] if possible, must be a formula/method to do this?

    your logic seems ok, but if your using base 10 then you should never have an integer greater than 9 in your set


  • Closed Accounts Posts: 259 ✭✭weiss


    what i should have seen so simple was to subtract the power from total before doing any modulus/division...:o

    the result in code is roughly..

    [PHP]
    unsigned long long power = 10;

    // get number of elements used to calculate value, must be atleast 1

    for(elements = 1;value >= power;elements++) {
    value -= power; // subtract
    power *= 10; // multiply
    }

    for(int index = 0;index < elements;index++) {
    num_set[index] = (value % 10); // modulus
    value /= 10; // divide
    }
    [/PHP]

    really simple thing.. thank you all for helping


Advertisement