Friday, August 24, 2012

I can haz math help?

I feel a little silly making an appeal like this, but I'm stumped.

I'm trying to solve an equation for a variable. The equation has a bunch of stuff in it that makes it look messy, but they're really just parameters and can be easily subsumed so that the basic form of the equation is:

aX + bX1+c + d = 0, where 0 < c < 1, and the reciprocal of c is not necessarily an integer either.

Mathematica protests to me that it is not up to the task of solving this.

I've poked around and there are a couple work-arounds - usually involving some substitution - for solving a non-integer polynomials but (as far as I can tell - because I'm having trouble applying them to this problem) they all only really seem to work if the non-integer polynomial is less than one and this is definitely more than one.

Anyone know how to solve this (or a program that would be better at it than Mathematica)? If you've got such a program handy, a general solution to the equation above would work fine.

Thanks in advance - if this ever sees the light of day you will certainly be acknowledged, if you like. Something like "My dumb ass made it through a bunch of the math and was kicked over the finish line by X".

I am hoping that this is easy enough that someone will be able to answer but tough enough that I don't have to feel dumb for asking.

14 comments:

  1. Does it help to divide it by X^2? That would make the non-integer polynominal less than one.

    ReplyDelete
  2. hmmm.. that will add a negative exponent on the third term on the LHS but it may still be easier to simplify. I'll try that out. Thanks.

    ReplyDelete
    Replies
    1. Not just the third term, also the first aX -> a/X.

      Delete
  3. Well if its greater than 1 you can rewrite X^A as X^(B+1) with B positive and then you no longer have a polynomial, since X^(1+B) = X*X^B. Sorry I have no idea how to solve that though :)

    ReplyDelete
  4. I'm rather sceptical that general solution exists - e.g. if c=0.2, make substitution x = y^5 and get sixth degree polynomial, but there are no general formulas for roots of polynomials with degree higher than 5. In any case you can solve for X numerically with FindRoot function (though you need to specify values for all parameters first). Or if you are after some comparative statics results, you can get derivative of x wrt. parameters by implicit function theorem, without solving the equation itself.

    ReplyDelete
    Replies
    1. re: "Or if you are after some comparative statics results, you can get derivative of x wrt. parameters by implicit function theorem, without solving the equation itself."

      Ya I wasn't getting anywhere with Current's (good suggestion to move it forward - just didn't seem to get me to a place that helped), so I decided to do exactly this. Of course working it out would be nice, but all I need is the derivative wrt just one of the parameters.

      Thanks for verifying that. I think it'll do.

      Delete
  5. I don't think you can get a closed form for the solution in general (i.e. without knowing a,b,c,d).

    If you really need a general solution, you can ask at math.stackexchange.com. The equation is simple enough that the answer might be known.

    An alternative method (that is probably not very good) would be to approximate the location of the zero as well as possible, then replace X^(1+c) with its quadratic approximation (calculated from its Taylor expansion at the approximate zero). What is left is a quadratic equation, which you can solve. From the error term in the quadratic approximation, you should be able to bound the error in your calculation of the zero.

    ReplyDelete
    Replies
    1. Oh that's a great site - thanks. I submitted one in case there is a general solution. I'll probably opt for just puling out the derivative rather than botching up the alternative you've got (which I'm likely to). thanks BR.

      Thanks everyone for the thoughts.

      Delete
  6. If Mathematica objects, I don't know. It seems like it would be amenable to Newton's method of approximation:

    Rewrite it as X^(1+c) + a*X + b = 0.

    Then X(n+1) = X(n) - (X(n)^(1+c) + a*X(n) + b)/((1+c)*X(n)^c + a)

    Two possibilities for X(0) are -b/a and (-a)^(1/c).

    ReplyDelete
  7. a,b,c and d are parameters and you want to solve for X.

    If the substitutions work for non-integer polynomials with powers less than or equal to one then try starting with the substitution Y = X^(1+c). Then your formula becomes aY^((1/(1+c)) + b Y + d = 0.

    Alternatively consider:

    First, X has to be a positive number.

    Second, there will not be a root for every combination of parameters.

    Third, if there is a root, Newton's method should trivially find it from any reasonable first approximation including X(0) = 0.

    Fourth, you can use a standard spreadsheet to play with the model:
    1) associate the parameters with particular cells of the spreadsheet
    2) identify a cell as the first approximation
    3) create a formula that does one step of the newton iteration and generates a new approximation. the formula has to refer to the first approximation and the parameters but the references to the parameters have to be fixed ( $A$1 type of references ) The formula goes immediately below the first approximation
    4) copy the iteration formula into the next ten (or so) lines so that each copy of the formula relies on the approximation immediately preceding it.

    Now the approximation should cascade down the spreadsheet with each approximation doubling the number of correct digits. The approximation will converge by line 5 or 6 in most cases. Now you can play with the parameters and the spreadsheet just solves automatically rather than you having to explicitly run Solver or a similar add in.

    This type of approach to iteration can be used to implement a bi-section method for root finding if you don't want to do derivatives or if the equation is badly behaved but the programming is trickier.


    ReplyDelete
  8. For some combinations of the parameters, the equation will have two roots.

    ReplyDelete
  9. Newton's Method. Closed form solutions are either non-existent or excessively laborious unless c=1.

    ReplyDelete
    Replies
    1. Ya this is what I'm converging on. c in this case actually started out its career in this model as diminishing returns to a certain productive process (military spending, in this case). I think I'm just going to assume constant returns and be done with it. The diminishing returns is not a central feature of what I'm trying to show. Always unfortunate to have to do that.

      Thanks everyone. I'll keep Newton's method in mind if they really don't like that.

      Delete
  10. Nowadays math can be learn easily by help of online tutors.Online tutoring is very helpful in studies of students as those students who can't bear the fees of tutor,they can take help of e-tutors.

    ReplyDelete

All anonymous comments will be deleted. Consistent pseudonyms are fine.