Re: [sage-support] Re: how to do ?

2019-05-25 Thread henri.gir...@gmail.com
I did your command and it is compiling. My problem was I have two 
sagemath, and I forget to do ./sage


thanks it works

Le 25/05/2019 à 20:39, John H Palmieri a écrit :



On Saturday, May 25, 2019 at 3:31:00 AM UTC-7, HG wrote:

sage -i database_odlyzko_zeta

doesn't work in sagemath-8.8beta6 ?

How can I do it ?


Please provide more details: what platform? What went wrong.

It worked for me, by the way:

$ ./sage -i database_odlyzko_zeta
...
[database_odlyzko_zeta-20061209] Successfully installed 
database_odlyzko_zeta-20061209

[database_odlyzko_zeta-20061209] Deleting temporary build directory
[database_odlyzko_zeta-20061209] 
/Users/palmieri/Desktop/Sage_stuff/sage_builds/VANILLA/sage-8.8.beta6/local/var/tmp/sage/build/database_odlyzko_zeta-20061209
[database_odlyzko_zeta-20061209] Finished installing 
database_odlyzko_zeta-20061209.spkg

...
--
You received this message because you are subscribed to the Google 
Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to sage-support+unsubscr...@googlegroups.com 
.
To post to this group, send email to sage-support@googlegroups.com 
.

Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/fc39d6e6-19ec-4512-a9b4-6c37fe42402a%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/2f2d4b42-67b2-97e1-5d4f-67714647de9c%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: how to do ?

2019-05-25 Thread John H Palmieri


On Saturday, May 25, 2019 at 3:31:00 AM UTC-7, HG wrote:
>
> sage -i database_odlyzko_zeta 
>
> doesn't work in sagemath-8.8beta6 ? 
>
> How can I do it ? 
>
>
Please provide more details: what platform? What went wrong.

It worked for me, by the way:

$ ./sage -i database_odlyzko_zeta 
...
[database_odlyzko_zeta-20061209] Successfully installed 
database_odlyzko_zeta-20061209
[database_odlyzko_zeta-20061209] Deleting temporary build directory
[database_odlyzko_zeta-20061209] 
/Users/palmieri/Desktop/Sage_stuff/sage_builds/VANILLA/sage-8.8.beta6/local/var/tmp/sage/build/database_odlyzko_zeta-20061209
[database_odlyzko_zeta-20061209] Finished installing 
database_odlyzko_zeta-20061209.spkg
...

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/fc39d6e6-19ec-4512-a9b4-6c37fe42402a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: how to do this in SAGE

2017-02-13 Thread valeriodea
Thanks for the explanations. I now know how to use the tab completion in 
SAGE and it's useful.
Best,
Valerio
 

