• Maxima beginner's questions

    From Robert Latest@21:1/5 to All on Sun Oct 16 17:55:14 2022
    Hi all,

    while helping my daughter with her school algebra problems I thought I might get some benefit for myself and dabble in some CAS. (Back when I studied
    math in the 90s I didn't even know such a thing as CAS existed, and I
    always found algebra terribly tedious).

    Topic of the day, circle equations. So why not try and figure out the intersection points (if any) of two circles.

    (%i1) e1: x^2 + y^2 + a*x + b*y + c = 0;
    2 2
    (%o1) y + b y + x + a x + c = 0
    (%i2) e2: x^2 + y^2 + d*x + e*y + f = 0;
    2 2
    (%o2) y + e y + x + d x + f = 0

    X and y in the two equations are the same because we're searching the point(s) both have in common. So here goes:

    (%i3) solve([e1, e2], [x, y]);
    (%o3) []

    That took several seconds and yielded nothing. So let's try a more homeworky approach: subtract the equations to get rid of the square terms, solve for x (or y) and substitute into one of the equations:

    (%i5) solve(%, x);
    (e - b) y + f - c
    (%o5) [x = - -----------------]
    d - a

    Now I can already see that substituting this into %o1 or %o2 will bring up an idiotically convoluted quadratic equation. Just the right thing for a CAS. Nice. But now I'm stuck. I can't find anything in the docs on how to proceed from here.

    Questions:

    1) Why didn't Maxima find any solution at %i3?
    2) How does one substitute the expression for x at %o5 into %o1?
    3) I'm using the Linux console. How can I make Maxima use readline, so that
    arrow-up brings up an editable copy of an earlier command line?

    Thanks!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Latest@21:1/5 to Robert Latest on Mon Oct 17 08:36:51 2022
    Robert Latest wrote:

    [stuff]

    My questions from before have largely answered themselves by playing around a bit more with Maxima. Turns out that even the simpler general case of solving the intersection(s) of a circle with a straight line yields unwieldy solutions. When it comes to algebra, I try to teach my kids to "first do it only with letters, then insert numbers at the end," but I had never tried it with circle equations.

    I still don't know why Maxima can't solve the general case of two (possibly) intersecting circles, but I have a hunch that it would be a useless jumble of symbols. Much like the surprisingly absurd roots of a cubic equation.

    The remaining question is: Is there Readline support for Maxima on the Linux console?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Cloos@21:1/5 to All on Mon Oct 17 10:56:48 2022
    "RL" == Robert Latest <boblatest@yahoo.com> writes:

    The remaining question is: Is there Readline support for Maxima on the Linux
    console?

    if running just 'maxima' fails to use readline (whether it does depends
    on which lisp system was used to compile maxima), then there will be an 'rmaxima' command you can call instead.

    rmaxima is similar to running 'rlwrap maxima'.

    -JimC
    --
    James Cloos <cloos@jhcloos.com> OpenPGP: 0x997A9F17ED7DAEA6

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nobody@nowhere.invalid@21:1/5 to Robert Latest on Mon Oct 17 18:03:28 2022
    Robert Latest schrieb:

    Hi all,

    while helping my daughter with her school algebra problems I thought
    I might get some benefit for myself and dabble in some CAS. (Back
    when I studied math in the 90s I didn't even know such a thing as CAS existed, and I always found algebra terribly tedious).

    Topic of the day, circle equations. So why not try and figure out the intersection points (if any) of two circles.

    (%i1) e1: x^2 + y^2 + a*x + b*y + c = 0;
    2 2
    (%o1) y + b y + x + a x + c = 0
    (%i2) e2: x^2 + y^2 + d*x + e*y + f = 0;
    2 2
    (%o2) y + e y + x + d x + f = 0

    X and y in the two equations are the same because we're searching the point(s) both have in common. So here goes:

    (%i3) solve([e1, e2], [x, y]);
    (%o3) []

    That took several seconds and yielded nothing. So let's try a more
    homeworky approach: subtract the equations to get rid of the square
    terms, solve for x (or y) and substitute into one of the equations:

    (%i5) solve(%, x);
    (e - b) y + f - c
    (%o5) [x = - -----------------]
    d - a

    Now I can already see that substituting this into %o1 or %o2 will
    bring up an idiotically convoluted quadratic equation. Just the right
    thing for a CAS. Nice. But now I'm stuck. I can't find anything in
    the docs on how to proceed from here.

    Questions:

    1) Why didn't Maxima find any solution at %i3?
    2) How does one substitute the expression for x at %o5 into %o1?
    3) I'm using the Linux console. How can I make Maxima use readline,
    so that arrow-up brings up an editable copy of an earlier command
    line?


    Don't know why Maxima fails like this (the problem has been known for a
    long time and seems somehow impossible to fix), but feeding your input
    into Derive 6.10:

    e1 := x^2 + y^2 + a*x + b*y + c = 0

    e2 := x^2 + y^2 + d*x + e*y + f = 0

    SOLVE([e1, e2], [x, y])

    [x = ((b - e)*SQRT(a^2*(e^2 - 4*f) + 2*a*d*(2*(c + f) - b*e)
    + b^2*(d^2 - 4*f) + 4*b*e*(c + f) - 4*(c^2 + c*(d^2 + e^2 - 2*f)
    + f^2))*SIGN(a - d) + a*(b*e - 2*c - e^2 + 2*f) - d*(b^2 - b*e
    - 2*(c - f)))/(2*(a^2 - 2*a*d + b^2 - 2*b*e + d^2 + e^2))
    AND y = - (SQRT(a^2*(e^2 - 4*f) + 2*a*d*(2*(c + f) - b*e)
    + b^2*(d^2 - 4*f) + 4*b*e*(c + f) - 4*(c^2 + c*(d^2 + e^2 - 2*f)
    + f^2))*ABS(a - d) + a^2*e - a*d*(b + e) + b*(2*c + d^2 - 2*f)
    - 2*e*(c - f))/(2*(a^2 - 2*a*d + b^2 - 2*b*e + d^2 + e^2)),
    x = - ((b - e)*SQRT(a^2*(e^2 - 4*f) + 2*a*d*(2*(c + f) - b*e)
    + b^2*(d^2 - 4*f) + 4*b*e*(c + f) - 4*(c^2 + c*(d^2 + e^2 - 2*f)
    + f^2))*SIGN(a - d) - a*(b*e - 2*c - e^2 + 2*f) + d*(b^2 - b*e
    - 2*(c - f)))/(2*(a^2 - 2*a*d + b^2 - 2*b*e + d^2 + e^2))
    AND y = (SQRT(a^2*(e^2 - 4*f) + 2*a*d*(2*(c + f) - b*e)
    + b^2*(d^2 - 4*f) + 4*b*e*(c + f) - 4*(c^2 + c*(d^2 + e^2 - 2*f)
    + f^2))*ABS(a - d) - a^2*e + a*d*(b + e) - b*(2*c + d^2 - 2*f)
    + 2*e*(c - f))/(2*(a^2 - 2*a*d + b^2 - 2*b*e + d^2 + e^2))]

    yields an answer within seconds. Derive has been discontinued, however,
    and was only available for Windows anyway. For your school algebra
    problems on Linux, maybe you should try Giac?

    Martin.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From antispam@math.uni.wroc.pl@21:1/5 to Robert Latest on Tue Oct 18 19:44:03 2022
    Robert Latest <boblatest@yahoo.com> wrote:
    Hi all,

    while helping my daughter with her school algebra problems I thought I might get some benefit for myself and dabble in some CAS. (Back when I studied
    math in the 90s I didn't even know such a thing as CAS existed, and I
    always found algebra terribly tedious).

    Topic of the day, circle equations. So why not try and figure out the intersection points (if any) of two circles.

    (%i1) e1: x^2 + y^2 + a*x + b*y + c = 0;
    2 2
    (%o1) y + b y + x + a x + c = 0
    (%i2) e2: x^2 + y^2 + d*x + e*y + f = 0;
    2 2
    (%o2) y + e y + x + d x + f = 0

    X and y in the two equations are the same because we're searching the point(s)
    both have in common. So here goes:

    (%i3) solve([e1, e2], [x, y]);
    (%o3) []


    Using FriCAS:

    (37) -> eq1 := x^2 + y^2 + a*x + b*y + c

    2 2
    (37) y + b y + x + a x + c
    Type: Polynomial(Integer) (38) -> eq2 := x^2 + y^2 + d*x + e*y + f

    2 2
    (38) y + e y + x + d x + f
    Type: Polynomial(Integer) (39) -> res := solve([eq1, eq2], [x, y])

    (39)
    [
    (- e + b)y - f + c
    [x = ------------------,
    d - a

    2 2 2 2 2
    (e - 2 b e + d - 2 a d + b + a )y
    +
    2 2 2
    ((2 e - 2 b)f + (- a d - 2 c + a )e + b d - a b d + 2 b c)y + f
    +
    2 2 2
    (- a d - 2 c + a )f + c d - a c d + c
    =
    0
    ]
    ]
    Type: List(List(Equation(Fraction(Polynomial(Integer)))))

    This is not an explicit solution, but arguably is more useful: intead of
    two equations of order 2 in two variables you get so called triangular
    system, where last equation contains only single variable and other
    equations reduce to equation in single variable when you plug in
    solutions of later equation. In fact, here first equation gives
    you x in terms of y.

    If you want it more explicit we can solve quadratic equation:
    (40) -> radicalSolve(res(1)(2), y)
    (40)
    [
    y
    =
    (- d + a)
    *
    ROOT
    2 2 2 2 2
    - 4 f + (4 b e + 4 a d + 8 c - 4 b - 4 a )f + (- 4 c + a )e
    +
    2 2 2
    (- 2 a b d + 4 b c)e + (- 4 c + b )d + 4 a c d - 4 c
    +
    2 2
    (- 2 e + 2 b)f + (a d + 2 c - a )e - b d + a b d - 2 b c
    /
    2 2 2 2
    2 e - 4 b e + 2 d - 4 a d + 2 b + 2 a
    ,

    y
    =
    (d - a)
    *
    ROOT
    2 2 2 2 2
    - 4 f + (4 b e + 4 a d + 8 c - 4 b - 4 a )f + (- 4 c + a )e
    +
    2 2 2
    (- 2 a b d + 4 b c)e + (- 4 c + b )d + 4 a c d - 4 c
    +
    2 2
    (- 2 e + 2 b)f + (a d + 2 c - a )e - b d + a b d - 2 b c
    /
    2 2 2 2
    2 e - 4 b e + 2 d - 4 a d + 2 b + 2 a
    ]
    Type: List(Equation(Expression(Integer)))

    This is solved using usual quadratic formula, but since coefficients
    of the quadratic are complicated the result is large. One could
    plug in this y into formula for x, but result would be equally large.

    Note: when you look at "general solution" there are subtleties.
    You can see this already from the first solution: there is
    division by d - a. And indeed, depending on the other parameters
    beside normal case of two solutions there may be one solution,
    no solutions or infinitely many solutions. Similarely, quadratic
    formula gives "generic solution" and ignores special cases.

    Normally a CAS will give you "generic solution", that is solution
    which is valid as long as there are no divisions and which may
    miss some special cases. Some teachers insist of analysiong
    all cases, that quickly gets tedious both for people and at
    somewhat larger scale for computers. If you have numbers in
    the problem, than it is possible to see during computation
    if there are special cases and handle such cases apropriately,
    this avoids purely theoretical difficulties. OTOH if you
    really need general solution, then there is some extra work
    to check usual CAS solution and write proper conditions.

    --
    Waldek Hebisch

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Latest@21:1/5 to antispam@math.uni.wroc.pl on Thu Oct 20 13:02:35 2022
    antispam@math.uni.wroc.pl wrote:
    This is solved using usual quadratic formula, but since coefficients
    of the quadratic are complicated the result is large. One could
    plug in this y into formula for x, but result would be equally large.

    Note: when you look at "general solution" there are subtleties.
    You can see this already from the first solution: there is
    division by d - a. And indeed, depending on the other parameters
    beside normal case of two solutions there may be one solution,
    no solutions or infinitely many solutions. Similarely, quadratic
    formula gives "generic solution" and ignores special cases.

    I know all that. I didn't really *need* to find a general solution for the intersections of two circles. I just took my daughter's homework assignment as inspiration to play around with a CAS (which I always wanted but didn't have any reason to). I expected a screenful of messy solutions, but not an empty result.

    Normally a CAS will give you "generic solution", that is solution
    which is valid as long as there are no divisions and which may
    miss some special cases. Some teachers insist of analysiong
    all cases, that quickly gets tedious both for people and at
    somewhat larger scale for computers.

    Again, the homework assignment wasn't the general solution.

    If you have numbers in
    the problem, than it is possible to see during computation
    if there are special cases and handle such cases apropriately,

    That's of course more along school homework lines.

    this avoids purely theoretical difficulties. OTOH if you
    really need general solution, then there is some extra work
    to check usual CAS solution and write proper conditions.

    Like I said, I don't. I was just curious.


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From antispam@math.uni.wroc.pl@21:1/5 to Robert Latest on Thu Oct 20 20:36:00 2022
    Robert Latest <boblatest@yahoo.com> wrote:
    antispam@math.uni.wroc.pl wrote:
    This is solved using usual quadratic formula, but since coefficients
    of the quadratic are complicated the result is large. One could
    plug in this y into formula for x, but result would be equally large.

    Note: when you look at "general solution" there are subtleties.
    You can see this already from the first solution: there is
    division by d - a. And indeed, depending on the other parameters
    beside normal case of two solutions there may be one solution,
    no solutions or infinitely many solutions. Similarely, quadratic
    formula gives "generic solution" and ignores special cases.

    I know all that. I didn't really *need* to find a general solution for the intersections of two circles. I just took my daughter's homework assignment as
    inspiration to play around with a CAS (which I always wanted but didn't have any reason to). I expected a screenful of messy solutions, but not an empty result.

    OK. So use a CAS with reasonable equation solver (and not Maxima
    which is (in)famous for failures in its solver).

    --
    Waldek Hebisch

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Latest@21:1/5 to antispam@math.uni.wroc.pl on Fri Oct 21 16:40:56 2022
    antispam@math.uni.wroc.pl wrote:
    OK. So use a CAS with reasonable equation solver (and not Maxima
    which is (in)famous for failures in its solver).

    Thanks. Didn't know there were big differences.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eelon Mu$$$$ch@21:1/5 to Robert Latest on Sat Oct 29 10:25:44 2022
    On 16 Oct 2022 17:55:14 GMT, Robert Latest wrote:

    Hi all,

    while helping my daughter with her school algebra problems I thought I
    might get some benefit for myself and dabble in some CAS. (Back when I studied math in the 90s I didn't even know such a thing as CAS existed,
    and I always found algebra terribly tedious).

    Topic of the day, circle equations. So why not try and figure out the intersection points (if any) of two circles.

    (%i1) e1: x^2 + y^2 + a*x + b*y + c = 0;
    2 2
    (%o1) y + b y + x + a x + c = 0 (%i2) e2: x^2 +
    y^2 + d*x + e*y + f = 0;
    2 2
    (%o2) y + e y + x + d x + f = 0

    X and y in the two equations are the same because we're searching the point(s)
    both have in common. So here goes:

    (%i3) solve([e1, e2], [x, y]);
    (%o3) []

    That took several seconds and yielded nothing. So let's try a more
    homeworky approach: subtract the equations to get rid of the square
    terms, solve for x (or y) and substitute into one of the equations:

    (%i5) solve(%, x);
    (e - b) y + f - c
    (%o5) [x = - -----------------]
    d - a

    Now I can already see that substituting this into %o1 or %o2 will bring
    up an idiotically convoluted quadratic equation. Just the right thing
    for a CAS. Nice. But now I'm stuck. I can't find anything in the docs on
    how to proceed from here.

    Questions:

    1) Why didn't Maxima find any solution at %i3?
    2) How does one substitute the expression for x at %o5 into %o1?
    3) I'm using the Linux console. How can I make Maxima use readline, so
    that
    arrow-up brings up an editable copy of an earlier command line?


    Thanks!

    No wonder it won't give "solutions". In general, there are none.

    For instance
    e1: x^2+y^2 + 1 =0
    is not even a circle, yet obeys to your e1.

    First of all, use wxmaxima. It provides menus, help and many other things
    that simplify life to a beginner.

    Then, perhaps you could find a more recent computer.

    (%i14) solve([e1,e2],[x,y]);
    Evaluation took 2.6020 seconds (1.6910 elapsed)
    (%o14) []

    Finally, you should use a correct approach, as solve is right returning an empty set. For instance:

    (%i10) eliminate([e1,e2],[x,y]);
    (%o10) [((d-a)*sqrt(-4*f^2+(4*b*e+4*a*d+8*c-4*b^2-4*a^2)*f+ (a^2-4*c)*e^2+(4*b*c-2*a*b*d)*e+(b^2-4*c)*d^2+4*a*c*d-4*c^2)+(2*b-2*e)*f+ (a*d+2*c-a^2)*e-b*
    d^2+a*b*d-2*b*c)/(2*e^2-4*b*e+2*d^2-4*a*d+2*b^2+2*a^2)]

    (%i11) eliminate([e1,e2],[x]);
    (%o11) [(e^2-2*b*e+d^2-2*a*d+b^2+a^2)*y^2+(2*e*f+b*(-2*f+d^2-a*d)- a*d*e+a^2*e+c*(2*b-2*e))*y+f^2-a*d*f+a^2*f+c*(-2*f+d^2-a*d)+c^2]

    (%i12) eliminate([e1,e2],[y]);
    (%o12) [(e^2-2*b*e+d^2-2*a*d+b^2+a^2)*x^2+(2*d*f+a*(e^2-2*f)+b*(-d*e-a*e) +b^2*d+c*(2*a-2*d))*x+f^2-b*e*f+b^2*f+c*(-2*f+e^2-b*e)+c^2]

    Here are your quadratic equations. Maybe they have real solutions, maybe
    not. Good luck exploring your 6 dimensional parameter space.

    There are plenty of tutorials around for wxmaxima/maxima that could be
    helpful.

    HTH.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)