Re: [sage-support] Re: How to use the result of solve

2010-03-17 Thread Jose Guzman

Dear BFJ,

thanks a lot for your answer. It works very nice!

Alternatively, I found that using the rhs() method also works. My idea 
was to substitute the algebraic expression of the solution, and inserted 
as denominator of a new function:


sage: f(x) = ( 1-e**(t/tau0) )*(e**(-x/tau1)) # this is the origin function
sage: S = solve(derivative(f,x)==0,x) # this is the solution at the peak
sage: tpeak = S[0].rhs() # this is the algebraic solution
sage: ypeak = f(tpeak) # y-value expressed as tau0 and tau1
sage: f_norm(x) = f(x)/ypeak # we nor normalize the function to the 
ypeak value


It works like a charm!!! I love Sage!

Best

JOse.



BFJ wrote:

To get the value of 'x' from solve you can use the option
solultion_dict = true as follows:

sage: S = solve(derivative(f,x)==0,x, solution_dict=true)
sage: S[0][x]
tau0*log(tau1/tau0 + 1)
sage: S[0][x].subs(tau0=0.5, tau1=5.0)
1.19894763639919

Also, using the 'N' function will evaluate numerical expressions to a
desired level of accuracy

sage: N(S[0][x].subs(tau0=0.5, tau1=5.0), digits=25)
1.198947636399185334710182

-BFJ

On Mar 16, 5:32 pm, Jose Guzman n...@neurohost.org wrote:
  

Hi everybody again.

Does anybody if it is possible to use the result of the function solve
to insert it in a function to resolve it analitically.

For example, I want to get the peak of the following function

  var('tau0,tau1')
  f(x) = (1-e**(-x/tau0))*(e**(-x/tau1))

For that, I simply derive it and equal to zero

  solve(derivative(f,x)==0,x)
  [x == tau0*log(tau1/tau0 + 1), e^(-(tau0 + tau1)*x/(tau0*tau1)) == 0]

I would like to take the first expression of that list
  xpeak = solve(derivative(f,x)==0,x)[0]

for example, to calculate its value when tau0=0.5 and tau1=5.0

  xpeak.subs(tau0=.5, tau1=5.0)

but this returns a symbolic expresion ,



t == 0.500*log(11.0)
  

and not the scalar 1.1989

More importantly, I would like to use this expression to solve
analytically the y value of that equation as a function of tau0 and tau1

Any suggestion would be greatly appreciated!

Best

Jose.



  


--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: 回复: [sage-support] Re: 3D plot in sage

2010-03-17 Thread wxuyec
Thank you! - 原文 - 发件人: Jaap Spies 主 题: Re: 回复: [sage-support] Re: 3D 
plot in sage时 间: 2010年3月16日  05:43:18wxu...@sohu.com wrote:gt; Thank you very 
much!gt;gt; I will try this.gt;You could try the experimental version found 
here:http://sage.math.washington.edu/home/jsp/SPKGS/ETS/Jaap-- To post to this 
group, send email to sage-supp...@googlegroups.comto unsubscribe from this 
group, send email to sage-support+unsubscr...@googlegroups.comfor more options, 
visit this group at http://groups.google.com/group/sage-supportURL: 
http://www.sagemath.org

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

[sage-support] Re: Syntax highlight in SAGE Calculator?

2010-03-17 Thread Alec Mihailovs
On Mar 16, 5:05 pm, dmitrey dmitrey.kros...@scipy.org wrote:
 hi all,
 is it possible somehow to perform syntax highlight in SAGE Calculator,
 at least for viewing published worksheets?

 Regards, D.

In the documentation (in the notebook) the syntax is highlighted (I
mean colored). See, for example,

vector?

vector??

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-17 Thread Alec Mihailovs
On Mar 16, 10:47 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:
 By the way, vector doesn't work with integer numpy arrays,

 from numpy import array
 vector(array([1,2]))

 Traceback (most recent call last):

That shouldn't be too hard to implement - in particular, the following
works,

sage: from numpy import array
sage: vector(list(array([1,2])))

(1, 2)

sage: vector(list(array([1,2],dtype=object)))

(1, 2)

sage: _.parent()

Ambient free module of rank 2 over the principal ideal domain Integer
Ring

sage: vector(list(array([1,2],dtype=float)))

(1.0, 2.0)

sage: vector(list(array([1,2],dtype=complex)))

(1.0, 2.0)

sage: _.parent()

Vector space of dimension 2 over Complex Double Field