On Wednesday, February 8, 2017 at 4:21:31 PM UTC-6, Simon King wrote:
>
> Hi! 
>
> On 2017-02-08, valer...@gmail.com   > wrote: 
> > Is there a difference between 
> > return expand(f^2) 
> > and 
> > return (g^2).expand() 
> > or are they perfect synonyms? 
>
> SageMath's language is Python, in particular it is object oriented. 
> Personally, I'd always prefer calling a method of an object (that's to 
> say (g^2).expand()) over calling a function that is defined in the 
> global namespace (that's to say expand(g^2)). 
>
> Reasons: 
> - If you have a function F in the global namespace and some object x, 
>   how would you know that applying F to x makes any sense? If, on the 
>   other hand, you have a method x.f of x, then you know that it makes 
>   sense. 
> - Do you know how to get information in Python (and thus in SageMath) 
>   by "tab completion"? If you have an object x and start to type 
>  x. 
>   and then hit the  key, you will see a list of all methods 
>   available for x. (And if you start typing x.e and then hit the  
>   key, the list will only comprise methods whose name starts with e). 
>   This list will be a lot more concise then the list of all functions in 
>   the global namespace. 
> - A function such as "expand" will normally just call a method anyway. 
>   Do you know how to access the source code in Python? Just put a 
>   question mark after an object x and hit return (resp. shift-return in 
>   the SageMath notebook) -- you will see the documentation of x. Or put 
>   two question marks after x, and you will see the source code. 
>
>   Do this with the "expand" function. The result is (basically) this: 
>
>   sage: expand?? 
>   Signature: expand(x, *args, **kwds) 
>   Source:   
>   def expand(x, *args, **kwds): 
>   """ 
>   EXAMPLES:: 
>   ... 
>   """ 
>   try: 
>   return x.expand(*args, **kwds) 
>   except AttributeError: 
>   return x 
>
> So, you can see from the code that they basically are synonymous, except 
> that that "expand" function just returns x if x happens to not have an 
> "expand" method. 
>
> > The same question for   
> > lambda f: (f^2).expand() 
> > (in Simon's answer): is the lambda construction just a shortcut, 
> equivalent 
> > to 
> > return (g^2).expand() 
> > or is it something different? 
>
> That's again a question on Python. Both ways give you an object of the 
> same type: 
>
>   sage: def f_1(x): 
>   : return 2*x 
>   : 
>   sage: f_2 = lambda x: 2*x 
>   sage: type(f_1) 
>
>   sage: type(f_1) is type(f_2) 
>   True 
>
> I guess from a theoretical point of view ("lambda calculus"), it is 
> possible to do everything using the "lambda" construction. However, as 
> soon as it gets a little more complicated, "def" constructions are 
> easier to read. 
>
> Best regards 
> Simon 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: how to do this in SAGE

2017-02-08 Thread Simon King
Hi!

On 2017-02-08, valerio...@gmail.com  wrote:
> Is there a difference between 
> return expand(f^2)
> and
> return (g^2).expand()
> or are they perfect synonyms?

SageMath's language is Python, in particular it is object oriented.
Personally, I'd always prefer calling a method of an object (that's to
say (g^2).expand()) over calling a function that is defined in the
global namespace (that's to say expand(g^2)).

Reasons:
- If you have a function F in the global namespace and some object x,
  how would you know that applying F to x makes any sense? If, on the
  other hand, you have a method x.f of x, then you know that it makes
  sense.
- Do you know how to get information in Python (and thus in SageMath)
  by "tab completion"? If you have an object x and start to type
 x.
  and then hit the  key, you will see a list of all methods
  available for x. (And if you start typing x.e and then hit the 
  key, the list will only comprise methods whose name starts with e).
  This list will be a lot more concise then the list of all functions in
  the global namespace.
- A function such as "expand" will normally just call a method anyway.
  Do you know how to access the source code in Python? Just put a
  question mark after an object x and hit return (resp. shift-return in
  the SageMath notebook) -- you will see the documentation of x. Or put
  two question marks after x, and you will see the source code.

  Do this with the "expand" function. The result is (basically) this:

  sage: expand??
  Signature: expand(x, *args, **kwds)
  Source:   
  def expand(x, *args, **kwds):
  """
  EXAMPLES::
  ...
  """
  try:
  return x.expand(*args, **kwds)
  except AttributeError:
  return x

So, you can see from the code that they basically are synonymous, except
that that "expand" function just returns x if x happens to not have an
"expand" method.

> The same question for  
> lambda f: (f^2).expand()
> (in Simon's answer): is the lambda construction just a shortcut, equivalent 
> to 
> return (g^2).expand()
> or is it something different?

That's again a question on Python. Both ways give you an object of the
same type:

  sage: def f_1(x):
  : return 2*x
  :
  sage: f_2 = lambda x: 2*x
  sage: type(f_1)
  
  sage: type(f_1) is type(f_2)
  True

I guess from a theoretical point of view ("lambda calculus"), it is
possible to do everything using the "lambda" construction. However, as
soon as it gets a little more complicated, "def" constructions are
easier to read.

Best regards
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: how to do this in SAGE

2017-02-08 Thread Dima Pasechnik


On Wednesday, February 8, 2017 at 6:45:41 PM UTC, valer...@gmail.com wrote:
>
> Thank you to the people who responded, all answers were helpful.
>
> Is there a difference between 
> return expand(f^2)
> and
> return (g^2).expand()
> or are they perfect synonyms?
>

the documentation of expand() appears to say that
this is the same thing, essentially. 

>
> The same question for  
> lambda f: (f^2).expand()
> (in Simon's answer): is the lambda construction just a shortcut, 
> equivalent to 
> return (g^2).expand()
> or is it something different?
>
it is the same thing - lambda is a facility to create nameless functions 
in-place.

 
 

>
> Thanks again
>
>  
>
>
> On Saturday, February 4, 2017 at 2:48:22 PM UTC-6, valer...@gmail.com 
> wrote:
>>
>> I would like to know the right way to do in SAGE what I am currently 
>> doing with Mathematica in these two examples (I actually know how to do the 
>> first one in SAGE, but probably not in the best way):
>> 1) Finding the intersection of a generic tangent line to f(x) with f(x):
>> f[x_]:= x^2(x^2-1)
>> L[a_,x_]:=f[a]+f'[a](x-a)
>> Solve[L[a,x]==f[x],x]
>> Here the main issue for me is how use the derivative f'(x) without having 
>> to define a new function g(x)=derivative(f(x))
>>
>> 2) Testing if |f(z)| < f(|z|) for various choices of f:
>> Pl[f_,r_]:=Plot[Abs[f[r Exp[I t]]]/f[r],{t,0,2Pi}]
>> Here I am mostly interested in how to write a command that uses a 
>> function as a variable. 
>>
>> Thanks for any suggestions.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: how to do this in SAGE

2017-02-08 Thread valeriodea
Thank you to the people who responded, all answers were helpful.

Is there a difference between 
return expand(f^2)
and
return (g^2).expand()
or are they perfect synonyms?

The same question for  
lambda f: (f^2).expand()
(in Simon's answer): is the lambda construction just a shortcut, equivalent 
to 
return (g^2).expand()
or is it something different?

Thanks again

 


On Saturday, February 4, 2017 at 2:48:22 PM UTC-6, valer...@gmail.com wrote:
>
> I would like to know the right way to do in SAGE what I am currently doing 
> with Mathematica in these two examples (I actually know how to do the first 
> one in SAGE, but probably not in the best way):
> 1) Finding the intersection of a generic tangent line to f(x) with f(x):
> f[x_]:= x^2(x^2-1)
> L[a_,x_]:=f[a]+f'[a](x-a)
> Solve[L[a,x]==f[x],x]
> Here the main issue for me is how use the derivative f'(x) without having 
> to define a new function g(x)=derivative(f(x))
>
> 2) Testing if |f(z)| < f(|z|) for various choices of f:
> Pl[f_,r_]:=Plot[Abs[f[r Exp[I t]]]/f[r],{t,0,2Pi}]
> Here I am mostly interested in how to write a command that uses a function 
> as a variable. 
>
> Thanks for any suggestions.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: how to do this in SAGE

2017-02-07 Thread Simon King
Hi,

On 2017-02-07, valerio...@gmail.com  wrote:
> I have not been able to use f as a parameter. To use a simpler example, 
> what is the SAGE code corresponding to this Mathematica code:
> f[x_]:=1+x+x^2
> g[x_]:=1+x+x^2+x^3
> Ex[f_]:=Expand[f[x]^2]
> Ex[f]
>
> 1 + 2 x + 3 x^2 + 2 x^3 + x^4
>
> Ex[g]
>
> 1 + 2 x + 3 x^2 + 4 x^3 + 3 x^4 + 2 x^5 + x^6

This is half a SageMath question and half a Python question (Python is
the main language in SageMath):

  sage: f(x) = 1+x+x^2
  sage: g(x) = 1+x+x^2+x^3
  sage: Ex = lambda f: (f^2).expand()
  sage: Ex(f)
  x |--> x^4 + 2*x^3 + 3*x^2 + 2*x + 1
  sage: Ex(g)
  x |--> x^6 + 2*x^5 + 3*x^4 + 4*x^3 + 3*x^2 + 2*x + 1

Note that in the above example both f and g are symbolic functions. If
you just want them to be expressions in x, use
  sage: f = 1+x+x^2
  sage: g = 1+x+x^2+x^3
instead.

Also note that "lambda" is a Python construct that isn't special to
SageMath. It allows you to create a function (here I really mean a
function in the sense of programming, not a symbolic function) on the
fly. Alternatively (which makes sense in more complicated examples),
you could define Ex like this:
  sage: def Ex(f):
  : return (f^2).expand()
  : 

Note of course that the above definitions of Ex do *not* change the
meaning of f, even though it appears as a variable in the definition of
Ex (of course, the scope of the local variable f end with the definition
of Ex).

I thought that the following is possible as well:
  sage: Ex(f_) = (f_^2).expand()
  sage: Ex(f)
  (x^2 + x + 1)^2
but as you see it doesn't give the expected answer. Reason: In the
definition of Ex, (f_^2).expand() is expanded *before* you insert f for
f_.

The last approach is bad for a second reason:
   sage: Ex(f_) = (f_^2).expand()
has the side-effect of defining f_ as a symbolic variable. In
particular, if you did use f instead of f_, it would override the
original meaning of f:
   sage: f
   x |--> x^2 + x + 1
   sage: Ex(f) = (f^2).expand()
   sage: f
   f

Generally, my recommendation is to avoid using the implicit definition
of symbolic functions. It wouldn't work in programs anyway, as it only
works since SageMath uses a preparser on interactive input:
  sage: preparse("f(y) = sin(y)+y^3")
  '__tmp__=var("y"); f = symbolic_expression(sin(y)+y**Integer(3)).function(y)'

That's what SageMath turns your input into, so that Python can
understand it.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] Re: how to do this in SAGE

