[sage-support] Re: symbolic vector calculus

2014-11-28 Thread Sherif
Hi all,

I came to post a similar question and stumbled upon this discussion, which 
I realize is from 2008 - perhaps some of this functionality has been 
developed by now!

In any case, I'm brand new to Sage, as in I haven't used it at all yet 
though I'm excited to try it. So, if my question is answered somewhere in 
the documentation, you can just direct me to the right spot, but I haven't 
been able to find it.

Basically, I have a function of three vectors, let's call them x1, x2 and 
x3. The function consists of a complicated expression using dot and cross 
products. I may know the dimension of the vector space, so this is not the 
primary issue (also as far as I know, cross products are only defined for 3 
or 7 dimensions). The issue is that I want the answer to be in terms of the 
vectors, not their individual components / coordinates in an equivalent 
Euclidean vector space. The function is vector-valued (the output value is 
of the same dimension as the input vectors), and I need to apply a 
composition of this function multiple times. So, the result will be overly 
complicated and needs to be simplified using vector identities. So, I need 
to obtain something like f(a4, b4, f(a3, b3, f(a2, b2, f(a1, b1, c1.

Can Sage do anything like this currently? If not, is there a suggested 
workaround with Sage, and if not, then what other software might help?

Thanks so much!

Sherif



On Monday, July 21, 2008 12:28:19 PM UTC-4, Justin Domke wrote:
>
> Hello all, 
>
> I have a simple question about the capabilities of Sage that I have 
> not been able to resolve by looking at the documentation.  I often 
> find myself manipulating somewhat complex functions that take vector 
> arguments.  I then need to derive gradients, hessians, etc.  I need to 
> do this with out knowing the dimensions of the vectors.  So for 
> example, what I would like to do is something like the following. 
> First, I would define the function f(x)=.5 * x' * A * x + b, perhaps 
> something like: 
>
> A = matrix(); 
> x = vector(); 
> b = vector(); 
> f = function( x'  * A * x + b); 
>
> Then, I would like Sage to do the calculus for me, something like, 
> say: 
>
> f.gradient() 
> sage) 2*A*x 
> f.hessian() 
> sage) A 
>
> (Of course, I wouldn't bother using a computer algebra system for such 
> a simple function, but you get the idea.)  My question is: can Sage do 
> things like this?  I would like to avoid specifying the dimensions of 
> x, or giving the entries of A when I define the function. 
>
> Thanks! 
> Justin 
>

-- 
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] export 3D three.js graphics?

2014-11-28 Thread William Stein
On Nov 28, 2014 12:45 PM, "Dan Drake"  wrote:
>
> On Fri, 28 Nov 2014 at 12:14PM -0800, William Stein wrote:
> > What precisely do you mean by "a three.js plot"?
>
> Something like
>
>
http://sagecell.sagemath.org/?z=eJwrULBVyMnMS9WI1jDQAUJNHQUNQx0g1IzV5OUqyShKTc0q1ijQBADJxQot&lang=sage
>
> or
>
> var('x y')
> plot3d(sin(x + y),(x,-10,10),(y,-10,10), threejs=true)
>
>
> Are those using three.js? We are using Javascript stuff and not Java
> anymore, right? I guess what I'm really asking for is how to export
> whatever Javascript code we generate to make the 3D graphics so that I
> can use it elsewhere.
>
>

Sage cell and SageMathCloud have completely separate three.js based 3d
graphics implementations
>
>
> Dan
>
> --
> ---  Dan Drake
> -  www.math.wisc.edu/~ddrake/
> ---
>
> --
> 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.

-- 
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] export 3D three.js graphics?

2014-11-28 Thread Dan Drake
On Fri, 28 Nov 2014 at 12:14PM -0800, William Stein wrote:
> What precisely do you mean by "a three.js plot"?

Something like

http://sagecell.sagemath.org/?z=eJwrULBVyMnMS9WI1jDQAUJNHQUNQx0g1IzV5OUqyShKTc0q1ijQBADJxQot&lang=sage

or

var('x y')
plot3d(sin(x + y),(x,-10,10),(y,-10,10), threejs=true)


Are those using three.js? We are using Javascript stuff and not Java
anymore, right? I guess what I'm really asking for is how to export
whatever Javascript code we generate to make the 3D graphics so that I
can use it elsewhere.




Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

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


signature.asc
Description: Digital signature


Re: [sage-support] export 3D three.js graphics?

2014-11-28 Thread William Stein
- William Stein (cell phone)
On Nov 28, 2014 9:46 AM, "Dan Drake"  wrote:
>
> Hi,
>
> If I have a 2D plot, I can save it to an image file and then include
> that image on any web page I like.
>
> Is there a corresponding way to export a three.js plot so that I can
> include it on a web page?
>

What precisely do you mean by "a three.js plot"?

> Thanks,
>
> Dan
>
> --
> ---  Dan Drake
> -  www.math.wisc.edu/~ddrake/
> ---
>
> --
> 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.

-- 
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] export 3D three.js graphics?

