ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 06 Jun 2019 17:38:46 -0500Problems and errors in solve an equationhttp://ask.sagemath.org/question/46842/problems-and-errors-in-solve-an-equation/ Hi everybody, I want to solve this non linear equation: omega_nf_eq = 0.
m,J_d,J_p,y,Y,omega,Omega,phi,Phi,z,Z,theta,Theta,k_yy,k_zz,k_phiphi,k_yphi,k_ztheta,k_thetatheta,plane_xy1,plane_xy2,plane_xz1,plane_xz2 = var('m J_d J_p y Y omega Omega phi Phi z Z theta Theta k_yy k_zz k_phiphi k_yphi k_ztheta k_thetatheta plane_xy1 plane_xy2 plane_xz1 plane_xz2')
t = var('t')
omega_nf_eq = -J_d^2*k_yy*k_zz*omega^4 + 0.382*J_d^2*k_yy*omega^6 + 0.382*J_d^2*k_zz*omega^6 - 0.145924*J_d^2*omega^8 + J_d*k_phiphi*k_yy*k_zz*omega^2 - 0.382*J_d*k_phiphi*k_yy*omega^4 - 0.382*J_d*k_phiphi*k_zz*omega^4 + 0.145924*J_d*k_phiphi*omega^6 + J_d*k_thetatheta*k_yy*k_zz*omega^2 - 0.382*J_d*k_thetatheta*k_yy*omega^4 - 0.382*J_d*k_thetatheta*k_zz*omega^4 + 0.145924*J_d*k_thetatheta*omega^6 - J_d*k_yphi^2*k_zz*omega^2 + 0.382*J_d*k_yphi^2*omega^4 - J_d*k_yy*k_ztheta^2*omega^2 + 0.382*J_d*k_ztheta^2*omega^4 + J_p^2*Omega^2*k_yy*k_zz*omega^2 - 0.382*J_p^2*Omega^2*k_yy*omega^4 - 0.382*J_p^2*Omega^2*k_zz*omega^4 + 0.145924*J_p^2*Omega^2*omega^6 - k_phiphi*k_thetatheta*k_yy*k_zz + 0.382*k_phiphi*k_thetatheta*k_yy*omega^2 + 0.382*k_phiphi*k_thetatheta*k_zz*omega^2 - 0.145924*k_phiphi*k_thetatheta*omega^4 + k_phiphi*k_yy*k_ztheta^2 - 0.382*k_phiphi*k_ztheta^2*omega^2 + k_thetatheta*k_yphi^2*k_zz - 0.382*k_thetatheta*k_yphi^2*omega^2 - k_yphi^2*k_ztheta^2 == 0
solve(omega_nf_eq, omega)
But the Sage is unable to find the solution, damn it.
I get this error message:
TypeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the memory limits before executing the program again.
I know the equation is big but i didn't expected such many problems.
I've already tried sympy but nothing.
Is there another way?
pull_over93Thu, 06 Jun 2019 17:38:46 -0500http://ask.sagemath.org/question/46842/problem: sage is not able to find solution to an equation.http://ask.sagemath.org/question/46841/problem-sage-is-not-able-to-find-solution-to-an-equation/ Hi everybody, I want to solve this non linear equation: omega_nf_eq = 0.
m,J_d,J_p,y,Y,omega,Omega,phi,Phi,z,Z,theta,Theta,k_yy,k_zz,k_phiphi,k_yphi,k_ztheta,k_thetatheta,plane_xy1,plane_xy2,plane_xz1,plane_xz2 = var('m J_d J_p y Y omega Omega phi Phi z Z theta Theta k_yy k_zz k_phiphi k_yphi k_ztheta k_thetatheta plane_xy1 plane_xy2 plane_xz1 plane_xz2')
t = var('t')
omega_nf_eq = -J_d^2*k_yy*k_zz*omega^4 + 0.382*J_d^2*k_yy*omega^6 + 0.382*J_d^2*k_zz*omega^6 - 0.145924*J_d^2*omega^8 + J_d*k_phiphi*k_yy*k_zz*omega^2 - 0.382*J_d*k_phiphi*k_yy*omega^4 - 0.382*J_d*k_phiphi*k_zz*omega^4 + 0.145924*J_d*k_phiphi*omega^6 + J_d*k_thetatheta*k_yy*k_zz*omega^2 - 0.382*J_d*k_thetatheta*k_yy*omega^4 - 0.382*J_d*k_thetatheta*k_zz*omega^4 + 0.145924*J_d*k_thetatheta*omega^6 - J_d*k_yphi^2*k_zz*omega^2 + 0.382*J_d*k_yphi^2*omega^4 - J_d*k_yy*k_ztheta^2*omega^2 + 0.382*J_d*k_ztheta^2*omega^4 + J_p^2*Omega^2*k_yy*k_zz*omega^2 - 0.382*J_p^2*Omega^2*k_yy*omega^4 - 0.382*J_p^2*Omega^2*k_zz*omega^4 + 0.145924*J_p^2*Omega^2*omega^6 - k_phiphi*k_thetatheta*k_yy*k_zz + 0.382*k_phiphi*k_thetatheta*k_yy*omega^2 + 0.382*k_phiphi*k_thetatheta*k_zz*omega^2 - 0.145924*k_phiphi*k_thetatheta*omega^4 + k_phiphi*k_yy*k_ztheta^2 - 0.382*k_phiphi*k_ztheta^2*omega^2 + k_thetatheta*k_yphi^2*k_zz - 0.382*k_thetatheta*k_yphi^2*omega^2 - k_yphi^2*k_ztheta^2 == 0
solve(omega_nf_eq, omega)
But the Sage is unable to find the solution, damn it.
I get this error message:
TypeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the memory limits before executing the program again.
I know the equation is big but i didn't expected such many problems.
I've already tried sympy but nothing.
Is there another way?
pull_over93Thu, 06 Jun 2019 17:35:14 -0500http://ask.sagemath.org/question/46841/AttributeError: 'dict' object has no attribute 'solve'http://ask.sagemath.org/question/46729/attributeerror-dict-object-has-no-attribute-solve/How I can fix this error '''AttributeError: 'dict' object has no attribute 'solve'
It appears after I tried to `solve(P)`:
G = I.groebner_basis()
P = {}
ind = 0
for i in range (n):
if (G[i].degree() < num):
ind = ind+1
P[ind] = G[i]
solve(P)MaoriThu, 30 May 2019 16:56:09 -0500http://ask.sagemath.org/question/46729/How to create in Sage system of equations using elements from boolean field?http://ask.sagemath.org/question/46710/how-to-create-in-sage-system-of-equations-using-elements-from-boolean-field/I want to create a field on 8 elements, and then, using this elements make a System of equations like:
nb = 8
varl = [c+ str(p) for c in 'xy' for p in range (nb)]
B = BooleanPolynomialRing(names = varl)
f1 = x1 + x7*x2
f2 = x4*x6*x8 + x7
and then....
But in this case Sage give me an error NameError: name 'x1' is not defined
And in this case:
f1 = x[3] + x[1]*x[2]
f2 = x[4]*x[6]*x[2] + x[7]
error: TypeError: 'sage.symbolic.expression.Expression' object does not support indexing
Is there any way to create them in Sage?MaoriThu, 30 May 2019 04:09:10 -0500http://ask.sagemath.org/question/46710/exponential equation solve problemhttp://ask.sagemath.org/question/45450/exponential-equation-solve-problem/ b=4*3^(2*x-1)==5*4^(x+2)
show(b)
solve(b,x)
The Solution is:
[4^(x + 2) == 4/5*3^(2*x - 1)]
Should the solve alg. solve for x?thethaWed, 13 Feb 2019 08:20:11 -0600http://ask.sagemath.org/question/45450/how to change rhs() of an equation in an equation listhttp://ask.sagemath.org/question/45269/how-to-change-rhs-of-an-equation-in-an-equation-list/ Hi
sorry for this basic question !
var('x y')
eqT=[x==3,y==4]
show(eqT[0].rhs())
((eqT[0]).rhs())=5
I got this mesage:
**File "<ipython-input-55-19bf87f1683d>", line 4
((T[Integer(0)]).rhs())=Integer(5)
SyntaxError: can't assign to function call**ortolljFri, 01 Feb 2019 12:05:44 -0600http://ask.sagemath.org/question/45269/Dividing Boolean Polynomials in Sage.http://ask.sagemath.org/question/45224/dividing-boolean-polynomials-in-sage/ Hi all,
I'm working in a Boolean Polynomial Ring. I have an equation generator. My objective is to divide the highest possible monomial by the leading monomial of my equations.
NUMBER_OF_VARIABLES = 15
B = BooleanPolynomialRing(NUMBER_OF_VARIABLES,'x', order = 'degrevlex')
Each equation that I generate looks something like this.
f = x6*x2*x1 + x6*x5*x4 + x9*x5*x4 + x9*x6*x0 + x10*x2*x1 + x10*x4*x1 + x11*x9*x7 + x11*x10*x0 + x12*x4*x0 + x12*x7*x3 + x12*x9*x0 + x12*x10*x3 + x12*x10*x5 + x13*x7*x0 + x13*x7*x5 + x13*x8*x6 + x13*x10*x9 + x13*x11*x2 + x14*x5*x4 + x14*x11*x5 + x14*x13*x12 + x6*x3 + x7*x2 + x9*x1 + x10*x9 + x14*x8 + x14*x13 + x3 + x7 + x8 + 1
Getting the leading monomial of f:
print f.lm()
>>> x6*x2*x1
Getting the highest possible monomial of my ring (15 variables)
print f.set().vars()
>>> x14*x13*x12*x11*x10*x9*x8*x7*x6*x5*x4*x3*x2*x1*x0
But somehow I get an error when I try to divide them.
f.set().vars()/f.lm()
>>> bad operand type for unary ~: 'sage.rings.polynomial.pbori.BooleanMonomial'
I checked the documentation and nothing seems to work. I have tried all of the methods below and they do not work.
f.set().vars().divide(f.lm())
# http://doc.sagemath.org/html/en/reference/polynomial_rings/sage/rings/polynomial/pbori.html
f.set().vars().reduce(Ideal([f.lm()]))
# https://stackoverflow.com/questions/35233406/multivariate-polynomial-division-in-sage
I'm really at a loss here. I've seen answers whereby the code `q,r = dividend.maxima_methods().divide(divisor)` is used, but this seems like such a simple thing to do. Surely I'm missing something out. Why isn't division working? Multiplication and addition works, so why shouldn't division work?
Stockfish3709Mon, 28 Jan 2019 19:43:21 -0600http://ask.sagemath.org/question/45224/How can I solve the following (linear) differential equation?http://ask.sagemath.org/question/45075/how-can-i-solve-the-following-linear-differential-equation/I want Sage to solve this equation:
$y'''-3y''+y'-5y=0$.
Both
y=function('y')(x)
desolve(diff(y,3)-3*diff(y,2)+diff(y,1)-5*y,y)
and
giac("desolve([y'''-3y''+y'-5y],y)").sage()
result in errors.ThrashWed, 16 Jan 2019 22:27:41 -0600http://ask.sagemath.org/question/45075/Wrong solution/output for differential equationhttp://ask.sagemath.org/question/45046/wrong-solutionoutput-for-differential-equation/As the user rburing advised in the thread
https://ask.sagemath.org/question/44995/combine-plots-with-built-in-maxima-trajectory-in-sage-available/
I'm opening this one now.
When running the following code, one obtains a wrong output:
y=function('y')(x)
desolve(diff(y)==4*y/x+x*sqrt(y),y,ics=[1,1]).factor()
The output is `1/4*x^4*(log(x) - 2)^2` instead of `1/4*x^4*(log(x) + 2)^2`. Mathematica however outputs both (by running `DSolve[{D[y[x], x] == 4*y[x]/x + x*Sqrt[y[x]], y[1] == 1}, y[x], x]`).ThrashMon, 14 Jan 2019 10:54:14 -0600http://ask.sagemath.org/question/45046/Quadratic equation with complex coefficientshttp://ask.sagemath.org/question/44961/quadratic-equation-with-complex-coefficients/How can I solve `x^2 - (1 + I)*x + 6 + 3*I == 0` to get answers `z = 3*I` and `z = 1 - 2*I` ? When I enter
solve(x^2 - (1 + I)*x + 6 + 3*I == 0, x)
I get
[x == -1/2*sqrt(-10*I - 24) + 1/2*I + 1/2, x == 1/2*sqrt(-10*I - 24) + 1/2*I + 1/2]EvgenyMTue, 08 Jan 2019 15:16:03 -0600http://ask.sagemath.org/question/44961/Using SageMath to solve Simultaneous equations in a Boolean Ringhttp://ask.sagemath.org/question/44856/using-sagemath-to-solve-simultaneous-equations-in-a-boolean-ring/I'm trying to get SageMath to solve a system of equations in a Boolean Ring.
Here is my code.
P.<x,y,z> = BooleanPolynomialRing(3, order= 'lex')
equations = [1+x+y+z, x+y, x*y+1, x+y]
zeros = [0,0,0,0]
I know that there are equation solvers for Sage, but I do not know how to have the answers of the equation be only in the Boolean Ring (ie. only 1 or 0). Obviously I can solve the equation by hand, but that's not the point here. Is there a way to have SageMath only output 0 or 1 as the answer?
Stockfish3709Thu, 03 Jan 2019 02:20:02 -0600http://ask.sagemath.org/question/44856/Solving linear congruencehttp://ask.sagemath.org/question/44618/solving-linear-congruence/ Is there a simple way to solve a linear congruence modulo an integer with large prime factors in Sage? `solve_mod` function cannot handle such large moduli apparently.kdr01Sun, 09 Dec 2018 13:28:31 -0600http://ask.sagemath.org/question/44618/Missing root when solving equation in sageMathhttp://ask.sagemath.org/question/43052/missing-root-when-solving-equation-in-sagemath/When I solve equation using sageMath, it missed one root.
sage: solve([4/5*(x - 1)^2/x^(1/5) + 2*(x - 1)*x^(4/5)==0] ,x)
[x == (2/7), x == 1]
The equation has 3 roots. It misses x==0.
What is the reason?Sam TanTue, 17 Jul 2018 18:58:17 -0500http://ask.sagemath.org/question/43052/How to get all (numerical) solutions of an equation?http://ask.sagemath.org/question/7634/how-to-get-all-numerical-solutions-of-an-equation/Mathematica's NSolve can produce all roots of a polynomial equation, like this:
sage: mathematica('NSolve[9*x^6 + 4*x^4 + 3*x^3 + x - 17 == 0, x]')
{{x -> -1.1030150726298147},
{x -> -0.49110203599909275 - 0.9883314953720708*I},
{x -> -0.49110203599909275 + 0.9883314953720708*I},
{x -> 0.5426095723140001 - 1.0543115206871092*I},
{x -> 0.5426095723140001 + 1.0543115206871092*I}, {x -> 1.}}
OTOH, Sage's solve gives just one real solution:
sage: solve(9*x^6 + 4*x^4 + 3*x^3 + x - 17 == 0, x)
[x == 1, 0 == 9*x^5 + 9*x^4 + 13*x^3 + 16*x^2 + 16*x + 17]
Is there a simple way to get all solutions?kkumerWed, 25 Aug 2010 04:42:23 -0500http://ask.sagemath.org/question/7634/solving matrix over GF(2)http://ask.sagemath.org/question/41575/solving-matrix-over-gf2/ A = matrix(GF(2), 8, 8, [])
b = vector(GF(2), [0, 1, 1, 0, 1, 0, 1, 1])
y = vector(GF(2), [0, 0, 0, 0, 1, 0, 1, 1])
x = vector(GF(2), [1, 0, 0, 0, 0, 0, 0, 0])
If the matrix $A$ is unkown, we have $Ax+b = y$.
How can we solve the matrix $A$?
omggggggThu, 15 Mar 2018 20:06:28 -0500http://ask.sagemath.org/question/41575/Get the constant value of an equationhttp://ask.sagemath.org/question/39060/get-the-constant-value-of-an-equation/I have the following equation :
(x - 1)^2 - (x - 2)^2 - (y - 1)^2 + y^2 + (z - 3)^2 - (z - 4)^2 == 1.75000000000000
which I factorized to :
2*x + 2*y + 2*z - 51/4
And then I would like to extract the `-51/4` but the `.coefficient()` function doesn't work for constant so I have no idea to get the constant value.BariloSat, 07 Oct 2017 04:20:49 -0500http://ask.sagemath.org/question/39060/Get the coefficient of the constanthttp://ask.sagemath.org/question/39058/get-the-coefficient-of-the-constant/ I have the following equation :
(x - 1)^2 - (x - 2)^2 - (y - 1)^2 + y^2 + (z - 3)^2 - (z - 4)^2 == 1.75000000000000
which I factorized to :
2*x + 2*y + 2*z - 51/4
And then I would like to extract the `-51/4` but the `.coefficient()` doesn't work for constant so I have no idea to get the constant value.BariloSat, 07 Oct 2017 04:19:12 -0500http://ask.sagemath.org/question/39058/Sage says equation isn't true while Mathematica says it ishttp://ask.sagemath.org/question/38795/sage-says-equation-isnt-true-while-mathematica-says-it-is/I have the following equation, of which I know that it is true when ```sigma > 0``` and ```mu > 0```.
eq = mu + 0.5*log(2*pi*sigma^2*e) == log(sqrt(2)*sqrt(pi)*sigma*e^(mu + 0.5))
So I set the constraints ```assume(sigma > 0)``` and ```assume(mu > 0)```. When evaluating it with ```bool(eq)```, Sage says ```False``` while Mathematica says that the equation holds. What am I doing wrong?muxamilianTue, 12 Sep 2017 08:22:24 -0500http://ask.sagemath.org/question/38795/Get the nth term of an equation.rhs() sumhttp://ask.sagemath.org/question/38720/get-the-nth-term-of-an-equationrhs-sum/ Hi
equ0 = term_0 == term_1 + term_2 + term_3
I want to extract term_1 + term_2 to work with.
I have been looking for a long time without success,
I read the whole page:
[link text](http://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/expression.html)
example:
$
{\left| p\left(\rho_{\epsilon} e^{\left(i \, \theta_{\epsilon}\right)} + w\right) \right|}^{2} =
\rho_{0} \rho_{\epsilon}^{m} \rho_{m} e^{\left(i \, m \theta_{\epsilon} - i \, \theta_{0} + i \, \theta_{m}\right)} +
\rho_{0} \rho_{\epsilon}^{m} \rho_{m} e^{\left(-i \, m \theta_{\epsilon} + i \, \theta_{0} - i \, \theta_{m}\right)} + \rho_{\epsilon}^{2 \, m} \rho_{m}^{2} + \rho_{0}^{2}
$ortolljSun, 03 Sep 2017 03:59:01 -0500http://ask.sagemath.org/question/38720/using sage solve for more than 4 variableshttp://ask.sagemath.org/question/38011/using-sage-solve-for-more-than-4-variables/ I just tried to sovle a 82 queation with 82 varibles, and got the following error:
TypeError: solve() takes at most 5 positional arguments (82 given)
I assume that i'm not using it right. I would like an help.
Thanks.SAvaGEMon, 19 Jun 2017 04:01:19 -0500http://ask.sagemath.org/question/38011/Equation with sign functionhttp://ask.sagemath.org/question/37948/equation-with-sign-function/Hi all,
I have the following piece of code
f(x) = 2*unit_step(x)
u = function('u')(x)
eqn = diff(u,x) + u == f(x)
v = desolve(eqn, u,ics=[0,0])
solve(v,x)
which gives me `[x == 0, sgn(x) == -1]` as solutions to the last equation. Could you help me find a way for Sage not to stop at `sgn(x) == -1`?
ThankssokingThu, 15 Jun 2017 02:20:44 -0500http://ask.sagemath.org/question/37948/indicial equationhttp://ask.sagemath.org/question/37861/indicial-equation/Let N be an integer. Let a, b, A_1,...,A_N be constant real numbers. Let g(n) be a real function of integer variable n.
g(n) satisfies the recurrence equation:
(n + 1)*(n + b)*g(n+1) = (n + a)*g(n) + sum(i=1 to N)(A_i * g(n-i))
with g(n)=0 for n<0 . g(0) is obtained through boundary conditions, so it can be considered a given constant.
I need to know the general functional form of the term g(n), as a function of the given constants of the problem: a,b,N,A_1,...,A_N and g(0).
Could you help me? Could I programm in SAGE the code to provide the searched general term g(n)?
Thanks for your attention.
Javier Garciafjgg1549Thu, 08 Jun 2017 12:34:46 -0500http://ask.sagemath.org/question/37861/problem solving equation systemshttp://ask.sagemath.org/question/36786/problem-solving-equation-systems/ var('V1', 'V2')
solve([V1+V2==0.5,7.20 == 5.5 - log(V1/V2,10)], V1, V2)
SageMath do not solve this system but when with Ctrl+C the calculation end and show in terminal the solution.
If I use natural logarithm in the expression Sage solve this system without any problem.eancedegThu, 02 Mar 2017 09:33:42 -0600http://ask.sagemath.org/question/36786/Any way to solve this differential equation?http://ask.sagemath.org/question/36122/any-way-to-solve-this-differential-equation/ sage: x(t)=function('x')(t)
sage: x
t |--> x(t)
sage: g(v,c)=1/sqrt(1-v^2/c^2)
sage: g
(v, c) |--> 1/sqrt(-v^2/c^2 + 1)
sage: var('a')
a
sage: ode = g(diff(x,t))*diff(x,t) == a*t
sage: ode
t |--> diff(x(t), t)/sqrt(-diff(x(t), t)^2/c^2 + 1) == a*t
sage: desolve(ode,x)
Traceback (most recent call last):
...
ValueError: Unable to determine independent variable, please specify.
sage: desolve(ode,[x,t])
Traceback (most recent call last):
...
NotImplementedError: Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.
sage: desolve(ode,[x,t],contrib_ode=True)
Traceback (most recent call last):
...
NotImplementedError: Maxima was unable to solve this ODE.
I can solve it by hand.
Mathematica can solve it. But I would very much prefer to learn to use Sage because it's open source.
It looks like it is Maxima that cannot solve it. But is it possible to make Sage invoke any other open source program than Maxima? Or use some trick in defining the problem that would allow Maxima to solve it?
Thank you.omoplataThu, 29 Dec 2016 13:15:36 -0600http://ask.sagemath.org/question/36122/Numerical real solution of derivativehttp://ask.sagemath.org/question/35374/numerical-real-solution-of-derivative/I would like to know where a function attains its maximum, so I'm trying to solve some
>diff(y,x),x
where y depends on y. I have difficulties with Sage returning equations, complex roots, converting equations, find_maximum_on_interval command etc, and instead of spending another hour trying to figure it out myself, I thought I would try asking here...
Here is a more concrete example:
>f = log(2.02 * x + 1) / 2 + log( -2 * x + 1) / 2
>find_local_maximum(diff(f,x), 0, 1)
What is mysterious for me, is that the above works if instead I have
>f = log(1.01 * x + 1) / 2 + log( -x + 1) / 2domotorpThu, 03 Nov 2016 00:29:02 -0500http://ask.sagemath.org/question/35374/What's this result of equation solving?http://ask.sagemath.org/question/35167/whats-this-result-of-equation-solving/Hi guys
I want to solve an equation that get from determinant of a matrix, but I cannot understand the result! Can anyone help me?
It's my code:
x = var('x')
A = Matrix([[0,1],[1,0]])
A = (I*x*A).exp()
A = A.determinant()
solve(A == 1,x,to_poly_solve ='force')
This is result!!!!!:
[x == 1/2*I*lambert_w(68)]
What is exactly that c68 (it's change every time!) [The result for equation should be pi/2]palidehxSun, 16 Oct 2016 22:46:38 -0500http://ask.sagemath.org/question/35167/How to use SageMath to solve this equation?http://ask.sagemath.org/question/34760/how-to-use-sagemath-to-solve-this-equation/ I am a beginner of SageMath. I want to solve Z in the following equation using SageMath:
(1 + rho * Z)^beta * (1 + 2 * rho * Z)^(1 - beta) < 2^(3 R / 2),
where rho > 0, Z >= 0, beta is in (0,1), and R > 0. I don't know how to do this in SageMath. Could you please teach me? Thank you very much in advance.
Wei-Cheng LiuWed, 07 Sep 2016 04:02:12 -0500http://ask.sagemath.org/question/34760/solving systems of equations returns [] Reduxhttp://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/I searched the wiki and found the "solve always returns []" question. But it doesn't help me. I will admit that I am a complete neophyte with Sagemath and have been playing with version 7.2 on my windows machine.
I was trying to do something very simple: solve a basic Lagrange Multiplier problem, so I defined the following:
- var('x' ,'y' ,'z', 'lam')
- var('F')
- F = x*y*z - lam * (x*y*z-9)
- var('dFx', 'dFy', 'dFz', 'dFlam')
- dFx=diff(F,x)
- dFy=diff(F,y)
- dFz=diff(F,z)
- dFlam=diff(F,lam)
- solve([dFx==0,dFy==0,dFz==0,dFlam==0],x,y,z,lam)
but the **solve** returns []. It should return something like x==3, y==3, z==3, shouldn't it? Is there an alternative way to approach this?
Thanks.
BobM
BobMSat, 27 Aug 2016 03:28:29 -0500http://ask.sagemath.org/question/34608/Unexpected Answer for an Equationhttp://ask.sagemath.org/question/33254/unexpected-answer-for-an-equation/ Hello,
I am trying to calculate the following equation in SAGE.
N = 100.
p = 0.9.
r = (N /(N-1))*(ln(N)-ln(-ln(p))); r
Unfortunately, sage gives this answer **100/99*log(100) + 2.27309831041661** , which is not the expected answer !!
But, when I used google calculator, I got the expected answer, which is **6.92478536697**
Please let me know what is going on.? Thank you. usamrfThu, 28 Apr 2016 13:52:10 -0500http://ask.sagemath.org/question/33254/Not understandable error when solving polynomial equationhttp://ask.sagemath.org/question/33050/not-understandable-error-when-solving-polynomial-equation/Hi all,
when I enter command
solve(symbolic_expression(x^12 - x^11 - 12*x^10 + 11*x^9 + 54*x^8 - 43*x^7 - 113*x^6 + 71*x^5 + 110*x^4 - 46*x^3 - 40*x^2 + 8*x + 1)==0, var(x), to_poly_solve=True)
I get the expected result, but when I enter command
solve(symbolic_expression(x^10 - 10*x^8 + 35*x^6 + x^5 - 50*x^4 - 5*x^3 + 25*x^2 + 5*x - 1), var(x), to_poly_solve=True)
I get the error message
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-203-6108bea90b72> in <module>()
----> 1 solve(symbolic_expression(x**Integer(10) - Integer(10)*x**Integer(8) + Integer(35)*x**Integer(6) + x**Integer(5) - Integer(50)*x**Integer(4) - Integer(5)*x**Integer(3) + Integer(25)*x**Integer(2) + Integer(5)*x - Integer(1)),var(x),to_poly_solve=True)
/usr/local/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages/sage/symbolic/relation.py in solve(f, *args, **kwds)
732 from sage.symbolic.expression import is_Expression
733 if is_Expression(f): # f is a single expression
--> 734 ans = f.solve(*args,**kwds)
735 return ans
736
/usr/local/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.solve (build/cythonized/sage/symbolic/expression.cpp:47061)()
/usr/local/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.solve (build/cythonized/sage/symbolic/expression.cpp:46887)()
TypeError: 'sage.symbolic.expression.Expression' object does not support indexing
What happened here? The error message is totally misleading (no index in the command!) and it is not to understand why the second command fails while the first works fine.
By the way, the polynomial in question has ten simple real roots, so there should be no problem to compute the roots if symbolic evaluation is not possible.
Thanks in advance
Wolfgang
wjansenSun, 10 Apr 2016 11:29:46 -0500http://ask.sagemath.org/question/33050/