# How to type sin function with square

141 views (last 30 days)

Show older comments

##### 0 Comments

### Accepted Answer

Sam Chak
on 20 Nov 2023

@John Sanjai J, are you expecting this?

syms x

expr = sin(x)^2

##### 5 Comments

Sam Chak
on 21 Nov 2023

Walter Roberson
on 21 Nov 2023

syms x

char(sin(x)^2)

char(sin(x)*sin(x))

char(sin(x^2))

char(sin(x * x))

### More Answers (1)

Steven Lord
on 21 Nov 2023

While the usual mathematical notation to compute the square of the sine of x is , the MATLAB code to perform that computation is sin(x)^2 (or, since you likely want to compute the square of the sine element-wise, sin(x).^2).

x = 0:pi/4:2*pi

sin(x).^2

You cannot put the squaring operator between the name of the function (sin) and its input argument x.

##### 0 Comments

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!