Ask Your Question

alessandro's profile - activity

2023-05-28 11:50:32 +0200 received badge  Notable Question (source)
2023-05-28 11:50:32 +0200 received badge  Popular Question (source)
2020-12-04 18:12:00 +0200 received badge  Student (source)
2018-12-17 03:48:53 +0200 received badge  Famous Question (source)
2017-04-26 15:39:15 +0200 received badge  Famous Question (source)
2016-10-11 00:18:21 +0200 received badge  Notable Question (source)
2016-04-13 02:19:11 +0200 received badge  Notable Question (source)
2015-10-23 22:11:15 +0200 received badge  Popular Question (source)
2015-03-09 22:41:27 +0200 received badge  Popular Question (source)
2015-01-18 11:28:23 +0200 received badge  Taxonomist
2013-10-21 05:58:38 +0200 answered a question conversions from/to FunctionField(SR) and symbolic expression

P.S. my project is on:

https://github.com/alessandro-bernardini/SAPICE

and it is a full work in progress. The documentation has to be adjusted and rewritten because at the moment the documentation does not (more) match "the reality" in the software class SmallSignalLinearCircuit.

The class reads a ngspice netlist (for the moment only BJT are supported as active elements) computes the small signal linear(ized) circuit and the corresponding nodal equations that can be solved symbolically or numerically (with sage).

Impedances can be computed symbolically or numerically (and the two port network parameters) ... and poles/zeros as far as the polynomial degree allows a symbolic solution ( <= 4 ).

"Automatic" simplification is thus a key concept, and only those terms have to be considered that "dominates" and the others ignored.

For this functions like symplify_rational_func will play an important role.

2013-10-21 05:47:24 +0200 answered a question conversions from/to FunctionField(SR) and symbolic expression

Thank you:

the unfold_refold method in the post of tmonteil is maybe the best solution.

In the approach of nbruin I have following problem: - expr1 is a very very big rational function in s with symbolic coefficients resulting from a solution to a system of linear equations: in the specific from the system of nodal equations of a linear electric circuit in the Laplace domain... The system is solved not for s but for the nodal voltages and s=var('s') will be the complex angular frequency (a parameter).

Because the resulting expressions are very big I am automatically simplifying terms that evaluate to tiny (absolute) values - provided an initial (or typical) value for the circuit paramters.

For rational functions I need the numerator_denominator expressions, but it takes too long to compute them. With FunctionField it goes faster, but I have the conversion problem (in both directions).

I think s must remain symbolic because it is needed in the solution of the system of nodal equations. Or am I wrong here ?

In the answer of nbruin I have to compute numerator and denominator, which IS my problem because of runtime.

So the unfold_refold method can be a good idea: I will try it and let you know...

2013-10-20 07:27:40 +0200 answered a question conversions from/to FunctionField(SR) and symbolic expression

and in case how can i do the inverse conversion... ?

2013-10-20 07:16:23 +0200 asked a question conversions from/to FunctionField(SR) and symbolic expression

Hello, read the following session OR if you won't please go directly to the question below

  $ sage
  ----------------------------------------------------------------------
  | Sage Version 5.6, Release Date: 2013-01-21                         |
  ----------------------------------------------------------------------
  sage: a,b,s = var('a b s')
  sage: expr1 = (a^2*s + 2)/(s^3 + s + 3) + s
  sage: expr1.denominator()
  s^3 + s + 3
  sage: type(s)
  <type 'sage.symbolic.expression.Expression'>
  sage: FF.<s> = FunctionField(SR)
  sage: FF(expr1)            
  s + (a^2*s + 2)/(s^3 + s + 3)
  sage: FF(expr1).denominator()
  1
  # s in expr1 is NOT recognized as the s in the definition of the
  # function field.
  sage: type(s)
  <type  'sage.rings.function_field.function_field_element.FunctionFieldElement_rational'>
  # BUT:
  sage: x = var('x')                       
  sage: expr2 = x + (45^2 + 2)/(x^3 + x + 3)
  sage: FF2.<x> = FunctionField(RR) 
  # now RR instead of SR and x as the variable.
  sage: FF2(expr2)
  (x^4 + x^2 + 3.00000000000000*x + 2027.00000000000)/(x^3 + x + 3.00000000000000)
  sage: FF2(expr2).denominator()
  x^3 + x + 3.00000000000000
  # x is correctly recognized in expr2 but not in expr1 !
  sage: type(x)
  <type 'sage.rings.function_field.function_field_element.FunctionFieldElement_rational'>

