Ask Your Question
1

Square root of a fraction

asked 2021-12-09 10:32:05 +0200

keko gravatar image

updated 2021-12-09 10:34:32 +0200

I have the following variable and function:

var('r')
f = function('f')(r)

with an equation given by:

eq = sqrt(-1/(f^2*sin(r)^2))-1/sqrt(-f^2*sin(r)^2)

which, in LaTeX expression, looks like:

\begin{equation} \sqrt{-\frac{1}{f\left(r\right)^{2} \sin\left(r\right)^{2}}} - \frac{1}{\sqrt{-f\left(r\right)^{2} \sin\left(r\right)^{2}}} \end{equation}

In principle, this should be equal to zero. However,

bool(eq==0)

gives me False. I have tried with .simplify_full() and following the suggestion in here, I have used ._sympy_().simplify():

eq = eq._sympy_().simplify()
bool(eq==0)

but I still get False. Am I missing something?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2021-12-09 12:51:49 +0200

cav_rt gravatar image

By doing

$\sqrt{-\frac{1}{f\left(r\right)^{2} \sin\left(r\right)^{2}}} - \frac{1}{\sqrt{-f\left(r\right)^{2} \sin\left(r\right)^{2}}} = \frac{i}{\sqrt{f\left(r\right)^{2} \sin\left(r\right)^{2}}}-\frac{1}{i\sqrt{f\left(r\right)^{2} \sin\left(r\right)^{2}}} = \frac{2i}{\sqrt{f\left(r\right)^{2} \sin\left(r\right)^{2}}}$

I wouldn't expect bool(eq==0) to return True.

You can deal with square roots using canonicalize_radical().

eq.canonicalize_radical()

returns $\frac{2 i}{f\left(r\right) \sin\left(r\right)}$.

edit flag offensive delete link more
0

answered 2021-12-15 17:08:05 +0200

keko gravatar image

I have realized that my problem here was of mathematical nature rather than computational. I was assuming that

$-\frac{a}{b} =\frac{a}{-b}$ $\implies$ $\sqrt{-\frac{a}{b}}=\sqrt{\frac{a}{-b}}$ $\implies$ $\frac{\sqrt{-a}}{\sqrt{b}}=\frac{\sqrt{a}}{\sqrt{-b}}$

However, if we consider only the positive branches of the square roots, the last equality does not hold.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-12-09 10:32:05 +0200

Seen: 234 times

Last updated: Dec 15 '21