How to use sqrt for input expression?

Richard B. Kreckel kreckel at thep.physik.uni-mainz.de
Fri Dec 14 13:38:55 CET 2001


Hello,

On Thu, 13 Dec 2001, Hidehiro FUJIO wrote:
> I'm using GiNaC for making numerical simulation tools.
> 
> My problem with GiNaC is how to handle 'sqrt' function in
> expression input.  The simplest example is,
> 
> =======================================
> #include <ginac/ginac.h>
> 
> using namespace GiNaC;
> #include <iostream.h>
> int main()
> {
>   symbol x("x");
>   ex e("sqrt(x)",lst(x));
>   cout << e <<endl;
> }
> =======================================
> 
> When it runs, it makes core dump.

Rather it throws an (uncaught) exception telling you that there is no
function 'sqrt' included in the parser.

> When I use 'sin' instead of 'sqrt', the result is what
> I expected with GiNaC library.
> 
> Is it a bug or normal?  If normal, how to input expression
> that contains 'sqrt' function?

Till this is fixed, just use "x^(1/2)" instead of "sqrt(x)" when
constructing an ex from a string.

Regards
    -richy.
-- 
Richard B. Kreckel
<Richard.Kreckel at Uni-Mainz.DE>
<http://wwwthep.physik.uni-mainz.de/~kreckel/>





More information about the GiNaC-devel mailing list