ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 31 Oct 2019 09:24:28 +0100How to solve this algebraic equation by SageMath (rather than by hand)https://ask.sagemath.org/question/48566/how-to-solve-this-algebraic-equation-by-sagemath-rather-than-by-hand/$$u = \frac{\sqrt{a^2+(r+t)^2}-\sqrt{a^2+(r-t)^2}}{2r}$$
How does one solve for $t$ in terms of all the other variables using SageMath?
Note: The purpose of this problem is not to find the solution per se, since we can solve it easily by hand, but to solve it completely by the machine algebra in SageMath. I am having difficulty coaxing SageMath to do that.
I tried the following SageMath code but failed to find the solution. What is the correct script?
u,r,t,a = var('u','r','t','a')
g = (sqrt(a^2 + (r+t)^2) - sqrt(a^2 + (r-t)^2))/(2*r)
ae = (g==u)
view(solve(ae,t))
The output is:
sqrt(a^2 + r^2 + 2*r*t + t^2) == 2*r*u + sqrt(a^2 + r^2 - 2*r*t + t^2)
However, this is not the desired solution.HansThu, 31 Oct 2019 09:24:28 +0100https://ask.sagemath.org/question/48566/Characteristic polynomial wont be used in solvehttps://ask.sagemath.org/question/39746/characteristic-polynomial-wont-be-used-in-solve/ When I try to find roots in a characteristic polynomial it gives me errors:
sage: #Diagonalmatrix
....:
....:
....: A=matrix([[1,-1,2],
....: [-1,1,2],
....: [2,2,-2]])
....: var('x')
....: poly=A.characteristic_polynomial()
....: eq1=solve(poly==0,x)
....:
x
--------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-86-fee7a7de2ea1> in <module>()
7 var('x')
8 poly=A.characteristic_polynomial()
----> 9 eq1=solve(poly==Integer(0),x)
/usr/lib/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
816
817 if not isinstance(f, (list, tuple)):
--> 818 raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")
819
820 if len(f)==1:
TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.
sage:
What can I do in order to use the polynomial in an equation I wish to solve?PoetastropheThu, 23 Nov 2017 18:18:11 +0100https://ask.sagemath.org/question/39746/how to get simplified result of solving equationhttps://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/Hi there!
In a linear algebra assignment I have the following equation I need to find a solution for:
`-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3)==0`. I know the result is pi/3.
Now, when I use solve, `solve(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3)==0, t)`. I get:
[sin(t) == -1/6*sqrt(3)*(sqrt(cos(t)^2+6)-cos(t), sin(t) == 1/6*sqrt(3)*sqrt(cos(t)^2+6)+cos(t))].
How do I use the solve function to get the more simplified result?
NB: I have also tried to use `find_root` and different simplify functions, but also without any luck. I am new to sage, so it is quite possible that I don't know a specification to the solve function which I should use.
Thank you in advance!
Sincerly SimonismonMon, 17 Aug 2015 19:38:14 +0200https://ask.sagemath.org/question/28853/Problems with Solve?https://ask.sagemath.org/question/10005/problems-with-solve/`
running in the notebook ( Sage 5.1 )
--- this input ---
var( "Z", "A" )
equ = 1.*Z/A^(1/3) + 2.*(A - 2*Z)/A == 0
print equ
sol = solve( equ, A )
print sol
--- gives ---
Z/A^(1/3) - 2*(-A + 2.00000000000000*Z)/A == 0
[
A == -2*(A^(4/3) - 2*A^(1/3)*Z)/Z
]
--- my problem ---
if I have solved for A, why is A still on the RHS, I expected
only Z as a variable.
This problems is similar to the real one I am having with
a much more complicated formula.
`russ_henselTue, 09 Apr 2013 15:08:39 +0200https://ask.sagemath.org/question/10005/Trigonometric Equation Solving: Not Terminatinghttps://ask.sagemath.org/question/9898/trigonometric-equation-solving-not-terminating/## The Background
I want to write a script which is able to do the following:
- **INPUT:** **`x`** - A list of triangle items. These items are considered as given.
- **INPUT:** **`y`** - A list of triangle items. We want to know the abstract formulas of these items.
- **OUTPUT:** **`z`** - A list of formulas to calculate the items from `y`
For example:
- **INPUT:** **`x`** - `[alpha, beta]` (considered as given)
- **INPUT:** **`y`** - `[gamma]` (we want to know the formula of `gamma`)
- **OUTPUT:** **`z`** - `[gamma == pi - alpha - beta]`
I want to do that using `sage`'s `solve()`.
## My Problem:
This is a simplified script. It is just able to output formulas for `alpha`, `beta` and `gamma` when `a`, `b` and `c` are considered as given:
rings = RR[('a', 'b', 'c')].gens()[:3] # considered as given
x = dict([(str(rings_), rings_) for rings_ in rings])
varbs = SR.var(['alpha', 'beta', 'gamma']) # looking for `alpha`, `beta` and `gamma`
x.update([(str(varbs_), varbs_) for varbs_ in varbs])
print solve([
#x['a']**2 == x['b']**2 + x['c']**2 - 2*x['b']*x['c']*cos(x['alpha']),
#x['b']**2 == x['a']**2 + x['c']**2 - 2*x['a']*x['c']*cos(x['beta']),
#x['c']**2 == x['a']**2 + x['b']**2 - 2*x['a']*x['b']*cos(x['gamma']),
x['alpha'] == arccos((x['a']**2 - x['b']**2 - x['c']**2) / 2*x['b']*x['c']),
x['beta'] == arccos((x['b']**2 - x['a']**2 - x['c']**2) / 2*x['a']*x['c']),
x['gamma'] == arccos((x['c']**2 - x['a']**2 - x['b']**2) / 2*x['a']*x['b']),
#pi == x['alpha'] + x['beta'] + x['gamma'],
], [
x['alpha'],
x['beta'],
x['gamma'],
])
This script is working correctly and outputs:
[
[alpha == pi - arccos(-0.5*a^2*b*c + 0.5*b^3*c + 0.5*b*c^3), beta == pi - arccos(0.5*a^3*c - 0.5*a*b^2*c + 0.5*a*c^3), gamma == arccos(-0.5*a^3*b - 0.5*a*b^3 + 0.5*a*b*c^2)]
]
I wanted to extend `solve()`'s knowledge base in order to be able to solve more complicated problems later on. But when I tried to uncomment the `#` lines and ran the script again, `solve()` didn't terminate any more.
## My Question:
* Why doesn't `solve()` terminate when I uncomment the `#` lines?
* How can I get `sage` to terminate? Or: How can I work around this problem?
Thanks - if anything's unclear, please leave a comment concerning that.fdj815Sun, 10 Mar 2013 09:56:09 +0100https://ask.sagemath.org/question/9898/intermediate algebrahttps://ask.sagemath.org/question/8604/intermediate-algebra/solve 3+?z-13 = ?z+2jonesbettyMon, 02 Jan 2012 11:55:36 +0100https://ask.sagemath.org/question/8604/Using numerical solution from system of equationshttps://ask.sagemath.org/question/7948/using-numerical-solution-from-system-of-equations/I want to take the numerical solution of a variable in a system of equations and use it later in the program. But all I can get is the symbolic definition. Here's a simplified example of the problem.
sage: var('x y z')
sage: eq1 = x + y + z == 6
sage: eq2 = 2*x - y + 2*z == 6
sage: eq3 = 3*x + 3*y - z == 6
sage: solve([eq1, eq2, eq3], x, y, z)
sage: v = x
sage: print v
Output:
[
[x == 1, y == 2, z == 3]
]
x
I assume the syntax for solving the system is correct because I get the right answers but I want v = 1, not v = x.
Thanks.
RACWed, 16 Feb 2011 13:35:22 +0100https://ask.sagemath.org/question/7948/Limitation of solve?https://ask.sagemath.org/question/7796/limitation-of-solve/I am using (or trying to use) the solve function to solve a system of 10 nonlinear equations in 10 variables. However, solve simply outputs the 10 equations after some time computing. Is this running into a limit of the solve function, or is there some other way to economize my input to make it more solve-function-friendly? Would it help to know the algorithm which solve uses?
EDIT: At a suggestion from niles, I am putting up the equations that I am solving. I have a version that is simplified, but it is not a problem to solve. In the equations below it is legal to set any combination of the variables equal to zero, and the resulting solutions will be a subset of the solution set of the full collection of equations.
var('a b c d e f g h i j')
eq1 = a == a^2 + b*a + 2*a*c + 2*a*d + 2*a*e + 2*a*f + g*a + h*a + i*a + j*a + b^2 + d*b + g*b + b*c + d*c + g*c
eq2 = b == c*b + 2*b*e + h*b + b*d + c*d
eq3 = c == c^2 + 2*e*c + h*c + b*f + c*f
eq4 = d == f*b + d^2 + 2*e*d + f*d
eq5 = e == e^2
eq6 = f == f*c + i*c + 2*f*e + d*f + f^2
eq7 = g == i*b + j*b + 2*g*d + 2*h*d + i*d + j*d + 2*g*e + a*g + b*g + c*g + f*g + g^2 + 2*h*g + i*g + j*g + a*h + b*h + a*i
eq8 = h == 2*h*e + c*h + h^2 + b*i + c*i
eq9 = i == 2*i*e + f*h + i*h + d*i + f*i
eq10 = j == 2*j*e + g*f + h*f + j*f + 2*j*h + g*i + h*i + i^2 + j*i + a*j + b*j + c*j + d*j + f*j + g*j + i*j + j^2
For those who are curious, the simplified version is this set of equations with a, b, c, g, h, i, j == 0.
If there is anything more that anybody would like to know about these equations or where I am getting them from, just say so in a comment.Eric A BunchTue, 07 Dec 2010 23:21:47 +0100https://ask.sagemath.org/question/7796/