Ask Your Question
0

real_part of an equation [closed]

asked 2017-08-19 13:39:15 +0100

ortollj gravatar image

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 flag offensive reopen merge delete

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

Comments

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

ortollj gravatar imageortollj ( 2017-08-19 14:20:07 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-08-19 14:41:23 +0100

dan_fulea gravatar image

updated 2017-08-19 14:42:44 +0100

... 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}
edit flag offensive delete link more

Comments

yes, much better thank you dan_fulea.

ortollj gravatar imageortollj ( 2017-08-19 14:58:51 +0100 )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.

dan_fulea gravatar imagedan_fulea ( 2017-08-19 15:21:22 +0100 )edit
0

answered 2017-08-19 14:22:55 +0100

ortollj gravatar image

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

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-08-19 13:39:15 +0100

Seen: 196 times

Last updated: Aug 19 '17