1

Maxima returns no results for the following:

 solve ([a = (p-x)*c, b = (q-x)*d, a + b = 0], [x]);

I think it should return:

                       d q + c p
                  [x = ---------]
                         d + c

What am I doing wrong?

Rob190
  • 13
  • Does it succeed if you replace $b$ by $-a$ and omit the equation $,a+b = 0?\ $ Try $,\rm assume(c+d,#,0),$ beforehand. – Bill Dubuque Apr 14 '19 at 21:12
  • No but if I perform the substitution by hand, i.e.

    solve ([ (p-x)c + (q-x)d = 0], [x]);

    then it works as expected.

    – Rob190 Apr 14 '19 at 21:26
  • I couldn't get the assume(c+d # 0) to work. It doesn't like the '#' operator. I tried assume(notequal(c+d,0)) but it still returned no results. – Rob190 Apr 14 '19 at 21:32

1 Answers1

2

You have a system of 3 equations of one variable x. Such a system can be overdetermined. Even

solve ([a = (p-x)*c, b = (q-x)*d, a + b = 0], [x]);

results in an empty solution

[]

because a+b=0 isn't true except for special values of the constants a and b. A constant expression will be true in this context only if it can be proved that is true for all possible assignment to the parameters.

I think you actually wanted to solve the system

solve ([a = (p-x)*c, b = (q-x)*d, a + b = 0], [x, a, b])

with three variables x, a, b and the constants c,d,p,q.

Maxima calculates the solution

[[x = (d*q+c*p)/(d+c),a = (c*d*p-c*d*q)/(d+c),b = -(c*d*p-c*d*q)/(d+c)]]

where x has the value you expected.

miracle173
  • 11,049
  • Thanks. That works but I'm still not clear why.

    You said 'a+b=0' is only true for special values but the solution maxima gives clearly shows a+b=0 in general.

    Also 'solve ([ (p-x)c + (q-x)d = 0], [x]);' works as I would expect.

    – Rob190 Jan 13 '20 at 19:08
  • @Rob190 You have to distinguish between constants and variables. In the solve([...,a+b=0],[x]) statement a and b are not in the variable list [x], so they are constants (or parameters). a+b=0 is false because one cannot show that a+b=0 for arbitrary values a and b (e.g. 3+5 !=0). If one statement is false in a system of equations then this system does not have a solution. In the statement solve([...,a+b=0],[x,a,b]) a and b are in the variable list so Maxima tries to calculate the values of these variables such that all equations of this system of equations are true. – miracle173 Jan 14 '20 at 18:57