2014-11-28 Thread John Cremona
I would like to know this too.

John

On 28 November 2014 at 17:43, Dan Drake  wrote:
> Hi,
>
> If I have a 2D plot, I can save it to an image file and then include
> that image on any web page I like.
>
> Is there a corresponding way to export a three.js plot so that I can
> include it on a web page?
>
> Thanks,
>
> Dan
>
> --
> ---  Dan Drake
> -  www.math.wisc.edu/~ddrake/
> ---
>
> --
> 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.

-- 
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: fast_callable of sybolyc expression with no variables

2014-11-28 Thread Nils Bruin
On Monday, November 24, 2014 11:19:40 AM UTC-8, Jesús Torrado wrote:
>
> Hi there,
>
> I am using fast_callable in order to pass numpy arrays to symbolic 
> expressions, as suggested [here](
> http://ask.sagemath.org/question/8383/using-symbolic-expressions-with-numpy-arrays/
> )
>
> I encountered the following behaviour:
>
> sage: var('x')
> sage: f(x) = x**2
> sage: fast_callable(f)(2)
> 4
> sage: f(x) = 0
> sage: fast_callable(f)(2)
> [...]
> ValueError [and no message here]
> sage: f(x) = 0
> sage: f(x) = 0
> sage: fast_callable(f, vars=[x])(2)
> 0
>
> I guess this is not a bad behaviour per se (though the exception looks 
> like it has not been handled properly). Nevertheless, I think it would be 
> nice that when `f.variables()==()`, `fast_callable` simply discards the 
> input. It would save some testing for corner cases: if I pass `f` to a 
> function that expects `f(x)` with one variable, one would have to check for 
> the special case of a zero-defined `f`.
>

The case of 0 variables is only a special case. This occurs more generally 
for "symbolic functions"  that do not actually have all their arguments 
appear in their evaluating expression:

sage: f(x,y)=y
sage: fast_callable(f)(1,2)
ValueError:

In fact, the behaviour leads to silent differences in results that should 
probably lead to an error of some sort:

sage: f(3)
y
sage: fast_callable(f)(3)
3

As you remark, fast_callable(f,vars=[x,y]) does do the right:

sage: fast_callable(f,vars=(x,y))(1,2)
2
sage: fast_callable(f,vars=(x,y))(3)
ValueError:

so the problem is that fast_callable is using the wrong heuristics for 
determining "vars" when not explicitly given. From the printing it's pretty 
clear what should be used:

sage: f
(x, y) |--> y

(clearly the left hand side is the best guess for "vars" in this case)

but I have trouble finding an easy criterion to recognize that f needs 
different treatment from f(x,y):

sage: type(f)

sage: type(f(x,y))

sage: f(x,y)
y

The heuristics used in fast_callable are problematic in other situations 
too:

sage: f(u,v)=x^2*u+v
sage: f
(u, v) |--> u*x ^2+ v
sage: f(3,5,7) #shouldn't we complain about the extra argument?
3*x^2 + 5
sage: fast_callable(f)(1,2)
ValueError:
sage: fast_callable(f)(3,5,7) #do we know for sure the x will land in the 
third position?
152
sage: fast_callable(f,vars=(u,v))(1,2) #perhaps the free x should cause an 
earlier error?
ValueError: Variable 'x' not found

-- 
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] export 3D three.js graphics?

2014-11-28 Thread Dan Drake
Hi,

If I have a 2D plot, I can save it to an image file and then include
that image on any web page I like.

Is there a corresponding way to export a three.js plot so that I can
include it on a web page?

Thanks,

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: Porting one Python code to a Sage one

2014-11-28 Thread William Stein
On Fri, Nov 28, 2014 at 8:39 AM, Christophe Bal  wrote:
> Hello.
>
> There is two points of view here.
>
> Using Python for math, and in this case, the less technic of programmation
> is used and the best it is. This is more true with young students. Sage is a
> great tool for that ! I definitely love it !
> Using Python for starting programmation and in this case, do not speak of
> importation will be an error.
>
> In my work, for the moment I have student doing math and not programmation.

