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.Mon, 19 Apr 2021 06:17:20 +0200Why don't log rules work for symbolic values?https://ask.sagemath.org/question/56724/why-dont-log-rules-work-for-symbolic-values/Log rules are working for actual values, but fail for symbolic ones. What am I doing wrong?
var('a b')
c = bool(log(a*b) == log(a) + log(b));print(c)
c = bool(log(5*3) == log(5) + log(3));print(c)
c = log(5*3).n(); print(c)
c = log(5).n() + log(3).n(); print(c)
False
False
2.70805020110221
2.70805020110221cybervigilanteMon, 19 Apr 2021 06:17:20 +0200https://ask.sagemath.org/question/56724/LaTeX Greek names for symbolic variableshttps://ask.sagemath.org/question/56197/latex-greek-names-for-symbolic-variables/Instead of the following:
x,y,z,s1,s2,s3,s4,s5 = var('x,y,z,s_1,s_2,s_3,s_4,s_5')
I want to display `s_1, s_2, s_3, s_4, s_5` as $\sigma_1, \sigma_2, \sigma_3, \sigma_4, \sigma_5$. So for example, when I type `show(s1/s2)` , it would typeset
$$
\frac{\sigma_1}{\sigma_2}.
$$RoadWed, 17 Mar 2021 00:15:49 +0100https://ask.sagemath.org/question/56197/Difference(s) between SR.var and SR.symbol ?https://ask.sagemath.org/question/56041/differences-between-srvar-and-srsymbol/Almost all is in the title.
The online documentation of `SR.symbol` is made only of examples ; it deserves at least a skimpy justification of the existence of `SR.symbol`...
Reading the source code suggests that the actual work of creating a variable is done by `SR.symbol`, and that `SR.var` is a wrapper handling the processing of name(s), domain, LaTeX names, etc...
If so, what would be the point of using `SR.symbol` directly instead of SR.var ?
Comments ?Emmanuel CharpentierSun, 07 Mar 2021 12:27:56 +0100https://ask.sagemath.org/question/56041/prove an identity for any integerhttps://ask.sagemath.org/question/55699/prove-an-identity-for-any-integer/Let $n$ be a positive integer and $m = (m_1, \ldots, m_n)$ an $n$-dimensional vector of real numbers.
Let $g$ be a real number.
I want to prove, for any $n$ and $m$, an equality of the form
$$ \sum_{i=1}^n f_i (m,g) = 0 $$
where the function $f_i$ is a rational function of $m$ and $g$.
Of course it's easy to check this by substituting finite values of $n$, but is there a way in Sage to prove it for any integer?rue82Sat, 13 Feb 2021 21:40:36 +0100https://ask.sagemath.org/question/55699/What is the difference between SR.var() and var()?https://ask.sagemath.org/question/53624/what-is-the-difference-between-srvar-and-var/Is this a bug?
If you type:
sage: SR.var('a')
a
sage: a?
Object `a` not found.
However, this works:
sage: var('a')
a
sage: a?
Type: Expression
String form: a
....
Edgar BrownSun, 27 Sep 2020 20:27:55 +0200https://ask.sagemath.org/question/53624/simplifying a symbolic expressionhttps://ask.sagemath.org/question/51751/simplifying-a-symbolic-expression/Hi I am really tired of not being able to see that sage says the following expression is zero. Instead it returns the same expression. Please help how to make sure that I get 0 for the calculation. Thank you.
q= var('q',domain='positive');
n= var('n',domain='positive');
k= var('k',domain='positive');
x= var('x',domain='positive');
(((q - 1)*x + 1)^n*q^n - ((q^2 - q)*x + q)^n).simplify_full()
((q - 1)*x + 1)^n*q^n - ((q^2 - q)*x + q)^niozenThu, 04 Jun 2020 08:01:15 +0200https://ask.sagemath.org/question/51751/How can I perform matrix operations in a transcendental extension of Q?https://ask.sagemath.org/question/50223/how-can-i-perform-matrix-operations-in-a-transcendental-extension-of-q/ I have three variables $p_w, p_i, p_f$. I want to construct a matrix whose entries are members are rational polynomials in these variables and perform computations with this matrix (ultimately diagonalize it and obtain a general formula for its $n$-th power). But I want to do this computation symbolically, treating the three variables as transcendental elements adjoined to $\mathbb Q$. How an I do this?JackMThu, 12 Mar 2020 14:24:18 +0100https://ask.sagemath.org/question/50223/possible bug in residue functionhttps://ask.sagemath.org/question/49615/possible-bug-in-residue-function/I compute the residue of a function in two ways, using the fact that it has simple poles.
It seems residue method gives the wrong anser (psi) to be compared to correct answer (chi).
br(x) = 1-x
q1,q2,q3,m = var('q1,q2,q3,m')
assume(q1>0,q2>0,q3>0,m>0)
q4 = (q1*q2*q3)^-1
k = 2
rho = [1,q4]
X = [var("x%d" % i) for i in range(k)]
chi1 = prod([ br(X[j]/m)/(br(X[j])*X[j]) for j in range(k)])
chi2 = prod([ prod([ br(q1*q2*X[i]/X[j])*br(q1*q3*X[i]/X[j])*br(q2*q3*X[i]/X[j]) for i in range(k) if i != j]) for j in range(k)])
chi3 = prod([ prod([ br(q1*X[i]/X[j])*br(q2*X[i]/X[j])*br(q3*X[i]/X[j])*br(q4*X[i]/X[j]) for i in range(k) if i != j]) for j in range (k)])
chi = (chi1*chi2/chi3).factor()
psi = chi
for xi,rhoi in zip(X,rho):
psi = psi.residue(xi==rhoi).combine().factor()
chi = (chi*(xi-rhoi)).factor().subs({xi: rhoi})
Now we can print chi and psi and see that they're different.
Is this a bug of residue or series?rue82Tue, 21 Jan 2020 10:57:16 +0100https://ask.sagemath.org/question/49615/Is there any way to inject a variable in the local environment of a function ?https://ask.sagemath.org/question/45887/is-there-any-way-to-inject-a-variable-in-the-local-environment-of-a-function/Inspiration: in [this recent question](https://ask.sagemath.org/question/45870/3d-line-from-equations-to-parametric/), the author looked for a way to act on variables introduced by a function call (this happens in some Maxima or Sympy functions such as `solve` or `desolve`, which need to introduce constants, for example).
It is (relatively) easy to wrap such calls detecting and creating such "new" symbolic variables. It is also easy to inject them in the global namespace. See my answer for a first (somewhat awkward) proposal.
But the case may be thatr these variables are useful in the context of a function wrapping the call to a maxima- or Sympy-derived function, but irrelevant to the global context. Example : the solution to a variational problem might involve calls to `desolve`, in which such constants are created, the used later on to solve for boundary conditions. At this poiont, the created variables are no longer useful.
It would be therefore useful to inject the new variables in the calling function's local namespace. But I do not know how to do this.
Ultimately, I'd like to write a context for such variable-generating calls managing such new variables.
Any suggestions ?Emmanuel CharpentierSat, 23 Mar 2019 18:51:23 +0100https://ask.sagemath.org/question/45887/3D line from equations to parametrichttps://ask.sagemath.org/question/45870/3d-line-from-equations-to-parametric/ In 3D space, given a line defined as the solution of two equations (two planes intersection) like in:
sage: x,y,z=var('x y z')
sage: eqns = [x + y + 2*z - 25 == 0, -x + y - 25 == 0]
how to obtain the direction vector and one (any) line point (parametric form) ?
This solution from solve:
sage: solve( eqns, [x,y,z] )
[[x == -r13, y == -r13 + 25, z == r13]]
has an answer in parametric form, but with parameter "r13" that has a name unpredictable and not usable in next steps.
This solution from solve:
sage: solve( eqns, [y,z] )
[[y == x + 25, z == -x]]
solves the issues of the previous, but it has been assumed that "x" is a valid parameter for the line ( something not true, by example, in case of vertical line: [ x==10 , y==2 ] )
The target is, by example, to obtain a parametric expression of any line that after can be used in a call to "parametric_plot3d".
pasaba por aquiFri, 22 Mar 2019 19:16:55 +0100https://ask.sagemath.org/question/45870/Summation of simbolic variableshttps://ask.sagemath.org/question/45669/summation-of-simbolic-variables/Hi guys!
----------
I have this function on theta:
$R_{x}(\theta) = R_{tx} + \cos \theta \cdot \left( f_{vp} + \sum_{i=1}^{n} \left(p S_i \sin^2 \alpha_i \right) \right) - \sin \theta \cdot \frac{1}{2} \sum_{i=1}^{n} \left(p S_i \sin 2\alpha_i \right)$
----------
Since I cannot define an n-dimensional vector, I reduced n to 5, and wrote the following code down in SAGE:
var('alpha1, alpha2, alpha3, alpha4, alpha5'); # some angles
var('area1, area2, area3, area4, area5'); # some areas
var('Rtx, Rty'); # components of some force
var('fvp'); # modulus of yet another force
var('pv'); # wind pressure
var('theta'); # wind direction
var('i'); # variable to iterate over the angles and areas
# this vector contains all the angles
alpha = vector([alpha1, alpha2, alpha3, alpha4, alpha5]);
# this vector contains all the areas
area = vector([area1, area2, area3, area4, area5]);
Upto this point everything seems to go fine.
Then I try to define my function like this:
# The function I am trying to define, depending on the wind direction
Rx(theta) = Rtx + cos(theta) * (fvp + sum(pv * area[i] * sin(alpha[i])^2, i, 1, 5)) - sin(theta) * 1/2 * sum(area[i] * sin(2*alpha[i])^2, i, 1, 5)
And sage complains:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-4889d5aee183> in <module>()
----> 1 __tmp__=var("theta"); Rx = symbolic_expression(Rtx + cos(theta) * (fvp + sum(pv * area[i] * sin(alpha[i])**Integer(2), i, Integer(1), Integer(5))) - sin(theta) * Integer(1)/Integer(2) * sum(area[i] * sin(Integer(2)*alpha[i])**Integer(2), i, Integer(1), Integer(5))).function(theta)
sage/modules/free_module_element.pyx in sage.modules.free_module_element.FreeModuleElement.__getitem__ (/build/sagemath-x4mQwo/sagemath-7.4/sage/src/build/cythonized/sage/modules/free_module_element.c:12935)()
sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.__index__ (/build/sagemath-x4mQwo/sagemath-7.4/sage/src/build/cythonized/sage/symbolic/expression.cpp:31916)()
sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._integer_ (/build/sagemath-x4mQwo/sagemath-7.4/sage/src/build/cythonized/sage/symbolic/expression.cpp:8623)()
TypeError: unable to convert i to an integer
Any ideas on what may be happening? And, Is there a way to make it work?
Apparently, my question is similar to: Symbolic function that sums over variable sequence (sorry: my karma is insufficient to post links).
Still, it is different in that I have two vectors of variables and need to define a computation using variables from both vectors. And I was trying to get it done in a different way.
Thank you for your time.
==============
EDIT:
This made the trick:
alpha = function("alpha")(i);
area = function("area")(i);
Rx=function("Rx")(theta);
sum1(i) = pv * area(i) * sin(alpha(i)^2)
sum2(i) = area(i) * sin(2*alpha(i))/2
Rx(theta) = Rtx + cos(theta) * (fvp + sum(sum1(i), i, 1, n)) - sin(theta) * sum(sum2(i), i, 1, n)
Thanks to @emmanuel-charpentierclonTue, 05 Mar 2019 16:46:13 +0100https://ask.sagemath.org/question/45669/Eigenvalues over symbolic ringhttps://ask.sagemath.org/question/45567/eigenvalues-over-symbolic-ring/I am trying to compute the eigenvalues of a 16x16 matrix whose eigenvalues are multivariate polynomials in 4 variables of degree at most 3 and integer coefficients. When I try to do so using the Symbolic Ring SR my machine quickly runs out of memory (~15GB available I believe).
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 am using sage 8.1 (and I could try to upgrade if that is the issue here). The example I am struggling with is included at the end of this question (I did not write this by hand, but I don't think that it is relevant how the matrix was generated. One should be able to copy-and-paste this into Sage)
I tried to change the ring to the fraction field of a Multivariate Polynomial Ring over Rational Field, and this allows to quickly compute the characteristic polynomial and its roots, without killing my machine. Unfortunately though some of the eigenvalues are not rational functions, so they do not show up. This is what I did
R = QQ['a,b,c,d']
N = matrix(R, 16, 16, M)
N.change_ring(R.fraction_field()).characteristic_polynomial().roots()
Mathematica on the same machine is able to compute the eigenvalues symbolically (quite quickly actually), and I can solve a similar problem in Sage if I only use 2 variables. Am I missing something, or is simply the algorithm used by Sage not efficient enough for 16x16 matrices in 4 variables?
----------
a,b,c,d = var('a','b','c','d', domain='positive')
M = matrix(16,16,[
(3*c^2*d + 6*c + 1, 0, 0, (a - b)*c*d + a - b, 0, (a - b)*c*d + a - b, (a - b)*c*d + a - b, 0, 0, (a - b)*c*d + a - b, (a - b)*c*d + a - b, 0, (a - b)*c*d + a - b, 0, 0, 3*(a - b)^2*d),
(0, -3*c^2*d + 1, (a + b)*c*d + a + b, 0, (a + b)*c*d + a + b, 0, 0, -(a - b)*c*d + a - b, (a + b)*c*d + a + b, 0, 0, -(a - b)*c*d + a - b, 0, -(a - b)*c*d + a - b, 3*(a + b)*(a - b)*d, 0),
(0, (a + b)*c*d + a + b, -3*c^2*d + 1, 0, (a + b)*c*d + a + b, 0, 0, -(a - b)*c*d + a - b, (a + b)*c*d + a + b, 0, 0, -(a - b)*c*d + a - b, 0, 3*(a + b)*(a - b)*d, -(a - b)*c*d + a - b, 0),
((a - b)*c*d + a - b, 0, 0, 3*c^2*d - 2*c + 1, 0, -(a + b)*c*d + a + b, -(a + b)*c*d + a + b, 0, 0, -(a + b)*c*d + a + b, -(a + b)*c*d + a + b, 0, (2*(a + b)^2 + (a - b)^2)*d, 0, 0, (a - b)*c*d + a - b),
(0, (a + b)*c*d + a + b, (a + b)*c*d + a + b, 0, -3*c^2*d + 1, 0, 0, -(a - b)*c*d + a - b, (a + b)*c*d + a + b, 0, 0, 3*(a + b)*(a - b)*d, 0, -(a - b)*c*d + a - b, -(a - b)*c*d + a - b, 0),
((a - b)*c*d + a - b, 0, 0, -(a + b)*c*d + a + b, 0, 3*c^2*d - 2*c + 1, -(a + b)*c*d + a + b, 0, 0, -(a + b)*c*d + a + b, (2*(a + b)^2 + (a - b)^2)*d, 0, -(a + b)*c*d + a + b, 0, 0, (a - b)*c*d + a - b),
((a - b)*c*d + a - b, 0, 0, -(a + b)*c*d + a + b, 0, -(a + b)*c*d + a + b, 3*c^2*d - 2*c + 1, 0, 0, (2*(a + b)^2 + (a - b)^2)*d, -(a + b)*c*d + a + b, 0, -(a + b)*c*d + a + b, 0, 0, (a - b)*c*d + a - b),
(0, -(a - b)*c*d + a - b, -(a - b)*c*d + a - b, 0, -(a - b)*c*d + a - b, 0, 0, -3*c^2*d + 1, 3*(a + b)*(a - b)*d, 0, 0, (a + b)*c*d + a + b, 0, (a + b)*c*d + a + b, (a + b)*c*d + a + b, 0),
(0, (a + b)*c*d + a + b, (a + b)*c*d + a + b, 0, (a + b)*c*d + a + b, 0, 0, 3*(a + b)*(a - b)*d, -3*c^2*d + 1, 0, 0, -(a - b)*c*d + a - b, 0, -(a - b)*c*d + a - b, -(a - b)*c*d + a - b, 0),
((a - b)*c*d + a - b, 0, 0, -(a + b)*c*d + a + b, 0, -(a + b)*c*d + a + b, (2*(a + b)^2 + (a - b)^2)*d, 0, 0, 3*c^2*d - 2*c + 1, -(a + b)*c*d + a + b, 0, -(a + b)*c*d + a + b, 0, 0, (a - b)*c*d + a - b),
((a - b)*c*d + a - b, 0, 0, -(a + b)*c*d + a + b, 0, (2*(a + b)^2 + (a - b)^2)*d, -(a + b)*c*d + a + b, 0, 0, -(a + b)*c*d + a + b, 3*c^2*d - 2*c + 1, 0, -(a + b)*c*d + a + b, 0, 0, (a - b)*c*d + a - b),
(0, -(a - b)*c*d + a - b, -(a - b)*c*d + a - b, 0, 3*(a + b)*(a - b)*d, 0, 0, (a + b)*c*d + a + b, -(a - b)*c*d + a - b, 0, 0, -3*c^2*d + 1, 0, (a + b)*c*d + a + b, (a + b)*c*d + a + b, 0),
((a - b)*c*d + a - b, 0, 0, (2*(a + b)^2 + (a - b)^2)*d, 0, -(a + b)*c*d + a + b, -(a + b)*c*d + a + b, 0, 0, -(a + b)*c*d + a + b, -(a + b)*c*d + a + b, 0, 3*c^2*d - 2*c + 1, 0, 0, (a - b)*c*d + a - b),
(0, -(a - b)*c*d + a - b, 3*(a + b)*(a - b)*d, 0, -(a - b)*c*d + a - b, 0, 0, (a + b)*c*d + a + b, -(a - b)*c*d + a - b, 0, 0, (a + b)*c*d + a + b, 0, -3*c^2*d + 1, (a + b)*c*d + a + b, 0),
(0, 3*(a + b)*(a - b)*d, -(a - b)*c*d + a - b, 0, -(a - b)*c*d + a - b, 0, 0, (a + b)*c*d + a + b, -(a - b)*c*d + a - b, 0, 0, (a + b)*c*d + a + b, 0, (a + b)*c*d + a + b, -3*c^2*d + 1, 0),
(3*(a - b)^2*d, 0, 0, (a - b)*c*d + a - b, 0, (a - b)*c*d + a - b, (a - b)*c*d + a - b, 0, 0, (a - b)*c*d + a - b, (a - b)*c*d + a - b, 0, (a - b)*c*d + a - b, 0, 0, 3*c^2*d + 6*c + 1)]
)angeloluciaThu, 28 Feb 2019 01:50:15 +0100https://ask.sagemath.org/question/45567/Factorize characteristic polynomial in SR base ringhttps://ask.sagemath.org/question/45249/factorize-characteristic-polynomial-in-sr-base-ring/ I am total newbie to SAGE so this question might be trivial. How can I factorize the characteristic polynomial obtained by a symbolic matrix in SAGE 8.6? Is there a workaround the fact that `factor()` is not defined on the base ring `SR` which is the one inherited from the symbolic matrix?
For example I have in a SAGE/Jupyter notebook something like:
a,b,c = var('a','b','c')
M = Matrix(SR,3,3)
M[0] = [a, -b, 0]
M[1] = [c, a+b, 0]
M[2] = [0, 0, 1]
e = M.eigenvalues()
f = M.charpoly()
factor(f)
The last instruction raises a `NotImplementedError` as expected from the fact that `factor` is not defined on `SR`...
In my real problem I am computing characteristic polynomials of large (8x8) symbolic matrices and I would like to get at glance all the factors, so as to quickly isolate negative real roots and instead easily discuss conditions for existence and sign of symbolic ones.maurizioThu, 31 Jan 2019 18:26:46 +0100https://ask.sagemath.org/question/45249/Roots of multivariable polynomials with respect to one variable?https://ask.sagemath.org/question/44686/roots-of-multivariable-polynomials-with-respect-to-one-variable/This question was previously titled "Finding residues of a huge multivariable rational function."
From my understanding, when computing with huge rational functions, we shouldn't use symbolic variables. However, I don't see how to find roots and residues without symbolic variables. Here is a small scale example of the issue. I have a rational function that looks like below:
$f(u_1,x_1,u_2,x_2,u_3,x_3) = \frac{1}{{\left(u_{1} u_{2} u_{3} - x_{1} x_{2} x_{3}\right)} {\left(u_{1} u_{2} u_{3} - 1\right)} {\left(u_{1} u_{2} - x_{1} x_{2}\right)} {\left(u_{1} u_{2} - 1\right)} {\left(u_{1} - x_{1}\right)} {\left(u_{1} - 1\right)}}$
First I want to solve for $u_1$ in the denominator and find those roots (poles) that have $x_1$ as below.
Then I will loop through the roots and compute the residue of $f$ w.r.t. $u_1$ at those poles.
u1,u2,u3,x1,x2,x3 = var('u1,u2,u3,x1,x2,x3') #symbolic variables
f=1/((u1*u2*u3 - x1*x2*x3)*(u1*u2*u3 - 1)*(u1*u2 - x1*x2)*(u1*u2 - 1)*(u1 - x1)*(u1 - 1))
fden=f.denominator() #denominator of f
list1=fden.roots(u1) #poles of u1
[root for (root, multiplicity) in list1] #list of roots
The output is
[x1*x2*x3/(u2*u3), x1*x2/u2, x1, 1/(u2*u3), 1/u2, 1]
Then we choose those roots that have $x1$
poles1 = [x1*x2*x3/(u2*u3), x1*x2/u2, x1] #choose those that have x1
Finally, we find the residue of $f$ w.r.t $u1$ of the rational function at the poles containing $x1.$
ans1=0
for ff in poles1:
tmp=f.residue(u1==ff)
ans1+=tmp #ans1 is the residue of f w.r.t u1 at all the poles containing x1
ans1
The output is then
1/((u2*u3*x1 - x1*x2*x3)*(u2*u3*x1 - 1)*(u2*x1 - x1*x2)*(u2*x1 - 1)*(x1 - 1)) - 1/((u3*x1*x2 - x1*x2*x3)*(u3*x1*x2 - 1)* (x1*x2 - 1)*u2*(x1 - x1*x2/u2)*(x1*x2/u2 - 1)) + 1/((x1*x2*x3 - 1)*(x1*x2 - x1*x2*x3/u3)*(x1*x2*x3/u3 - 1)*u2*u3*(x1 x1*x2*x3/(u2*u3))*(x1*x2*x3/(u2*u3) - 1))
Then I replace $f$ with $ans1$ to continue to do the same process w.r.t $u2$ and poles containing $x2$ and finally w.r.t $u3$ and poles containing $x3.$ However, this consumes about 800GB of memory on an HPC when I feed it a larger rational function.
Is there a way to find
1. roots of multivariable polynomials with respect to one variable?
2. residue of a rational function avoiding symbolic variables?
Both .roots() and .residue() are not defined for rational functions that are not defined in terms of symbolic variables.HoldenSun, 16 Dec 2018 23:32:23 +0100https://ask.sagemath.org/question/44686/Function of symbolic array elementshttps://ask.sagemath.org/question/43684/function-of-symbolic-array-elements/I want to create a function like this:
def f(A,B):
return [A[1]*B[1],A[0],B[2]]
However, the thing that the function is supposed to return is calculated in an earlier part of the program. Since Sagemath has a problem with symbolic indices, I have previously defined A and B as follows:
Nf=5
B =[0 for j in range(Nf+1)]
A =[0 for j in range(Nf+1)]
for j in range(Nf+1):
A[j]=var('a_'+str(j))
B[j]=var('b_'+str(j))
The thing that the function should return is calculated in another part of the program. Suppose that it is something like this (evaluated from a separate subroutine):
temp=[a_1*b_1, a_0, b_2]
So my question is: how do I turn this `temp` into a function similar to `f`, and the second question: the matrix element references are replaced by variable names. Even if I define a function for `temp` as it is, I will have to define a huge number of input variables `f(a_1, b_1, a_0, b_2, ...)` for the function whereas if I could just replace the variables `a_1` with `A[1]`, etc., this would have enabled me to use `f(A,B)` making the function definition so much more compact. How can I achieve this?DanialBaghSun, 16 Sep 2018 18:04:35 +0200https://ask.sagemath.org/question/43684/Is there a way to specify the dependent variable in eulers_method?https://ask.sagemath.org/question/41727/is-there-a-way-to-specify-the-dependent-variable-in-eulers_method/Consider
sage: u,v = PolynomialRing(QQ,2, "uv").gens()
sage: eulers_method(2*u + v, 1, 5, 0.2, 4)
On the face of it it's ambiguous whether this is solving du/dv = 2\*u + v with u(v=1) = 5 or if it's doing dv/du = 2\*u + v with v(u=1)=5. In practice it solves the latter, but how is that determined?
It appears to hinge on the order of u and v on the LHS of the first line but I can't find any mention of this in the documentation.cretinsgaccountFri, 23 Mar 2018 08:19:15 +0100https://ask.sagemath.org/question/41727/Mathematica misinterprets some underscored symbolic variableshttps://ask.sagemath.org/question/41666/mathematica-misinterprets-some-underscored-symbolic-variables/Following examples show that the interface between sage and Mathematica misinterprets symbolic variables if they are underscored with numbers:
sage: h_20,h_10,h_2,h_3,h20,h10,h_ij,h_kl=var("h_20,h_10,h_2,h_3,h20,h10,h_ij,h_kl");
sage: mexpr=mathematica((h_20+h_10)^3);
sage: print(mexpr);
3
27000 (h_)
sage: mexpr1=mathematica((h20+h10)^3);
sage: print(mexpr1);
3
(h10 + h20)
sage: mexpr2=mathematica((h_2+h_3)^3);
sage: print(mexpr2);
3
125 (h_)
sage: mexpr3=mathematica((h_ij+h_kl)^3);
sage: print(mexpr3);
3
((h_ij) + (h_kl))
I use sage-8.1 and Mathematica 11.2.0 at Linux OpenSUSE Leap v42.3. In this forum I haven't found any other comment regarding this funny behaviour.bekalphWed, 21 Mar 2018 08:25:24 +0100https://ask.sagemath.org/question/41666/