Search code examples
matlabexpressionintegral

MATLAB symbolic expression: How to force the answer to be sin(alpha)/alpha


syms x alpha
L =1;
cn = (1/2)*int(exp(-j*alpha*x),x,-L,L)

cn should be sin(alpha)/alpha.

But Matlab answer as follows:

cn =

(2^(1/2)*sin(alpha)*i)/(2*(alpha*i)^(1/2)*(alpha*(i/2))^(1/2))

With simplify or simple, I can not force cn = sin(alpha)/alpha. How to force it?

Thanks a lot for the help


Solution

  • If you use simplify(cn,'IgnoreAnalyticConstraints',true) you get the result you want. The documentation for the option says:

    Apply purely algebraic simplifications to an expression. simplify can return simpler results for expressions for which it would return more complicated results otherwise. Setting IgnoreAnalyticConstraints to true can lead to results that are not equivalent to the initial expression.

    I never saw the option returning "wrong" results. If you are interested in some further explanations you can read ths blog entry.