That's a nice way to clarify the situation.

For many users, Sage is primarily a Python program for doing
computational mathematics (as its mission statement: "viable
alternative to Magma, etc." implies), and secondarily a computational
mathematics library to support Python programs.

William

>
>
> Christophe BAL
> Enseignant de mathématiques en Lycée et développeur Python amateur
> ---
> French math teacher in a "Lycée" and amateur developer in Python
>
> 2014-11-28 0:26 GMT+01:00 William Stein :
>>
>> On Thu, Nov 27, 2014 at 3:12 PM, Simon King 
>> wrote:
>> > Hi Christophe,
>> >
>> > On 2014-11-27, Christophe Bal  wrote:
>> >> Indeed, my question is related to pedagogical reasons. Even if my code
>> >> is
>> >> simple, it uses the import machinery that I would like to not use.
>> >
>> > Why not? Isn't it a good thing to teach students that polluting the
>> > global name space is bad and thus that the stuff one needs should
>> > first be imported?
>>
>> I disagree.   A basic design choice in Sage -- since day 1 -- is not
>> to make such a judgement.
>> Sage is meant to be an easy to use system designed for mathematics,
>> which happens to use Python
>> as a language, instead of me creating a new language from scratch.
>>
>> Of course we have to take with what is introduced in the global
>> namespace.  But that you can start
>> Sage and type
>>
>>   sage: sin(pi)
>>
>> is not only *good*, but critical.   Requiring all users to do a few
>> imports before the above would be bad.
>>
>>  -- William
>>
>> >
>> > 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 http://groups.google.com/group/sage-support.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> William Stein
>> Professor of Mathematics
>> University of Washington
>> http://wstein.org
>>
>> --
>> 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.
>
>
> --
> 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.



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

-- 
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: Porting one Python code to a Sage one

2014-11-28 Thread Christophe Bal
Hello.

There is two points of view here.

   1. Using Python for math, and in this case, the less technic of
   programmation is used and the best it is. This is more true with young
   students. Sage is a great tool for that ! I definitely love it !
   2. Using Python for starting programmation and in this case, do not
   speak of importation will be an error.

In my work, for the moment I have student doing math and not programmation.


*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a "Lycée" **and amateur developer in Python*

2014-11-28 0:26 GMT+01:00 William Stein :

> On Thu, Nov 27, 2014 at 3:12 PM, Simon King 
> wrote:
> > Hi Christophe,
> >
> > On 2014-11-27, Christophe Bal  wrote:
> >> Indeed, my question is related to pedagogical reasons. Even if my code
> is
> >> simple, it uses the import machinery that I would like to not use.
> >
> > Why not? Isn't it a good thing to teach students that polluting the
> > global name space is bad and thus that the stuff one needs should
> > first be imported?
>
> I disagree.   A basic design choice in Sage -- since day 1 -- is not
> to make such a judgement.
> Sage is meant to be an easy to use system designed for mathematics,
> which happens to use Python
> as a language, instead of me creating a new language from scratch.
>
> Of course we have to take with what is introduced in the global
> namespace.  But that you can start
> Sage and type
>
>   sage: sin(pi)
>
> is not only *good*, but critical.   Requiring all users to do a few
> imports before the above would be bad.
>
>  -- William
>
> >
> > 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 http://groups.google.com/group/sage-support.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> William Stein
> Professor of Mathematics
> University of Washington
> http://wstein.org
>
> --
> 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.
>

-- 
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 free memory used by object?

2014-11-28 Thread Jori Mantysalo

On Wed, 26 Nov 2014, Simon King wrote:


If it is not collectable by Python's cyclic garbage collector, then
there is a bug. Can you open a trac ticket for it, putting me as Cc?


Now I don't understand at all. I modify the code just to write memory 
usage in the middle of loop --- and there is no leak.


A heisenbug? Something else?

Anyways, no ticket because no reproducible bug.

--
Jori Mäntysalo


[sage-support] Re: Why solve(5^( x -1) == (0.04)^(2*x), x) returns empty set?

2014-11-28 Thread Jakob Kroeker

>
> Other opinions? If everybody agrees, I will open a ticket.
>>
>  
>
Please do!  Thanks! 
>

here is the corresponding ticket:

http://trac.sagemath.org/ticket/17412

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