conjugate issue
12-01-2015, 05:48 PM (This post was last modified: 12-01-2015 06:12 PM by ji3m.)
Post: #1
 ji3m Member Posts: 131 Joined: Sep 2015
conjugate issue
In my program i build a string like

s := "conj (2+3*i)" and then do

r := CAS (s);

the returned r is 2-3*i with a funny looking minus sign.

But then

t := "conj (" + r + ")" gives t := "conj (2-3*i)"

But the CAS (t) fails with a major error.

At the cas window , when rentering the item with the odd minus
sign it is converted by the parser to a normal minus sign so it works.

This program shows my problem better.

Enter bbb (2+3*i) or even bbb ("2+3*i") .
It fails when trying to use return result Q (whick has funky minus sign)

EXPORT bbb(S)
BEGIN
LOCAL P,Q,R,T;
DEBUG;
P := "conj(" + S + ")";
Q := CAS(P);
R := "conj(" + Q + ")"; // using STRING (Q) doesnt help
T := CAS(R); // fails here
END;

I work with android Prime only for now on my
Galaxy Tab Pro/Note 2
12-01-2015, 08:03 PM
Post: #2
 Han Senior Member Posts: 1,804 Joined: Dec 2013
RE: conjugate issue
(12-01-2015 05:48 PM)ji3m Wrote:  In my program i build a string like

s := "conj (2+3*i)" and then do

r := CAS (s);

the returned r is 2-3*i with a funny looking minus sign.

But then

t := "conj (" + r + ")" gives t := "conj (2-3*i)"

But the CAS (t) fails with a major error.

At the cas window , when rentering the item with the odd minus
sign it is converted by the parser to a normal minus sign so it works.

This program shows my problem better.

Enter bbb (2+3*i) or even bbb ("2+3*i") .
It fails when trying to use return result Q (whick has funky minus sign)

EXPORT bbb(S)
BEGIN
LOCAL P,Q,R,T;
DEBUG;
P := "conj(" + S + ")";
Q := CAS(P);
R := "conj(" + Q + ")"; // using STRING (Q) doesnt help
T := CAS(R); // fails here
END;

This looks like a bug in the "minus" sign that conj() returns. It looks a lot like a negation symbol. Manually copying the result from CAS view changes it to the correct subtraction sign. However, using string conversion seems to keep the invalid character. I wonder if this is an XCAS issue...

Graph 3D | QPI | SolveSys
12-01-2015, 08:19 PM
Post: #3
 ji3m Member Posts: 131 Joined: Sep 2015
RE: conjugate issue
Finaly a bug that's not just a my own mis-understanding.

My work-around:

If type(q) ==DOM_COMPLEX
then
s:= string (RE (s)) + "+" + string (IM (s)) + "*i ";
end;

s will be uzed in a cas string.It works nicely.

So IM(s) gets a normal minus or evaluates the negation.

I work with android Prime only for now on my
Galaxy Tab Pro/Note 2
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)