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.Sun, 18 Nov 2018 18:21:18 +0100Evaluate from string an equation that has integer divisionhttps://ask.sagemath.org/question/44328/evaluate-from-string-an-equation-that-has-integer-division/ I have the following Python list that contains strings of equations.
L = ['651/349*t + 5382747/9778631000', 't + 57879/196133000', '1000/349*t + 57879/68450417']
You can see that all of the equations have integer division. Because this is obtained by some program, I can not edit the strings.
When I evaluate for `t=1.0` with the following code in SageMath (for example), it does not evaluate as an Euclidean division.
F = function('F')(t)
for k in L:
F(t) = eval(k)
Fc = fast_callable(F, vars=[t])
val2eval = 1.0
print(Fc(val2eval).n(13))
It gives
1.00000000000000
1.00000000000000
2.00000000000000
And should be give
1.86587997307599
1.00029510077345
2.86617507384944
Of course I can solve this by modifying MANUALLY the strings of the equations by indicating that the denominator is a real number and not an integer (I put a decimal point at the end of the integer in the denominator) as following.
L = ['651/349.*t + 5382747/9778631000.', 't + 57879/196133000.', '1000/349.*t + 57879/68450417.']
But this is not the idea, the strings of the equations are generated automatically and one can not modify by editing manually, because it will be implemented in a process where it should be create at least 2000 equations.
Is there some elegant solution for this? --Many thanks!loSuarezBSun, 18 Nov 2018 18:21:18 +0100https://ask.sagemath.org/question/44328/Comparing even powers of $i$ with 1https://ask.sagemath.org/question/10612/comparing-even-powers-of-i-with-1/Computing $i^4$ yields $1$, but it's not the same $1$ as when I type $1$. Compare these two evaluations:
sage: I^4 == 1
1 == 1
sage: I^2 == 1
-1 == 1
I would have expected the first to yield `True` and the second to yield `False`. Is Sage's answer a desirable default behavior?
I see that the first $1$ is a `sage.symbolic.expression.Expression` and the other $1$ is a `sage.rings.integer.Integer` (likewise for the $-1$). How can I make the comparison evaluate as one might reasonably expect mathematically?Ed ScheinermanTue, 15 Oct 2013 16:41:10 +0200https://ask.sagemath.org/question/10612/A combination of commands partial_fraction(x) and coefficient(x,n)https://ask.sagemath.org/question/10016/a-combination-of-commands-partial_fractionx-and-coefficientxn/I have asked this question over [here](http://stackoverflow.com/questions/15962495/a-combination-of-commands-partial-fractionx-and-coefficientx-n) but I got no answer.
I am trying to do some iterative calculations where each time SAGE constructs a fraction and lists the coefficients in the partial fraction decomposition of that fraction. I realized that doing everything symbolically, SAGE wants to keep everything as integer as possible. So what it does is to simplify fractions like `1/(x-3/2)` as `2/(2x-3)` and then when I ask for
> f.coefficient(x-3/2,-1)
it returns `0`, while I expect it to return `1`.
I have tried to solve things numerically, but there are two problems:
1. The errors get really big after each iteration
2. It takes much much longer to calculate it
Any suggestions to get SAGE to solve this is greatly appreciated.k1Fri, 12 Apr 2013 19:00:11 +0200https://ask.sagemath.org/question/10016/