On May 9, 2009, at 4:12 AM, Laurent Claessens wrote:
>
> I half-answer to myself :
>
>
>> 1. be able to convert a string into a function on which I can use
>> Sage
>
> s = "x**3"
> var('x')
> f = eval(s)
> print f(3)
Or
sage: SR(s)
x^3
sage: SR("2a+5x^2-sqrt(pi)")
5*x^2 + 2*a - sqrt(pi)
so y
David Joyner a écrit :
> Maybe this then?
>
> sage: from sympy import *
> sage: Symbol("x")
> x
> sage: f = 3*x^2
> sage: str(f.as_basic())
> '3*x**2'
>
Yes !! :):)
Thanks a lot.
Laurent
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@g
Maybe this then?
sage: from sympy import *
sage: Symbol("x")
x
sage: f = 3*x^2
sage: str(f.as_basic())
'3*x**2'
On Sat, May 9, 2009 at 7:56 AM, Laurent wrote:
>
>
>>
>> sage: str(latex(g))
>> '{3 {x}^{2} }'
>>
>> what you want?
>>
> I would prefer 3*(x**2)
> {3 {x}^{2} }
> is not a valid pstr
>
> sage: str(latex(g))
> '{3 {x}^{2} }'
>
> what you want?
>
I would prefer 3*(x**2)
{3 {x}^{2} }
is not a valid pstricks's syntax, and I don't see how to manipulate it
in order to get something valid.
Maybe I can make the replacement { -> ( and } ->), but I fear some side
effect of the LaT
On Sat, May 9, 2009 at 7:12 AM, Laurent Claessens wrote:
>
> I half-answer to myself :
>
>
>> 1. be able to convert a string into a function on which I can use Sage
>
> s = "x**3"
> var('x')
> f = eval(s)
> print f(3)
>
> makes the job
>
>> 2. from the results of Sage (especially from diff(f,x)),
I half-answer to myself :
> 1. be able to convert a string into a function on which I can use Sage
s = "x**3"
var('x')
f = eval(s)
print f(3)
makes the job
> 2. from the results of Sage (especially from diff(f,x)), I need a
> string that I can manipulate with Python (especially use the .repla