So it looks as if the conversion from one-dimensional numpy arrays to
vectors could be done like that, independently of their dtype.

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Help starting Mathematica with Sage

2010-03-17 Thread Young, Michael I. (DFRC-SR)
I am having a problem getting Mathematica to start from Sage on my Mac.  I have 
created the math file in my local directory and made sure that it is 
executable but when I try to start Mathematica I get the message RuntimeError: 
Unable to start mathematica because the command 'math' failed.  I have 
executed the command line that I have in math in a separate Terminal window 
and it seems to start the command line version of Mathematica without a 
problem.  I also executed ./math from my home directory and that worked as 
well.  One note here; you have to make sure that you use the UNIX end of line 
characters in the file for this to work correctly.  The editor I was using 
defaults to the Apple end of line characters which causes it not to execute.  I 
am trying to use Sage 4.3.3 on Mac OSX 10.5.8 operating system with Mathematica 
7.0.1.  Any ideas would be greatly appreciated.

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Re: [sage-support] Help starting Mathematica with Sage

2010-03-17 Thread Mike Hansen
On Wed, Mar 17, 2010 at 2:02 PM, Young, Michael I. (DFRC-SR)
michael.i.yo...@nasa.gov wrote:
 I am having a problem getting Mathematica to start from Sage on my Mac.  I
 have created the “math” file in my local directory and made sure that it is

What directory do you mean by local directory?  In order for it to
work, it has to be in Sage's $PATH.  Try placing the the file in
$SAGE_ROOT/local/bin and see if that works for you.

--Mike

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] newbie: plot() questions

2010-03-17 Thread Nareto
Hello, I have to plot an exponential function with vertical asymptote
in point tc, but

plot(f(t), (tc  - e, tc + e));

gives me unreadable plots for any values of e - if e is to large the
curvature is not apreciable (i.e. the plot is confused with the axes)
but if it's too small I'm getting things like 4 on the y axis.

So, how can I force the y axis range? I tried this but it doesn't
change anything:

P = plot(f(t));
P.set_range_axes(tc - 0.2, tc + 0.2, f(tc - 0.2), f(tc + 0.2));
show(P);

Question #2, how can I tell sage not to 'break' the axes? for example,

plot(1/(x + 3));

doesn't show me the last bit of the y axis, it ends approximately at
0.25


thanks for any help
Renato

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] atan2 throws divide by zero

2010-03-17 Thread G B
While waiting to be approved, I think I narrowed this down to a very
simple test case.

atan2(3,0)   -- 1/2*pi
atan2(-3,0)  -- -1/2*pi
atan2(pi,0)  -- 1/2*pi
atan2(-pi,0) --  RuntimeError: power::eval(): division by zero

Any ideas how to get around this?

Thanks--
 Greg



Here's the full traceback:

Traceback (most recent call last):
  File stdin, line 1, in module
  File _sage_input_34.py, line 9, in module
open(___code___.py,w).write(# -*- coding: utf-8 -*-\n +
_support_.preparse_worksheet_cell(base64.b64decode(YXRhbjIoLXBpLDAp),globals())
+\n); execfile(os.path.abspath(___code___.py))
  File , line 1, in module

  File /private/var/folders/ol/olxcekVE2RWirE+1YxlblU+++TI/-Tmp-/
tmphh0DH2/___code___.py, line 3, in module
atan2(-pi,_sage_const_0 )
  File , line 1, in module

  File function.pyx, line 709, in
sage.symbolic.function.GinacFunction.__call__ (sage/symbolic/
function.cpp:6394)
  File function.pyx, line 430, in
sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:
4448)
RuntimeError: power::eval(): division by zero

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Seeking Cython-101 lesson

2010-03-17 Thread kstueve
Hi,

I would like to rewrite the C code in ticket 8135 (Riemann's explicit
formula for the prime counting function, based on code from Oliveira e
Silva) in Cython so that it can be added to Sage, but I don't have any
experience programming in Cython.  I am seeking someone at UW skilled
in Cython to give me a lesson in the basics of Cython.  I can buy you
lunch/dinner (under $20) for your time, as well as provide interesting
conversation about primes.

Cython might also help me with my work on tickets 7013/7539.

Kevin Stueve

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: newbie: plot() questions

2010-03-17 Thread G B
Try

plot(f(t), ymax=17, ymin=-12)