QUESTION: a FunctionField over RR with the variable x correctly recognizes expressions where x=var('x') appears in the expression (see above), and the computation of denominator is correct; FunctionField over SR with the variable s do not recognizes expressions with s=var('s'); instead in this case the s is treated like a coefficient (denominator=1 in example above in the first part). How can i adjust this behavior, so that I obtain the same answer in both following cases:

     sage: expr1                                                                                                                                                                                    
     s + (a^2*s + 2)/(s^3 + s + 3)   
     # here s = var('s') is symbolic expression                                                                                                                                                               
     sage: FF(expr1).denominator()                                                                                                                                                                  
     1  
     # I DO NOT WANT THIS ANSWER                                                                                                                                                                                            
     sage: FF(s + (a^2*s+2)/(s^3 + s + 3)).denominator()                                                                                                                                            
     s^3 + s + 3
     # but this answer (that works if the expression is constructed by hand) with
     sage: type(s)
     <type 'sage.rings.function_field.function_field_element.FunctionFieldElement_rational'>

Any suggestion ? THANK YOU VERY MUCH !

2013-10-18 21:01:16 +0200 answered a question numerator_denominator()

This seems a good idea.

But I have an expression of type 'sage.symbolic.expression.Expression' that contains a variable s of the same type.

When I use your approach I have/handle objects of type 'sage.rings.function_field.function_field_element.FunctionFieldElement_rational' after constructing a Rational function field in s over Symbolic Ring (of type sage.rings.function_field.function_field.RationalFunctionField_with_category')

SO THE ONE s (in the expression) is NOT the s in the function field element...

If I do the conversion with K(expr) the whole expr is considered as a block and is not "parsed" for s... So when then I call denominator I always get 1

How can this be fixed/handled ?

Thanx you !

2013-10-18 10:18:11 +0200 answered a question is_polynomial with symbolic coefficients: bug ?

(s/(s^3+2*s) + 3).is_polynomial(s)

returns True

Check this case also...

Thanks.

2013-10-17 16:50:31 +0200 asked a question is_polynomial with symbolic coefficients: bug ?

sage: s, a, b= var('s a b')

sage: (1/s^2 + s).is_polynomial(s)

False

sage: (a/s^2 + b*s).is_polynomial(s)

True

Should the second call of is_polynomial not return False as in the first case ?

Is this a bug ?

Who and howto report ?

2013-10-17 16:34:14 +0200 answered a question numerator_denominator()

I have symbolic coefficients...

Thank you

2013-10-16 18:58:48 +0200 asked a question numerator_denominator()

I have a very big rational function and i want to obtain the numerator and denominator. with .numerator_denominator() it takes forever with .numerator_denominator(False) not every term is expanded. with .expand() and .combine() it takes forever and the result is not a single fraction.

I need a single fraction N(x)/D(x) where N and D are polynomials in x, it is not important how big !

2013-09-28 09:38:45 +0200 answered a question save_session runs forever

save or save_session seems not to work on very large expressions. But cPickle seems to work. http://docs.python.org/release/2.5/li... http://www.sagemath.org/doc/tutorial/...

I cite the second link: (In Python, saving and loading is accomplished using the cPickle module. In particular, a Sage object x can be saved via cPickle.dumps(x, 2). Note the 2!)

2013-09-26 09:22:48 +0200 asked a question save_session runs forever

Hello,

when I try to save a session (save_session command) with some expressions that are very long (composed by sums with hundred of terms) then the save session command runs for hours without producing any result nor writing anything to the file that should be created for storing the session on disk.

What can I do ?