Solving equation system

Windows 10, Octave 6.2.1

Solve says that it cant find a soultion (sol = {}(0x0)) but i can get a solution for this on maxima.
Examples i have found look simlar so i don’t know why mine is not working.


clear all
pkg load symbolic
sympref display unicode

syms a b c d e f g h x

s(x) = hx^7+gx^6+fx^5+ex^4+dx^3+cx^2+b*x+a;
v(x) = diff(s(x));
a(x) = diff(v(x));
r(x) = diff(a(x));

eqns = [s(0)==0, s(1)==1/2, v(0)==0, v(1/2)==1/2, v(1)==1, a(0)==0, a(1)==0, r(0)==0, r(1)==0];
vars = [a, b, c, d, e, f, g, h];
sol = solve (eqns, vars)



Is it safe to assume your main equation is actually:

s(x) = h*x^7+g*x^6+f*x^5+e*x^4+d*x^3+c*x^2+b*x+a;

s(x) = hx^7+gx^6+fx^5+ex^4+dx^3+cx^2+b*x+a;

Looks like i accidentally removed the multiply sign between h and x in this post.

After fixing the s(x) equation, getting the same empty result as you I checked in Matlab. There, I noticed that you use a as a constant and then redefine it as a function. When I try to run solve I get the error message:

>> sol = solve (eqns, vars)
Error using sym.getEqnsVars>checkVariables (line 92)
Second argument must be a vector of symbolic variables.

looking back at var:

>> vars
vars(x) =
[42*h*x^5 + 30*g*x^4 + 20*f*x^3 + 12*e*x^2 + 6*d*x + 2*c, b, c, d, e, f, g, h]

It seems Octave does not provide an error as it allows you to try to solve the equation with a more complicated variable set, but then just returns an empty solution set. Not sure whether or not this is intended.

If i replace a(x) with acc(x) in every line above I get the some solution in both Octave and Matlab:

>> sol = solve (eqns, vars)
sol =
  scalar structure containing the fields:
    g =
      <class sym>
    h =
      <class sym>
    e =
      <class sym>
    f =
      <class sym>
    d =
      <class sym>
    c =
      <class sym>
    b =
      <class sym>
    a =
      <class sym>

>> [sol.a,sol.b,sol.c,sol.d,sol.e,sol.f,sol.g,sol.h]
ans = (sym) [0  0  0  0  5/2  -3  1  0]  (1x8 matrix)
1 Like

not sure if this is really a bug. looking at both the Matlab and octave help for solve, it appears that Octave supports a wider range of input syntax, at least one of which does not require an explicit var input. Matlab, on the other hand, only lists a couple input options, all of which require explicit var definition, and must be of type symbolic variable. So it threw an error when I turned a into a symbolic expression and tried to pass it as a variable. One of the permissible Octave input forms is:

SOL = solve (EQN1, ..., EQNN)

with no explicit variable input. So Octave saw you passing two symbolic expressions as input, and tried to solve them as simultaneous equations, which it obviously couldn’t do.

I’ll make an inquiry over at the symbolic package maintainer’s GitHub, and see maybe this is something that should throw a warning.
(see should no-variable inputs to solve provide a warning? · Issue #1045 · cbm755/octsympy · GitHub)

So stupid from me :-(. Many thanks for your help. In Maxima i got the same solution so this correct.

Best regards