2017-02-07 Thread David Joyner
On Tue, Feb 7, 2017 at 7:14 AM,   wrote:
>
>
> On Saturday, February 4, 2017 at 4:46:38 PM UTC-6, Dima Pasechnik wrote:
>>
>>
>>
>> On Saturday, February 4, 2017 at 8:48:22 PM UTC, valer...@gmail.com wrote:
>>>
>>> I would like to know the right way to do in SAGE what I am currently
>>> doing with Mathematica in these two examples (I actually know how to do the
>>> first one in SAGE, but probably not in the best way):
>>> 1) Finding the intersection of a generic tangent line to f(x) with f(x):
>>> f[x_]:= x^2(x^2-1)
>>> L[a_,x_]:=f[a]+f'[a](x-a)
>>> Solve[L[a,x]==f[x],x]
>>> Here the main issue for me is how use the derivative f'(x) without having
>>> to define a new function g(x)=derivative(f(x))
>>
>>
>> Are your f always polynomials? Sage can do much more with polynomials then
>> with "generic" symbolic functions.
>> (e.g. for intersecting plane curves an exact approach would be to compute
>> the resultant, etc)
>>
>> Regarding your last question, certainly there is no need to define a new
>> named function for everything, e.g.
>> sage: f(x)=x^2
>> sage: f.diff(x)
>> x |--> 2*x
>> sage: f.diff(x)(5)
>> 10
>>
>> works
>
>
> f is not always a polynomial, but the above surely answers my question,
> thank you
>>
>>
>>>
>>>
>>> 2) Testing if |f(z)| < f(|z|) for various choices of f:
>>> Pl[f_,r_]:=Plot[Abs[f[r Exp[I t]]]/f[r],{t,0,2Pi}]
>>> Here I am mostly interested in how to write a command that uses a
>>> function as a variable.
>>
>>
>> Sage has two different types of "functions": 1) native Python functions 2)
>> symbolic functions;
>> certainly both of these can be passed around as parameters.
>
>
> I have not been able to use f as a parameter. To use a simpler example, what
> is the SAGE code corresponding to this Mathematica code:
> f[x_]:=1+x+x^2
> g[x_]:=1+x+x^2+x^3
> Ex[f_]:=Expand[f[x]^2]
> Ex[f]
>
> 1 + 2 x + 3 x^2 + 2 x^3 + x^4
>
> Ex[g]
>
> 1 + 2 x + 3 x^2 + 4 x^3 + 3 x^4 + 2 x^5 + x^6
>
> etc.
>

