How can I suppress simplify factoring out -1?

I am going to simplify the following formula:

sqrt(a^2*p*(1-p)*(N-n)/(n^2*(N-1)))

I wrote simplify(sqrt(a^2*p*(1-p)*(N-n)/(n^2*(N-1))),symbolic), the output was:

I*a*sqrt(p)*sqrt(-1+p)*sqrt(N-n)/(n*sqrt(N-1))

The command did a bit, but it factored -1 out, that is unexpected.

In current case, I*sqrt(-1+p)=sqrt(p-1), the I is unwanted.

How can I suppress the command factoring out the -1?

I tried other options of simplify such as size, they didn't help.

A correction

In current case, I*sqrt(-1+p)=sqrt(p-1), the I is unwanted.

=>

In current case, I*sqrt(-1+p)=sqrt(1-p), the I is unwanted.

acer's picture

assumptions

You might try simplifying the expression under certain assumptions on the variables.

For example,

> expr := sqrt(a^2*p*(1-p)*(N-n)/(n^2*(N-1))):

> simplify(expr) assuming n::real, a::real, p>0, p<1, N>1;
                       1/2        1/2        1/2
                      p    (1 - p)    (N - n)    | a/n |
                      ----------------------------------
                                         1/2
                                  (N - 1)

You might also wish to consider the explanation of the 'symbolic' option of the simplify() routine, as it appears in the help-page ?simplify,details.

acer

Thank you very much!

Thank you very much!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}