I'm trying to write a procedure which returns the real conjugate of a real number.
Ex: $2 + \sqrt3 \rightarrow 2 - \sqrt3$
I tried:
rconj:= proc(x) local i,y; y:=-x; for i to nops(x) do if type(op(i,x),rational) then op(i,y):= -op(i,x); end if; end do; return y; end proc
It isn't working. Error statement: "Error, (in rconj) invalid left hand side in assignment".
Any suggestions? Thank you.
For simple cases
this will do what you want. It is not properly general (it really doesn't do the right thing for cube roots), but gives you a starting point.