Ask Your Question

avi9526's profile - activity

2023-08-26 17:44:03 +0200 received badge  Popular Question (source)
2023-08-21 04:07:01 +0200 commented answer Why solve function can't solve system which can be solved manually

I'm sorry, but I'm a bit confused by what you're saying. I manually derived that formula, and it appears to be the corre

2023-08-21 04:02:04 +0200 marked best answer Why solve function can't solve system which can be solved manually

This returns an empty list:

reset()
var('i_B10 i_B6 i_B11 i_C10 i_C6 i_C11 beta i_in i_out i_E10 i_E6 i_E11')
solve([
  i_C10 == i_B10 * beta,
  i_E10 == i_C10 + i_B10,

  i_C6 == i_B6 * beta,
  i_E6 == i_B6 + i_C6,

  i_C11 == i_B11 * beta,
  i_E11 == i_B11 + i_C11,

  i_E10 == i_B11 + i_E6,

  i_E11 + i_E6 == i_in + i_out,

  i_B11 == i_B6,
  i_in == i_B10 + i_C11,
  i_out == i_C10

], i_out)

Output:

[]

But it can be solved manually

reset()
var('i_B10 i_B6 i_B11 i_C10 i_C6 i_C11 beta i_in i_out i_E10 i_E6 i_E11')

i_C10 = i_B10 * beta
i_E10 = i_C10 + i_B10
i_C6 = i_B6 * beta
i_E6 = i_B6 + i_C6
i_C11 = i_B11 * beta
i_E11 = i_B11 + i_C11
i_B10 = (i_E10 == i_B11 + i_E6).solve(i_B10)[0].right()
i_B10 = i_B10(i_B11=i_B6)
i_C10 = i_C10(i_B10=i_B10)
i_B6 = solve(i_in == i_B10 + i_C11(i_B11=i_B6), i_B6)[0].right()
i_out = i_C10(i_B6=i_B6)

i_out = i_out.simplify_rational()
i_out

Output:

(beta^2 + 2*beta)*i_in/(beta^2 + 2*beta + 2)

Why solve doesn't work? Do I need to set some assumptions or etc? Or is because i_out depends only on one variable? How to make "solve" function work in this case?

2023-08-21 04:02:00 +0200 answered a question Why solve function can't solve system which can be solved manually

