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

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

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.

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.

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

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.

1 Like

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

1 Like

Sure, Mark’s suggestion sounds fine.

Sorry, misread the subsequent comments. Previous post edited.

1 Like

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.

1 Like

Thanks for your kindness