1

Cosider the simple solution:

 sol: solve(b * x - a, x);
     a
[x = -]
     b

how can I get the expression part sol: a / b out of the above result?

solution was offered to me here.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
  • 2
    In what way is the offered solution not working for you? What is it that you want to do that the offered solution does not cover? A different way to solve it is to say: `sol: rhs (first (sol))`. By the way, about the other problem in the tweets, note the name of the plotting function is `wxplot2d`, not `wxplot2D`. – Robert Dodier Mar 05 '21 at 23:31
  • hey, @RobertDodier thanks for the comment. If by the offered solution you mean the one below, it is not a WxMaxima/Maxima solution. If you mean the one I have linked in the Tweet, then it is a perfectly fine solution. I'm just gonna add it as an answer below. Also, feel free to offer your alternative solution as an answer if you will. – Foad S. Farimani Mar 05 '21 at 23:51

2 Answers2

1

Thanks to Johann Weilharter I found one way to extract the expression:

 sol: ev(x, solve(b * x - a, x)[1]);

Of course, if there is more than one solution, you need to change 1 to the specific instance.

Alternatively, as pointed out in the comments of the question, one can also use

sol: rhs(first(solve(b * x - a, x)));

oneliner to do the job.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
0

What you need is a symbolic evaluation library. If you are considering a python implementation, you can use SymPy.

import sympy as sym

x = sym.Symbol('x')
b = sym.Symbol('b')
a = sym.Symbol('a')
sol = sym.solve((b * x - a), x)
print(sol)

------
[a/b]