On Mar 17, 2:32 pm, Nareto renn...@gmail.com wrote:
 Hello, I have to plot an exponential function with vertical asymptote
 in point tc, but

 plot(f(t), (tc  - e, tc + e));

 gives me unreadable plots for any values of e - if e is to large the
 curvature is not apreciable (i.e. the plot is confused with the axes)
 but if it's too small I'm getting things like 4 on the y axis.

 So, how can I force the y axis range? I tried this but it doesn't
 change anything:

 P = plot(f(t));
 P.set_range_axes(tc - 0.2, tc + 0.2, f(tc - 0.2), f(tc + 0.2));
 show(P);

 Question #2, how can I tell sage not to 'break' the axes? for example,

 plot(1/(x + 3));

 doesn't show me the last bit of the y axis, it ends approximately at
 0.25

 thanks for any help
 Renato

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: atan2 throws divide by zero

2010-03-17 Thread G B
Should have also mentioned:

Sage 4.3.3
OS X 10.6.2
64bit Intel
MacBook Pro


On Mar 17, 5:38 pm, G B g.c.b.at.w...@gmail.com wrote:
 While waiting to be approved, I think I narrowed this down to a very
 simple test case.

 atan2(3,0)   -- 1/2*pi
 atan2(-3,0)  -- -1/2*pi
 atan2(pi,0)  -- 1/2*pi
 atan2(-pi,0) --  RuntimeError: power::eval(): division by zero

 Any ideas how to get around this?

 Thanks--
  Greg

 Here's the full traceback:

 Traceback (most recent call last):
   File stdin, line 1, in module
   File _sage_input_34.py, line 9, in module
     open(___code___.py,w).write(# -*- coding: utf-8 -*-\n +
 _support_.preparse_worksheet_cell(base64.b64decode(YXRhbjIoLXBpLDAp),glob 
 als())
 +\n); execfile(os.path.abspath(___code___.py))
   File , line 1, in module

   File /private/var/folders/ol/olxcekVE2RWirE+1YxlblU+++TI/-Tmp-/
 tmphh0DH2/___code___.py, line 3, in module
     atan2(-pi,_sage_const_0 )
   File , line 1, in module

   File function.pyx, line 709, in
 sage.symbolic.function.GinacFunction.__call__ (sage/symbolic/
 function.cpp:6394)
   File function.pyx, line 430, in
 sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:
 4448)
 RuntimeError: power::eval(): division by zero

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Help starting Mathematica with Sage

2010-03-17 Thread Dr. David Kirkby

Young, Michael I. (DFRC-SR) wrote:
I am having a problem getting Mathematica to start from Sage on my Mac. 
 I have created the “math” file in my local directory and made sure that 
it is executable but when I try to start Mathematica I get the message 
“RuntimeError: Unable to start mathematica because the command 'math' 
failed.”  I have executed the command line that I have in “math” in a 
separate Terminal window and it seems to start the command line version 
of Mathematica without a problem.  I also executed “./math” from my home 
directory and that worked as well.  One note here; you have to make sure 
that you use the UNIX end of line characters in the file for this to 
work correctly.  The editor I was using defaults to the Apple end of 
line characters which causes it not to execute.  I am trying to use Sage 
4.3.3 on Mac OSX 10.5.8 operating system with Mathematica 7.0.1.  Any 
ideas would be greatly appreciated.


There is no Apple standard for terminating lines.

OS X is a Unix system. Unix has always terminated lines with a line feed. I 
don't know what started using carriage return and line feed (CR/LF), but it was 
certainly used in the disk operating system (DOS) on which Windows is based. 
That's why there are tools like dos2unix and unix2dos.


Many programs handle the either CR/LF or LF only without issue, but some will 
not accept one or the other.


My main point is there is no Apple standard.

Is Mathematica installed with the binaries in your home directory? That is 
unusual setup, so I'm not sure why you would type ./math from your home 
directory. The default is to install to


/usr/local/Wolfram/Mathematica/7.0/Executables/math

with links in /usr/local/bin.

I think the Mathematica support in Sage was broken about 4 months ago:

http://trac.sagemath.org/sage_trac/ticket/8495

as some changes were made to the Mathematica interface, without them being 
tested fully. But Mathematica is ok for some things. I've managed to get 
Mathematica to start using from Solaris and perform some computations.


The Mathematica problem that does exist should soon be solved, as a fix is 
available

http://trac.sagemath.org/sage_trac/ticket/8495

It just needs to be tested.

Are you running a Sage server with a different user name for the server to that 
for user processes? If so, make sure the user can find Mathematica, not just the 
server.


Dave

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org