Here's one way:

sage: f = 1+x+x^2
sage: g = 1+x+x^2+x^3
sage: def my_expand(x): return (x^2).expand()
sage: my_expand(f)
x^4 + 2*x^3 + 3*x^2 + 2*x + 1
sage: my_expand(g)
x^6 + 2*x^5 + 3*x^4 + 4*x^3 + 3*x^2 + 2*x + 1



>
>
>
>>
>>
>>>
>>>
>>> Thanks for any suggestions.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: how to do this in SAGE

2017-02-07 Thread Dima Pasechnik


On Tuesday, February 7, 2017 at 12:14:49 PM UTC, valer...@gmail.com wrote:
>
>
>
> On Saturday, February 4, 2017 at 4:46:38 PM UTC-6, Dima Pasechnik wrote:
>>
>>
>>
>> On Saturday, February 4, 2017 at 8:48:22 PM UTC, valer...@gmail.com 
>> wrote:
>>>
>>> I would like to know the right way to do in SAGE what I am currently 
>>> doing with Mathematica in these two examples (I actually know how to do the 
>>> first one in SAGE, but probably not in the best way):
>>> 1) Finding the intersection of a generic tangent line to f(x) with f(x):
>>> f[x_]:= x^2(x^2-1)
>>> L[a_,x_]:=f[a]+f'[a](x-a)
>>> Solve[L[a,x]==f[x],x]
>>> Here the main issue for me is how use the derivative f'(x) without 
>>> having to define a new function g(x)=derivative(f(x))
>>>
>>
>> Are your f always polynomials? Sage can do much more with polynomials 
>> then with "generic" symbolic functions.
>> (e.g. for intersecting plane curves an exact approach would be to compute 
>> the resultant, etc)
>>
>> Regarding your last question, certainly there is no need to define a new 
>> named function for everything, e.g.
>> sage: f(x)=x^2
>> sage: f.diff(x)
>> x |--> 2*x
>> sage: f.diff(x)(5)
>> 10
>>
>> works
>>
>
> f is not always a polynomial, but the above surely answers my question, 
> thank you
>
>>  
>>
>>>
>>> 2) Testing if |f(z)| < f(|z|) for various choices of f:
>>> Pl[f_,r_]:=Plot[Abs[f[r Exp[I t]]]/f[r],{t,0,2Pi}]
>>> Here I am mostly interested in how to write a command that uses a 
>>> function as a variable. 
>>>
>>
>> Sage has two different types of "functions": 1) native Python functions 
>> 2) symbolic functions;
>> certainly both of these can be passed around as parameters.
>>
>
> I have not been able to use f as a parameter. To use a simpler example, 
> what is the SAGE code corresponding to this Mathematica code:
> f[x_]:=1+x+x^2
> g[x_]:=1+x+x^2+x^3
> Ex[f_]:=Expand[f[x]^2]
> Ex[f]
>
> 1 + 2 x + 3 x^2 + 2 x^3 + x^4
>
> Ex[g]
>
> 1 + 2 x + 3 x^2 + 4 x^3 + 3 x^4 + 2 x^5 + x^6
>
> etc.
>
>
>  
Sure it's easy, although you might have to learn a bit of Python :-)


