# real_part of an equation [closed]

Hi

how to get 'A^2 -B^2' in the last show() ?

a = var('a')
b = var('b')
A = var('A')
B = var('B')
assume(a,'real')
assume(b,'real')
assume(A,'real')
assume(A,'real')
equ=sqrt(a+b*I)==A + B*I
equ1=((equ.lhs()^2)==(equ.rhs()^2).expand())
show(equ1)
show(equ1.lhs().real_part().expand())
show(equ1.rhs().real_part().expand())

edit retag reopen merge delete

### Closed for the following reason not a real question by ortollj close date 2017-08-19 14:24:32.910372

Sorry I made a mistake ! :Twice assume(A,'real') but no assume(B,'real') !!!

( 2017-08-19 14:20:07 +0200 )edit

Sort by ยป oldest newest most voted

... by also changing the text after copy+paste of (the second) assume(A,'real') . Make it

assume( B, 'real' )


For my taste i would do (although explicitly is possibly better):

sage: for v in var( 'a,b,A,B' ):    assume( v, 'real' )

sage: equ = sqrt(a+b*I) == A + B*I
sage: equ1 = ( (equ.lhs()^2) == (equ.rhs()^2).expand() )

sage: show(equ1)
....: show(equ1.lhs().real_part().expand())
....: show(equ1.rhs().real_part().expand())
....:
\newcommand{\Bold}[1]{\mathbf{#1}}a + i \, b = A^{2} + 2 i \, A B - B^{2}
\newcommand{\Bold}[1]{\mathbf{#1}}a
\newcommand{\Bold}[1]{\mathbf{#1}}A^{2} - B^{2}

more

yes, much better thank you dan_fulea.

( 2017-08-19 14:58:51 +0200 )edit

It is just an alternative, it has advantages and disadvantages. Not being explicit may be a problem. (Some readers would not get the message immediately or ignore the line.) But this way the typo's are avoided,it is my style when i need something quickly.

( 2017-08-19 15:21:22 +0200 )edit

Sorry I made a mistake ! :Twice assume(A,'real') but no assume(B,'real') !!! shame on me

more