[NOTE: I mistakenly sent several replies to individuals rather than to the group. Several are moot, but I did not want to leave them off-list. So I am resending below. Sorry about that! Bruce]

Hi Oscar,

Thanks for the quick reply.

The symbol 'a' is declared to be real and positive. But my example is NOT automatically simplified:

a=symbols('a', real=True, positive=True)

expr = sqrt(4*a**2 + 1)*sqrt(1/(4*a**6 - 15*a**4 + 12*a**2 + 4))

simplify(expr)

sqrt(4*a**2 + 1)*sqrt(1/(4*a**6 - 15*a**4 + 12*a**2 + 4))

Could you suggest how I might direct sympy to simplify it as shown below? In my expressions, the arguments of the square roots are typically polynomials in 'a', or ratios of such polynomials.

Cheers,
        Bruce


On 01.04.21 18:53, Oscar Benjamin wrote:
On Thu, 1 Apr 2021 at 15:43, 'B A' via sympy <sympy@googlegroups.com> wrote:

What is described above has worked well for me.  But there is a further 
simplification step that I need help with.

I have some long expressions containing terms contain terms which look like 
this example:
sqrt(4*a**2 + 1)*sqrt(1/(4*a**6 - 15*a**4 + 12*a**2 + 4))
How can I instruct sympy to combine such square roots and factor the arguments? 
In this example that would lead to:

sqrt(factor((4*a**2 + 1)/(4*a**6 - 15*a**4 + 12*a**2 + 4)))
=
1/Abs(a**2 - 2)

You can declare a to be real:

In [12]: a = Symbol('a', real=True)

In [13]: expr = sqrt(factor((4*a**2 + 1)/(4*a**6 - 15*a**4 + 12*a**2 + 4)))

In [14]: expr
Out[14]:
    1
────────
│ 2    │
│a  - 2│


Oscar


--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/30d73202-756e-dff7-c275-a7aa545d82de%40googlemail.com.

Reply via email to