Ensure integral don't become complex
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi. I'm trying to optimize a integral of a function on the form of:
sin(acos(x - cos(Phi(x) - pi/4)) + pi/4)
where Phi(x) is a polynomial of some degree (not important which degree tho), and the polynomial coefficients should minimize this integral in the interval [x_start, x_end].
So, my problem is that this easily becomes complex, which fmincon don't handle very well. I have tried to use a nonlinear inequality constraint on (x - cos(Phi(x) - pi/4)) so it stays inside [-1,1], though this will only ensure non-complex answer before integration.
If anyone have thoughts or suggestion to this problem I would really appreciate it.
6 Comments
Walter Roberson
on 31 Jan 2014
I am uncertain here. Are you using fmincon() varying x, or are you using fmincon varying the polynomial coefficients?
If the polynomial coefficients should minimize the integral, then perhaps the coefficients should be something like all 0 ?
Brede Løvik Lillehammer
on 2 Feb 2014
Walter Roberson
on 2 Feb 2014
And it is z that needs to be altered for the minimization, right?
Brede Løvik Lillehammer
on 2 Feb 2014
Matt J
on 2 Feb 2014
I would step back and reconsider the approach you're taking to whatever it is you're doing and see if there isn't a better way to formulate the problem. As you have it now, it isn't even clear that your objective function is differentiable in z. The integrand surely is not, at least not at points where
abs(x - cos(Phi(x) - pi/4))=1
Brede Løvik Lillehammer
on 2 Feb 2014
Edited: Brede Løvik Lillehammer
on 2 Feb 2014
Answers (1)
Roger Stafford
on 31 Jan 2014
I would suggest, instead of using quadrature functions like 'quad' which set their own values for the variable x, that you use 'trapz' for which you can choose the values of x to be used. This would allow you to use the "c<=0" type of constraint in 'fmincon' as applied to the inequalities
max(x-cos(Phi(x)-pi/4))-1<=0
-1-min(x-cos(Phi(x)-pi/4))<=0
where the max and min are taken over all the x points used by 'trapz'. The arguments that are to be adjusted by 'fmincom' in the 'c' inequality functions are of course the coefficients of the polynomial in Phi. You can select the size of the x-interval used by 'trapz' so as to give the required integration accuracy, or as an alternative to 'trapz' you can use the more accurate Gaussian integration method in which again the x values are predetermined.
2 Comments
Roger Stafford
on 31 Jan 2014
You will probably have to use a variety of coefficient initial estimates in 'fmincon' - that is, the quantity Mathworks calls 'x0'. With the wrong initial values, you may get a local minimum but not the true global minimum. My intuition tells me that this may be particularly true with your kind of problem.
Brede Løvik Lillehammer
on 2 Feb 2014
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!