Post Reply 
Odd bug with 'solve'
04-25-2021, 04:45 PM
Post: #5
RE: Odd bug with 'solve'
There is special code in the parser to detect i inside a loop as an index, but inside a solve command or other CAS expressions, i is and will remain sqrt(-1) (unless you activate some compatibility mode, for example inside Xcas xcas_mode(1) will activate maple compatibility where sqrt(-1)==I).
Most calculators and some desktop programs prefer to have a special i letter, but it is hard to get this character on a desktop keyboard and moreover it is not the same unicode char everywhere which means that if you are using a special i you will probably have to stay with the same program/calculator (probably a reason to get calc maker happy!).
I strongly believe it is much better to have a standard letter for sqrt(-1), and I think lowercase i is better than uppercase I (but I leave the choice to the end user). The Xcas lexer accepts the following versions of i, from input_lexer.ll
Code:

"i"            index_status(yyextra)=1; if (xcas_mode(yyextra) > 0 || !i_sqrt_minus1(yyextra)) { (*yylval)=i__IDNT_e; return T_SYMBOL; } else { (*yylval) = cst_i; return T_LITERAL;};
"ί"                      index_status(yyextra)=1; (*yylval) = cst_i; return T_LITERAL;
"?"                     index_status(yyextra)=1; (*yylval) = cst_i; return T_LITERAL;
""                      index_status(yyextra)=1; (*yylval) = cst_i; return T_LITERAL;
\xa1                    index_status(yyextra)=1; (*yylval) = cst_i; return T_LITERAL;
  /* \xef\xbd\x89            index_status(yyextra)=1; (*yylval) = cst_i; return T_LITERAL; */
\xe2\x81\xb1            index_status(yyextra)=1; (*yylval) = cst_i; return T_LITERAL;
"I"                     index_status(yyextra)=1; if (python_compat(yyextra)>=0 && (xcas_mode(yyextra)==0 || xcas_mode(yyextra)==3 || rpn_mode(yyextra)) ) { return find_or_make_symbol(yytext,(*yylval),yyscanner,true,yyextra); } else { (*yylval) = cst_i; return T_LITERAL; };
"%i"            index_status(yyextra)=1; (*yylval) = cst_i; return T_LITERAL;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Odd bug with 'solve' - jonmoore - 04-24-2021, 07:16 PM
RE: Odd bug with 'solve' - toml_12953 - 04-24-2021, 08:13 PM
RE: Odd bug with 'solve' - jonmoore - 04-25-2021, 05:35 AM
RE: Odd bug with 'solve' - jonmoore - 04-25-2021, 06:23 AM
RE: Odd bug with 'solve' - Albert Chan - 04-27-2021, 04:09 PM
RE: Odd bug with 'solve' - ijabbott - 04-27-2021, 04:40 PM
RE: Odd bug with 'solve' - parisse - 04-25-2021 04:45 PM
RE: Odd bug with 'solve' - jonmoore - 04-25-2021, 06:58 PM
RE: Odd bug with 'solve' - Wes Loewer - 04-26-2021, 03:18 PM
RE: Odd bug with 'solve' - jonmoore - 04-26-2021, 08:01 PM
RE: Odd bug with 'solve' - jonmoore - 04-27-2021, 06:48 AM
RE: Odd bug with 'solve' - parisse - 04-27-2021, 01:29 PM
RE: Odd bug with 'solve' - jonmoore - 04-27-2021, 03:02 PM
RE: Odd bug with 'solve' - parisse - 04-27-2021, 06:25 PM
RE: Odd bug with 'solve' - jonmoore - 04-28-2021, 08:22 AM
RE: Odd bug with 'solve' - parisse - 04-28-2021, 12:40 PM



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