This system of equations is based on electronic circuit. Seems 'solve' works fine if asked to find all unknown values: (

2023-08-18 21:37:17 +0200 received badge  Famous Question (source)
2023-08-07 04:22:12 +0200 edited question Why solve function can't solve system which can be solved manually

Why solve function can't solve system of which can be solved This returns nothing reset(); var('i_B10 i_B6 i_B11 i_C10

2023-08-07 04:21:59 +0200 asked a question Why solve function can't solve system which can be solved manually

Why solve function can't solve system of which can be solved This returns nothing reset(); var('i_B10 i_B6 i_B11 i_C10

2021-07-04 03:30:17 +0200 received badge  Notable Question (source)
2021-05-18 16:06:34 +0200 received badge  Notable Question (source)
2020-10-02 16:55:07 +0200 received badge  Notable Question (source)
2018-12-03 05:41:40 +0200 received badge  Notable Question (source)
2017-04-10 08:19:26 +0200 received badge  Nice Question (source)
2015-11-06 02:14:25 +0200 received badge  Popular Question (source)
2015-05-26 20:09:49 +0200 received badge  Popular Question (source)
2015-04-09 17:13:45 +0200 received badge  Famous Question (source)
2014-06-29 03:14:53 +0200 marked best answer Make sage to don't open brackets while solving equation

Hi, I have an equation

import sympy

...

eq1 = 80*X*e^(T*p) + X*e^(2*T*p) == 5*e^(T*p)/(e^(T*p) - 1) + e^(T*p)/(e^(T*p) - e^(2*T))

and when I do

Xi = eq1.solve(X)
X = Xi[0].right()
X = X.simplify_full()
X = sympy.simplify(X)
X = X.subs(e^(p*T), z)
X = SR(X)

get answer

X = (6*z - 5*e^(2*T) - 1)/(z^3 - z^2*e^(2*T) + 79*z^2 - 79*z*e^(2*T) - 80*z + 80*e^(2*T))

Next I need to find pole of X (z that gives denominator==0). But sagemath opened the brackets in denominator

sage: Xi
[X == -(6*e^(T*p) - 5*e^(2*T) - 1)/(79*e^(T*p + 2*T) + e^(2*T*p + 2*T) + 80*e^(T*p) - 79*e^(2*T*p) - e^(3*T*p) - 80*e^(2*T))]

it's very bad. Here numerator have only 3rd power, but if it will be bigger, sagemath (i think) give me no solution. When I do prevision commands using pen and paper I get in denominator

(z-1)*(z+80)*(z-e^(2*T))

how to get it with sagemath?

(sorry for bad eng.)

2014-06-29 03:14:53 +0200 marked best answer Replace part of expression

Hi, I've got an expression

X = (5/(e^(T*p) - 1) + 1/(e^(T*p) - e^(2*T)))*e^(T*p)/(80*e^(T*p) + e^(2*T*p))

(its result of D-transform - discrete laplace transform - don't know details, me bad in math) I need to replace e^(T*p) by z How can i do that ? Thanks!

2014-06-29 03:14:52 +0200 marked best answer Sage notebook with secure connection

I am using next command line to run sage notebook

gnome-terminal -e "/home/avi9526/Programs/sage-4.6.2-linux-32bit-ubuntu_10.04_lts-i686-Linux-i686-Linux/sage -n port=8000 accounts=1 open_viewer=0 interface='' ulimit='-v 500000'"

but, notebook tell me that I am crazy and someone can get access to my account (really I haven't important data in sage account). If I try to run with secure=True - sage ask me for a domain name, I type it (or just think that it was it) and get no warning about insecure mode, but, also - no access to sage notebook from world or from localhost. I really need to run with secure=True ? If yes - then how to get working web interface ?

2014-06-29 03:14:50 +0200 marked best answer arctan of infinity is undefined

Using the following code for an equation, I get an undefined result for arctan(oo):

sage: var('t, p, w')
(t, p, w)
sage: a = w^2
sage: b = w
sage: k = b/a
sage: phi = arctan(k)
sage: a = lim(k, w=0)
sage: a
Infinity
sage: lim(phi, w=0) # should be pi/2 ?
und
sage: b = oo
sage: arctan(b)
1/2*pi
sage: a==b
True
sage: arctan(a)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: cannot coerce arguments: no canonical coercion from The Unsigned Infinity Ring to Symbolic Ring

What is wrong?

2014-06-29 03:14:49 +0200 marked best answer Additional conditions for expression

Hi (sorry for bad eng.), i have next code

reset()
var('K1, T1, T2')
var('p')
# Transient function W(p)
W = K1 * p / ((T1 * p - 1) * (T2 * p - 1))
# Amplitude-phase-frequency characteristic W(jw)
Wa(omega) = W(p = I * omega)

Re(omega) = Wa(omega).real()
Im(omega) = Wa(omega).imag()

print(Re)

but last string gives loooooong result, because sagemath don't knows that K1, T1, T2 and omega are real, how to "tell" that to sagemath ?

2014-06-29 03:14:49 +0200 marked best answer Inaccurate numerical result for roots of square equation

Hi,I have 'Sage Version 4.6.1, Release Date: 2011-01-11' and I using next code to get roots of square equation:

reset()
var('a b c p pz pz2')

a = 0.0000148294611962432
b = 9.90113840830450
c = 1.00000000000000
A = a*p^2 + b*p + c

pz = solve(A == 0, p, solution_dict = True)
pz = [s[p].n() for s in pz];
Result1 = A(p=pz[0])

This way give very bad accuracy of the 1st root (Result1=-0.00138422288000584). What i do wrong? And How to get precision result with Sage? Thanks!

2014-05-14 13:15:19 +0200 received badge  Notable Question (source)
2013-11-20 14:41:13 +0200 received badge  Popular Question (source)
2013-11-08 16:03:01 +0200 received badge  Taxonomist
2013-08-02 09:11:44 +0200 received badge  Famous Question (source)
2013-04-29 19:33:52 +0200 marked best answer Get variants of complex cube-root

Fist, when you write

sage: a = (-1)^(1/3)

you define an element of the Symbolic Ring, which is not a safe place:

sage: a.parent()
Symbolic Ring
sage: a^2
1

So it is better to work on QQbar, the set of algebraic complex numbers.

sage: a = QQbar(-1)^(1/3)
sage: a.parent()
Algebraic Field
sage: a^2
-0.500000000000000? + 0.866025403784439?*I

Now, if a is a cubic root of some complex number (in your case -1), the other cube roots are a*j and a*j^2, where j=exp(2*I*pi/3)=(-1+I*sqrt(3))/2. Hence you can define

sage: j = QQbar(-1)^(2/3)
sage: j == QQbar(e^(2*I*pi/3))
True
sage: j == QQbar(-1+I*sqrt(3))/2 
True
sage: 1+j+j^2 == 0
True
sage: complex_cube_roots = [a, a*j, a*j^2]

and check

sage: for i in complex_cube_roots:
....:     print i, 'whose cube is', i^3
0.500000000000000? + 0.866025403784439?*I whose cube is -1
-1 whose cube is -1
0.500000000000000? - 0.866025403784439?*I whose cube is -1
2013-04-25 15:31:30 +0200 asked a question Get variants of complex cube-root

I found-out that complex cube-root can have 3 variants (see http://en.wikipedia.org/wiki/Cube_root)

But if I try in SageMath to do

(-1)^(1/3)

SageMath return (-1)^(1/3). When I try

(-1)^(1/3).n()

SageMath gives me numerical approximation of the one root (not real)...

How I can get all variants of complex cube-root without numerical approximation?

Thanks! P.S. Sorry for poor English...

2013-03-07 02:25:17 +0200 received badge  Popular Question (source)
2013-02-07 23:52:42 +0200 received badge  Popular Question (source)
2012-12-10 19:12:44 +0200 received badge  Famous Question (source)
2012-12-04 10:52:47 +0200 received badge  Notable Question (source)
2012-05-02 15:58:30 +0200 received badge  Good Question (source)
2012-04-27 02:59:31 +0200 received badge  Popular Question (source)
2012-01-20 01:37:15 +0200 received badge  Notable Question (source)
2011-10-21 13:00:15 +0200 received badge  Popular Question (source)
2011-06-11 01:00:27 +0200 marked best answer Sage notebook with secure connection

If you are just trying to run the notebook on your own computer, you should just be able to do

./sage -n

(which could be the whole thing above which you do, except the part after -n) and enjoy a web browser pop up with the notebook.

Do remember, though, that arbitrary Python code can be executed from the notebook, so nasty things can be done via an insecure notebook accessed from off line. If you're trying to set up a server, see (for instance) this wiki page in addition to the notebook documentation.

2011-06-03 16:25:06 +0200 marked best answer Replace part of expression

Alternatively, you can write your expression out using Sympy, a symbolics package that's included with Sage. (Sympy Documentation)

sage: from sympy import *
sage: T = Symbol('T')
sage: p = Symbol('p')
sage: z = Symbol('z')
sage: X = (5/(exp(T*p) - 1) + 1/(exp(T*p) - exp(2*T)))*exp(T*p)/(80*exp(T*p) + exp(2*T*p))
sage: X.subs(exp(T*p),z)
z*(1/(z - exp(2*T)) - 5/(1 - z))/(80*z + z**2)

Note that Sympy correctly identifies that exp(2*T*p) == z^2. In some cases, Sympy can work better than the core of most of Sage's symbolics: Maxima. You should try both and see which one performs to your liking. You can easily switch from Sage's symbolic expressions to Sympy's by doing the following:

sage: import sympy
sage: var('T,p,z')
sage: X = (5/(e^(T*p) - 1) + 1/(e^(T*p) - e^(2*T)))*e^(T*p)/(80*e^(T*p) + e^(2*T*p))
sage: type(X)
<type 'sage.symbolic.expression.Expression'>
sage: Y = sympy.sympify(X)
sage: Y
(1/(-exp(2*T) + exp(T*p)) - 5/(1 - exp(T*p)))*exp(T*p)/(80*exp(T*p) + exp(2*T*p))
sage: type(Y)
<class 'sympy.core.mul.Mul'>

You can now treat Y similarly as above.

sage: Y.subs(exp(T*p),z)
z*(1/(z - exp(2*T)) - 5/(1 - z))/(80*z + z**2)

Note that we didn't have to convert T,p,z, nor exp to Sympy data types. Isn't that great?

EDIT: You can convert a Sympy expression back to a Sage symbolic expression by doing the following:

sage: Z = SR(Y.subs(exp(T*p),z))
sage: Z
(5/(z - 1) + 1/(z - e^(2*T)))*z/(z^2 + 80*z)
sage: Z(z=-1)
-1/79/(e^(2*T) + 1) - 5/158
2011-06-03 13:01:44 +0200 marked best answer Make sage to don't open brackets while solving equation

I'm confused. If I do exactly what you've done above:

sage: reset()
sage: import sympy
sage: var("X T p z")
(X, T, p, z)
sage: 
sage: eq1 = 80*X*e^(T*p) + X*e^(2*T*p) == 5*e^(T*p)/(e^(T*p) - 1) + e^(T*p)/(e^(T*p) - e^(2*T))
sage: Xi = eq1.solve(X)
sage: X = Xi[0].right()
sage: X = X.simplify_full()
sage: X = sympy.simplify(X)
sage: X = X.subs(e^(p*T), z)
sage: X = SR(X)
sage: 
sage: solve(X.denominator(), z)
[z == e^(2*T), z == -80, z == 1]
sage: factor(X.denominator())
(z - 1)*(z + 80)*(z - e^(2*T))

I seem to get the answers you want.