I’m currently using Julia to perform utility optimization on an n-period model with one stock implementing a buy-and-hold strategy. I want to generalize my program to find the optimal number of shares for any general utility function U(x) of the form

U(x) = 1/\beta * x^\beta

Where x represents the terminal capital at time n. I’m using the PolynomialRoots packages to find the roots of the expected value of U(x) (E[U(x)], x is of type Polynomial), but I’m running into an issue where I can’t raise the Polynomial type to a power. I was able to work around this when using specific integer values (just by doing x * x * x instead of x^3, etc.), but now that I want to generalize it I’m stuck on how to do it for non-integer values like 1/2, 1/3, etc. Ideally, I would be able to do this for any rational value of \beta.

Any help/tips would be much appreciated! Thanks for your time.

I don’t understand what you mean by computing non-integer powers. Polynomials raised to fractional powers are generally no longer polynomials. You’ll need to reformulate your problem a bit in order to exploit fast root-finding procedures, I’m guessing; I’m not completely clear on what you are doing, but maybe you can reformulate your problem to put it back in terms of positive integer powers of your polynomial.

Can’t you just evaluate the polynomial, obtain the x, and raise that to a power to calculate U? This would, of course, require a general optimization algorithm like (L)BGFS in Optim.jl, but if your problem is well-behaved it should be fine.