[GiNaC-list] Error on expression

Vladimir V. Kisil kisilv at maths.leeds.ac.uk
Tue Mar 14 00:24:50 CET 2017


	Hi,
	
>>>>> On Mon, 13 Mar 2017 23:42:12 +0100, Jean-Michaël Celerier <jeanmichael.celerier at gmail.com> said:

  GiNaC::ex e = p("2*cos(x)+e^x");

  This conversion leaves e^x to be "a symbol e to power x", where e is
  GiNaC::symbol and is not the base of natural logarithms. This cannot
  be converted to a double and produces the quoted error.

  The following (simpler) code produces the correct answer:

#include<ginac/ginac.h>
#include<iostream>

int main(int argc, char* argv[])
{
	GiNaC::symtab table;
	table["x"] = 2.34;
	GiNaC::parser p(table);
	GiNaC::ex e = p("2*cos(x)+exp(x)");
	GiNaC::numeric n = GiNaC::ex_to<GiNaC::numeric>(e);
	double x = n.to_double();
	std::cout << x << std::endl;
	return 0;
}

  Best wishes,
  Vladimir
-- 
Vladimir V. Kisil                 http://www.maths.leeds.ac.uk/~kisilv/
  Book:     Geometry of Mobius Transformations     http://goo.gl/EaG2Vu
  Software: Geometry of cycles          http://moebinv.sourceforge.net/


More information about the GiNaC-list mailing list