sage: def Ex(g):# we define a Python function here
: return expand(g^2)
: 
sage: f(x)=(x+1)^2
sage: Ex(f)
x |--> x^4 + 4*x^3 + 6*x^2 + 4*x + 1

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: how to do this in SAGE

2017-02-07 Thread valeriodea


On Saturday, February 4, 2017 at 4:46:38 PM UTC-6, Dima Pasechnik wrote:
>
>
>
> On Saturday, February 4, 2017 at 8:48:22 PM UTC, valer...@gmail.com wrote:
>>
>> I would like to know the right way to do in SAGE what I am currently 
>> doing with Mathematica in these two examples (I actually know how to do the 
>> first one in SAGE, but probably not in the best way):
>> 1) Finding the intersection of a generic tangent line to f(x) with f(x):
>> f[x_]:= x^2(x^2-1)
>> L[a_,x_]:=f[a]+f'[a](x-a)
>> Solve[L[a,x]==f[x],x]
>> Here the main issue for me is how use the derivative f'(x) without having 
>> to define a new function g(x)=derivative(f(x))
>>
>
> Are your f always polynomials? Sage can do much more with polynomials then 
> with "generic" symbolic functions.
> (e.g. for intersecting plane curves an exact approach would be to compute 
> the resultant, etc)
>
> Regarding your last question, certainly there is no need to define a new 
> named function for everything, e.g.
> sage: f(x)=x^2
> sage: f.diff(x)
> x |--> 2*x
> sage: f.diff(x)(5)
> 10
>
> works
>

f is not always a polynomial, but the above surely answers my question, 
thank you

>  
>
>>
>> 2) Testing if |f(z)| < f(|z|) for various choices of f:
>> Pl[f_,r_]:=Plot[Abs[f[r Exp[I t]]]/f[r],{t,0,2Pi}]
>> Here I am mostly interested in how to write a command that uses a 
>> function as a variable. 
>>
>
> Sage has two different types of "functions": 1) native Python functions 2) 
> symbolic functions;
> certainly both of these can be passed around as parameters.
>

I have not been able to use f as a parameter. To use a simpler example, 
what is the SAGE code corresponding to this Mathematica code:
f[x_]:=1+x+x^2
g[x_]:=1+x+x^2+x^3
Ex[f_]:=Expand[f[x]^2]
Ex[f]

1 + 2 x + 3 x^2 + 2 x^3 + x^4

Ex[g]

1 + 2 x + 3 x^2 + 4 x^3 + 3 x^4 + 2 x^5 + x^6

etc.





>  
>
>>
>> Thanks for any suggestions.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: how to do this in SAGE

2017-02-04 Thread Dima Pasechnik


