Tim Lahey wrote:
> 
> On Nov 24, 2008, at 11:54 PM, William Stein wrote:
> 
>> On Mon, Nov 24, 2008 at 8:27 PM, Tim Lahey <[EMAIL PROTECTED]>  
>> wrote:
>>> Hi,
>>>
>>> If I have the following example Sage code,
>>>
>>> var('x,a,b')
>>> # Test 1
>>> f1 = 1/(a*x+b)
>>> aa = f1.integrate(x)
>>> bb = 1/a*log(a*x+b)
>>> aa_cmp = bb-aa # Should be zero
>>> sage_time_f1 = timeit.eval('f1.integrate(x)')
>>> friCAS_time_f1 = timeit.eval('axiom.integrate(f1,x)')
>>>
>>> How do I write it as a test?
>>>
>>> The code runs fine on the command line and I was thinking
>>> of setting it up as a script, but when running as a script
>>> it doesn't like the ^ for **. Suggestions? Or should I just
>>> do a find-replace?
>> Make it a foo.sage script instead of foo.py and it will be
>> preparsed, so the ^'s will work.
> 
> Thanks.
>>
>>> I'd like to run things in batch mode. I'll also try to
>>> set up them for SymPy as well, but those need to run
>>> separately because of how SymPy defines its variables.
>> Why?
> 
> Because in order to prevent an exception from SymPy, I need
> to define my variables as:
> x,a,b = sympy.symbols('xab')
> 
> then I can do,
> aa = sympy.integrate(f1,x) #using the f1 definition from above.
> 
> but, if I do that, Maxima and FriCAS don't like it. So, I can't
> use a common f1 for both. I need to run one then the other.
> 

You could probably use the "sympyify" command:


sage: import sympy
sage: var('x,a,b')
(x, a, b)
sage: f1=1/(a*x+b)
sage: sympy.integrate(sympy.sympify(f1),sympy.sympify(x))
1/a*log(b + a*x)
sage: sympy_integrate = lambda f,x: sympy.integrate(sympy.sympify(f), 
sympy.sympify(x))
sage: sympy_integrate(f1,x)
1/a*log(b + a*x)


-Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to