Is it possible to use sin or cos in cvx?

Nonconvex
Oct 15, 2016
P

hello
is it possible to use sin or cos in cvx?
when i use it i got this error
undefined function ‘sin’ for input argument for cvx
my function is this
exp (-sin(x) )

thanks

M

sin and cos are neither convex nor concave. Therefore, CVX will not accept them and they can not be used in CVX. If you need to use them, you will have to use a different tool.

P
Replying to #2

Thanks for reply
when I limit x between zero and 45, exp (-sin(x) ) gets convex on x. I did this but again I got
undefined function ‘sin’ for input argument for cvx.

M
P

I understand why CVX does not accept sin (.) because in general it is not convex ,but as I said my problem is convex , Is it possible to use Taylor series for approximation sin(.) and using poly val .
any suggestion?
Thanks

M
Replying to #3

Taylor series about x = 0 of

exp(-sin(x))

is

1 - x + 1/2* x^2 - 1/8**x^4 + O(x^5)

The sum of the first 3 terms is convex. CVX will accept it. At x = Pi/4, exp(-sin(x)) = 04931, and 1 - x + 1/2*x^2 = 0.5230 … You will have to decide whether this 3 term Taylor approximation is accurate enough for your purposes.

Note: This post has been updated to correct numerical evaluation errors in the original post.

D

You may use Excel to plot and fit a convex function to exp(-sin(x)) where 0<=x<=pi/6.

M

Sure, Mark’s suggestion sounds fine.

M
Replying to #8

Sorry, misread the subsequent comments. Previous post edited.

M
Replying to #9

I have edited my original post with the Taylor approximation. I made a mistake in evaluating the function and Taylor approximation, It is much better than I originally posted.I have now edited the post to use correct values.

P
Replying to #6

Thanks for your kindness