On Saturday, February 4, 2017 at 8:48:22 PM UTC, valer...@gmail.com wrote:
>
> I would like to know the right way to do in SAGE what I am currently doing 
> with Mathematica in these two examples (I actually know how to do the first 
> one in SAGE, but probably not in the best way):
> 1) Finding the intersection of a generic tangent line to f(x) with f(x):
> f[x_]:= x^2(x^2-1)
> L[a_,x_]:=f[a]+f'[a](x-a)
> Solve[L[a,x]==f[x],x]
> Here the main issue for me is how use the derivative f'(x) without having 
> to define a new function g(x)=derivative(f(x))
>

Are your f always polynomials? Sage can do much more with polynomials then 
with "generic" symbolic functions.
(e.g. for intersecting plane curves an exact approach would be to compute 
the resultant, etc)

Regarding your last question, certainly there is no need to define a new 
named function for everything, e.g.
sage: f(x)=x^2
sage: f.diff(x)
x |--> 2*x
sage: f.diff(x)(5)
10

works
 

>
> 2) Testing if |f(z)| < f(|z|) for various choices of f:
> Pl[f_,r_]:=Plot[Abs[f[r Exp[I t]]]/f[r],{t,0,2Pi}]
> Here I am mostly interested in how to write a command that uses a function 
> as a variable. 
>

Sage has two different types of "functions": 1) native Python functions 2) 
symbolic functions;
certainly both of these can be passed around as parameters.

 

>
> Thanks for any suggestions.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] Re: How to do symbolic algebra in GF(2)={0,1}

2014-03-11 Thread Nils Bruin


On Tuesday, March 11, 2014 11:26:13 AM UTC-7, Christian Nassau wrote:
>
> You could work in the polynomial ring generated by the ak, modulo the 
> relation ak**2 = ak
>

For which sage  wraps a specially optimized library PolyBoRi:

sage: R.=BooleanPolynomialRing(3)
sage: (a+b+c)*(a+b)
a*c + a + b*c + b

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: How to do symbolic algebra in GF(2)={0,1}

2014-03-11 Thread Prakash Dey
Thanks. It solves my problem.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] Re: How to do symbolic algebra in GF(2)={0,1}

2014-03-11 Thread Christian Nassau
You could work in the polynomial ring generated by the ak, modulo the 
relation ak**2 = ak:


P=PolynomialRing(GF(2),["a%d" % i for i in (0,..,5)])
I=P.ideal([u*u-u for u in P.gens()])
Q=P.quotient(I)
@cached_function
def z(k):
   if k < 6: return Q.gens()[k]
   return z(k-6)+z(k-3)+z(k-2)*z(k-1)

for z(40) you then get

sage: Q.lift(z(40))
a0*a1*a2*a3*a4 + a0*a1*a3*a4*a5 + a1*a2*a3*a4*a5 + a0*a1*a2*a3 + 
a0*a1*a2*a4 + a0*a1*a3*a4 + a0*a1*a3*a5 + a0*a2*a3*a5 + a1*a2*a3*a5 + 
a0*a2*a4*a5 + a0*a3*a4*a5 + a1*a3*a4*a5 + a2*a3*a4*a5 + a0*a1*a2 + 
a0*a2*a3 + a0*a3*a4 + a0*a1*a5 + a0*a2*a5 + a1*a2*a5 + a1*a3*a5 + 
a1*a4*a5 + a0*a1 + a0*a2 + a1*a3 + a2*a3 + a0*a5 + a1*a5 + a4*a5 + a4


Hope this helps,
C.

On 03/11/2014 07:02 PM, Prakash Dey wrote:

Thanks. But

x= polygen(GF(2), "a")
y= polygen(GF(2), "b")
print x+y
---> gives error

How to do this symbolic algebra in GF(2)={0,1} ?

My need is the following:
  I have a recurrence relation like z[t+6]=z[t]+z[t+3]+z[t+4]*z[t+5] in GF(2)
taking z[0]=a0,z[1]=a1,...,z[5]=a5
i want to find the value of z[40] in a0,a1,..,a5



--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: How to do symbolic algebra in GF(2)={0,1}

2014-03-11 Thread Prakash Dey
Thanks. But  

x= polygen(GF(2), "a")
y= polygen(GF(2), "b")
print x+y
---> gives error

How to do this symbolic algebra in GF(2)={0,1} ?

My need is the following:
 I have a recurrence relation like z[t+6]=z[t]+z[t+3]+z[t+4]*z[t+5] in GF(2)
