Using Octave at home
I was checking my daughter's homework which was about factorizing polynomials. They were too many and thought that Octave would allow me to do it in a quicker and easier way. By googling found the next link which explained how to do it on Matlab. I thought if it can be done on Matlab it should be the same on Octave. It is basically to create a symbolic variable and then use the factor() function to factorize the polynomial. Hence, the entry would be as next:
syms x
factor(2*x^2 + 3*x -5)
but when I tried this on Octave, it didn't accept the first line, saying the syms wasn't a known command. I googled a little more and found that syms belongs to the "symbolic" package. I downloaded the package and then found how to install it on Octave, "pkg install <path to package>\symbolic-2.6.0.tar.gz". This was successful, but then had to turn off and restart Octave. However, even so it failed after this but this time complaining that "sympy" was missing.
It was a matter to install SymPy Python package at the python location on my PC. For this, having pip was quite easy, "pip install sympy" per the instructions I found here.
Turned off Octave and on again and this time it worked. I was able to enter the trinomials and get an answer as the next example.
>> factor(2*x^2 + 3*x -5)
ans = (sym) (x - 1)*(2*x + 5)
I was able to finish checking her answers a lot quicker and felt my experience with Matlab and Octave enabled me to tackle this home task in a McGyver-ish way.
Manager, Software Test Engineering at Dexcom
5 年Why not using directly python for everything??>>> from sympy import * >>> init_printing() >>> x = symbols('x') >>> factor(2*x**2 + 3*x -5) (x - 1)*(2*x + 5) >>>?