Ask Your Question

Juanlu001's profile - activity

2021-12-14 03:03:46 +0200 received badge  Famous Question (source)
2016-11-02 21:38:31 +0200 received badge  Good Answer (source)
2016-10-23 11:57:31 +0200 received badge  Notable Question (source)
2016-09-27 14:09:43 +0200 received badge  Famous Question (source)
2014-06-29 03:14:52 +0200 marked best answer Difference between f and f(r)

I was experimenting with symbolic functions, and I was wondering what is the difference between these two forms of creating one:

sage: f1 = function('f', r)
sage: f2(r) = function('f', r)

I have made some experiments in this Sage worksheet, but except for some output differences, I don't know what will happen if I try to differentiate them, integrate them, put them into an equation, etc.

Any ideas?

2014-06-29 03:14:51 +0200 marked best answer Solving complex equation

I was trying to solve the following equation over the complex numbers: sin(z) + cos(z) = 2

In Sage:

sage: z = var('z')
sage: solve(sin(z) + cos(z) == 2, z)
[sin(z) == -cos(z) + 2]

Obviously, that's not what I want. Wolfram|Alpha yields the two solutions in multiple forms: http://www.wolframalpha.com/input/?i=cos%28z%29+%2B+sin%28z%29+%3D%3D+2

Can this be done in Sage?

2014-05-21 15:00:37 +0200 received badge  Nice Question (source)
2014-02-13 10:01:35 +0200 received badge  Famous Question (source)
2013-12-21 13:06:42 +0200 received badge  Notable Question (source)
2013-08-15 07:11:26 +0200 marked best answer Solving complex equation
sage: solve(sin(x)+cos(x)==2,x,to_poly_solve=True)
[x == 1/4*pi + 2*pi*z6 - I*log(-1/2*(sqrt(2) - 2)*sqrt(2)), x == 1/4*pi + 2*pi*z8 - I*log(sqrt(2) + 1)]

Note that one gets a family of solutions because these are multi-valued inverses.

The to_poly_solve option still is not documented in the global solve?, but will show up if you do x.solve?. Apologies for not having done this.

2013-05-01 10:45:02 +0200 received badge  Popular Question (source)
2012-10-17 11:02:42 +0200 received badge  Great Question (source)
2012-09-06 14:15:02 +0200 received badge  Notable Question (source)
2012-09-03 12:46:47 +0200 received badge  Popular Question (source)
2012-01-27 10:51:26 +0200 received badge  Popular Question (source)
2011-12-05 17:25:00 +0200 commented answer Complex argument of a symbolic expression

Hm, works in this case, but it seems I still have problems with plot(), for example. Thank you anyway!

2011-12-05 17:24:28 +0200 marked best answer Complex argument of a symbolic expression

You can do this:

sage: z = i + 1.0
sage: arg(z)
0.785398163397
2011-11-15 13:06:02 +0200 asked a question Complex argument of a symbolic expression

I was wondering how could I get the argument of an expression involving complex numbers. For example, this simple case fails at first:

sage: z = i + 1.0
sage: z.argument() 

Traceback (most recent call last):
...
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'argument'

But:

sage: i = CC.0
sage: z = i + 1.0
sage: z.argument() * 180 / pi.n()
45.0000000000000

As you can see in this worksheet.

Of course, if the expression involves symbolic variables and such the same problem appears. Is there any direct way I can calculate the complex argument of a symbolic expression?

I mean, apart from

atan(z.imag() / z.real())

of course.

2011-09-20 04:24:30 +0200 commented answer Difference between U and U(t)

That's great! :)

2011-09-20 04:24:30 +0200 received badge  Commentator
2011-07-31 06:47:12 +0200 marked best answer Difference between f and f(r)

First off, what is missing here (but is in your worksheet) is var("r") at the beginning. Otherwise your first one is calling R!

As to the others, as you see on the worksheet, the difference is that the first one is a "symbolic expression", in which variables have to be substituted, while the second is a "callable symbolic expression", where you don't have to do this. Compare:

sage: f1.subs(r=3)
f(3)
sage: f2(3)
f(3)

sage: preparse("f2(r) = function('f', r)")
'__tmp__=var("r"); f2 = symbolic_expression(function(\'f\', r)).function(r)'

What happens is that the .function method turns it into something with a specific variable r that is the input. If you had 'constants' like 'a' or 'b' in your function, this would make more sense, e.g.

sage: var('a,b,c')
(a, b, c)
sage: f3(r)=a*b*c*function('f',r)
sage: f3
r |--> a*b*c*f(r)

So you could only substitute r with the function syntax; for the rest you'd need the .subs method.

Otherwise, they should be pretty much identical, I think. You have to be a little careful with whether you call the second one f2(r) or just f2, I think, in things like numerical integration, maybe. I can't remember the exact contexts in which that matters, but it is not frequent.

2011-07-31 06:20:37 +0200 commented question Difference between U and U(t)

Here is a similar question, tell us if the answers there are useful for you: http://ask.sagemath.org/question/555/difference-between-f-and-fr

2011-07-27 14:08:30 +0200 answered a question Solving symbolically equation system

In this case, having seen the structure of the ODEs system, I would rather substitute (2) into (1), so you would have a second order ODE:

$$U(t) = R \cdot C \cdot uC'(t) + L \cdot C \cdot uC''(t) + uC(t)$$

And then you could solve it the normal way.

2011-06-28 16:36:33 +0200 commented question using sage functions with data from octave

Good question, though. I tried `b.sage()`, but also raised a NotImplementedError

2011-06-28 16:30:22 +0200 commented question using sage functions with data from octave

Did you mean `b = octave_hist(a)`?

2011-06-25 08:10:52 +0200 answered a question Minimal notebook system requirements

Here is some info from Jason Grout, who managed to set up a Sage Server:

"The biggest bottleneck seems to be RAM; that will determine how many simultaneous users you can have. From some informal tests, it seems that the Sage notebook uses about 150MB of RAM for the server and about 50MB for a worksheet instance."

From here: http://wiki.sagemath.org/SageServer#HardwareRequirements

2011-06-23 16:51:02 +0200 commented answer equivalent command in sage?

I know how you feel: I also was a Mathematica user before getting into Sage. It is worth the effort :)

2011-06-23 10:08:00 +0200 received badge  Good Answer (source)
2011-06-21 23:39:07 +0200 received badge  Nice Answer (source)
2011-06-21 17:40:23 +0200 commented answer equivalent command in sage?

By the way, here is an interact I made to find out the Fourier series of a piecewise defined function: http://flask.sagenb.org/home/pub/90/

2011-06-21 17:38:56 +0200 answered a question equivalent command in sage?

Yep: it's the decorator interact.

Documentation: http://www.sagemath.org/doc/reference...

Examples: http://wiki.sagemath.org/interact/