taking z[0]=a0,z[1]=a1,...,z[5]=a5
i want to find the value of z[40] in a0,a1,..,a5 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: How to do symbolic algebra in GF(2)={0,1}

2014-03-11 Thread Prakash Dey
On Tuesday, March 11, 2014 7:55:04 PM UTC+5:30, Prakash Dey wrote:
> I am new to sage. 
> 
> x=var('a')
> y=var('b')
> print x+y
> 
> How to do this symbolic algebra in GF(2)={0,1} ?

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: How to do symbolic algebra in GF(2)={0,1}

2014-03-11 Thread Pierre
You can try

sage: x= polygen(GF(2), "a")

and try a few expressions involving x. For example

sage: 2*x
0

since 2=0 in GF(2).

Pierre

On Tuesday, March 11, 2014 3:25:04 PM UTC+1, Prakash Dey wrote:
>
> I am new to sage. 
>
> x=var('a')
> print x*x*x*x+x*x*x+x*x+x
>
> How to do this symbolic algebra in GF(2)={0,1} ?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: How to do symbolic calculations with complex numbers

2010-08-07 Thread Jason Grout

On 8/7/10 12:25 PM, tontaube wrote:

Hello everybody!
Can I do calculations with complex numbers that are defined only by
symbols? Let's say I'd like to do the following:

sage: var("R1 X1 R2 X2")
sage: Z1 = R1 + X1*i
sage: Z2 = R2 + X2*i
sage: Z = Z1 + Z2
sage: print Z
sage: Z.imag()
R1 + R2 + I*X1 + I*X2
real_part(X1) + real_part(X2) + imag_part(R1) + imag_part(R2)

Now the imaginary part delivered by Z.imag() should be (X1 + X2)I.



This is only true if your R1, R2, X1, and X2 variables are real, right? 
 Then you have to tell Sage that, using the "domain" keyword of the 
var() function:


sage: var("R1 X1 R2 X2", domain=RR)
sage: Z1 = R1 + X1*i
sage: Z2 = R2 + X2*i
sage: Z = Z1 + Z2
sage: imag(Z)
X1 + X2
sage: real(Z)
R1 + R2


Thanks,

Jason

--
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: How to do it in cython?

2010-06-12 Thread Simon King
On 12 Jun., 08:56, Robert Bradshaw 
wrote:
> Sage is preparsed. ...

... and the preparser is not used on .pyx and .py files.

So, when you write 3 in a .pyx file, it becomes a python int, but if
you write 3 on the Sage command line, it is interpreted (by the
preparser) as a Sage integer.

However, if I am not mistaken, Cython code *is* preparsed if it is put
into a .spyx (not .pyx) filed.

Cheers,
Simon

-- 
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: How to do: is_Integer(sqrt(a^2+b^2))

2008-09-26 Thread Martin Albrecht

> >> These is_* sure are causing a lot of confusion lately...
> >
> > Indeed!  I like Mike Hansen's (or your) proposal to get
> > rid of them all from the global namespace, and replace
> > them only by "is_lowercase_method_name" functions
> > that are all conceptually meaningful.   Of course leave
> > the type-checking is_Uppercase's around, but don't
> > put them in all.py's.
> >
> > What do you guys think?
>
> +1 for sure.

+1

-- 
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_www: http://www.informatik.uni-bremen.de/~malb
_jab: [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sage-support] Re: How to do: is_Integer(sqrt(a^2+b^2))

2008-09-26 Thread mabshoff



On Sep 26, 12:06 am, Robert Bradshaw <[EMAIL PROTECTED]>
wrote:



> > Indeed!  I like Mike Hansen's (or your) proposal to get
> > rid of them all from the global namespace, and replace
> > them only by "is_lowercase_method_name" functions
> > that are all conceptually meaningful.   Of course leave
> > the type-checking is_Uppercase's around, but don't
> > put them in all.py's.
>
> > What do you guys think?
>
> +1 for sure.

The patch is up at #4192 and will be merge shortly unless there is
some last minute breakage.



> - Robert

Cheers,

Michael
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sage-support] Re: How to do: is_Integer(sqrt(a^2+b^2))

2008-09-26 Thread Robert Bradshaw

On Sep 25, 2008, at 6:11 PM, William Stein wrote:

