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, 06 Sep 2020 19:59:38 +0200Division algorithm in one variablehttps://ask.sagemath.org/question/53339/division-algorithm-in-one-variable/ Hi! I'm trying to implement the division algorithm 'by hand' (yes, I know the existence of `f.maxima_methods().divide(g)`)
So far I've came up with this:
def div(f,g):
q==0; r==f;
while r != 0 and g.lt().divides(r.lt()):
q==q+r.lt()/g.lt()
r==r-(r.lt()/g.lt())*g
return q,r
but I'm getting an error on the "while" line. I'm following Ideals, Varieties and Algorithms by Cox (page 39 of the book), and they insert a "do" at the end of the while line, but I'm getting an "invalid syntax" error there.
I'm pretty inexperienced with coding, and even more with Python/Sage (I've only taken a numerical methods course with Fortran).
I've gotten this "far" reading the book + documentation. Any ideas on how to proceed here?HitSun, 06 Sep 2020 19:59:38 +0200https://ask.sagemath.org/question/53339/Smallest positive numerical solution of an equation in one variablehttps://ask.sagemath.org/question/43152/smallest-positive-numerical-solution-of-an-equation-in-one-variable/ I have some functions, all of which are functions of variable $x$ but some of them may not have any positive solutions. It is known that at least one of them have a positive solution. Now I need a list of all smallest positive solutions for those functions. For example consider $f=x^2+3x+2$ and $g=2^{(5x + 1)} - 3.2^{(3x + 1)}$. Here $f$ doesn't have any positive root but $g$ has (0.792481250360578). I want a sage code like min(solve([f,x>1],x))+min(solve([g,x>1],x)) to get the list as [0.792481250360578]. Thank you in advance.Deepak SarmaWed, 25 Jul 2018 13:48:40 +0200https://ask.sagemath.org/question/43152/