>
> On Thu, Sep 25, 2008 at 6:06 PM, Robert Bradshaw
> <[EMAIL PROTECTED]> wrote:
>>
>>
>> On Sep 25, 2008, at 5:43 PM, William Stein wrote:
>>
>>>
>>> On Thu, Sep 25, 2008 at 5:33 PM, Quicksilver_Johny
>>> <[EMAIL PROTECTED]> wrote:

 If c=sqrt(a^2+b^2)
 How would I check if c is an integer in order to get a true/false
 value.
 I tried is_Integer(ZZ(c)), this returns true when c is an integer,
 but
 ZZ(c) returns an error when c is not an integer.
>>>
>>> Try using Python's try/except:
>>>
>>> try:
>>> ZZ(c)
>>> # c is an integer
>>> except TypeError:
>>> # c isn't an integer
>>
>> These is_* sure are causing a lot of confusion lately...
>
> Indeed!  I like Mike Hansen's (or your) proposal to get
> rid of them all from the global namespace, and replace
> them only by "is_lowercase_method_name" functions
> that are all conceptually meaningful.   Of course leave
> the type-checking is_Uppercase's around, but don't
> put them in all.py's.
>
> What do you guys think?

+1 for sure.

>> Rational numbers also have an is_integral method, so you could  
>> also dos
>>
>> c=sqrt(a^2+b^2)
>
> If a,b are integers, then c is either an integer or an element
> of the symbolic ring...

Oops... I guess one could also do "if c in ZZ" for a one-liner.

- Robert



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sage-support] Re: How to do: is_Integer(sqrt(a^2+b^2))

2008-09-25 Thread William Stein

On Thu, Sep 25, 2008 at 6:06 PM, Robert Bradshaw
<[EMAIL PROTECTED]> wrote:
>
>
> On Sep 25, 2008, at 5:43 PM, William Stein wrote:
>
>>
>> On Thu, Sep 25, 2008 at 5:33 PM, Quicksilver_Johny
>> <[EMAIL PROTECTED]> wrote:
>>>
>>> If c=sqrt(a^2+b^2)
>>> How would I check if c is an integer in order to get a true/false
>>> value.
>>> I tried is_Integer(ZZ(c)), this returns true when c is an integer,
>>> but
>>> ZZ(c) returns an error when c is not an integer.
>>
>> Try using Python's try/except:
>>
>> try:
>> ZZ(c)
>> # c is an integer
>> except TypeError:
>> # c isn't an integer
>
> These is_* sure are causing a lot of confusion lately...

Indeed!  I like Mike Hansen's (or your) proposal to get
rid of them all from the global namespace, and replace
them only by "is_lowercase_method_name" functions
that are all conceptually meaningful.   Of course leave
the type-checking is_Uppercase's around, but don't
put them in all.py's.

What do you guys think?

>
> Rational numbers also have an is_integral method, so you could also dos
>
> c=sqrt(a^2+b^2)

If a,b are integers, then c is either an integer or an element
of the symbolic ring...

> if c.is_integral():
># c is an integer
>
> - Robert
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sage-support] Re: How to do: is_Integer(sqrt(a^2+b^2))

2008-09-25 Thread Robert Bradshaw


On Sep 25, 2008, at 5:43 PM, William Stein wrote:

>
> On Thu, Sep 25, 2008 at 5:33 PM, Quicksilver_Johny
> <[EMAIL PROTECTED]> wrote:
>>
>> If c=sqrt(a^2+b^2)
>> How would I check if c is an integer in order to get a true/false
>> value.
>> I tried is_Integer(ZZ(c)), this returns true when c is an integer,  
>> but
>> ZZ(c) returns an error when c is not an integer.
>
> Try using Python's try/except:
>
> try:
> ZZ(c)
> # c is an integer
> except TypeError:
> # c isn't an integer

These is_* sure are causing a lot of confusion lately...

Rational numbers also have an is_integral method, so you could also do

c=sqrt(a^2+b^2)
if c.is_integral():
# c is an integer

- Robert

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sage-support] Re: How to do: is_Integer(sqrt(a^2+b^2))

2008-09-25 Thread William Stein

On Thu, Sep 25, 2008 at 5:33 PM, Quicksilver_Johny
<[EMAIL PROTECTED]> wrote:
>
> If c=sqrt(a^2+b^2)
> How would I check if c is an integer in order to get a true/false
> value.
> I tried is_Integer(ZZ(c)), this returns true when c is an integer, but
> ZZ(c) returns an error when c is not an integer.

Try using Python's try/except:

try:
ZZ(c)
# c is an integer
except TypeError:
# c isn't an integer

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---