# "Waiting..." by trying to use the solve() function with symbolic

Hi guys,

so I read similar topics regarding the problem by using the solve function and it wasn´t quite helpful. Octave is just being stuck with the output “Waiting…”.

Here is my code:

``````clear all; close all; clc

pkg load io dataframe symbolic

b = 1

syms a real

%Equation test:

%Equaton to solve:

eqn_TS = (a/(( 1 - a ) * (0.5/0.95 - a/2)^(0.5)))*(3.50526 - a/2)^(-0.5) == b

a_solved = solve(eqn_TS, a)

a_number = double(a_solved)
``````

Here is the output:

When I´m executing the code in Matlab, then the value is approximately a_number = 0.998, which is a plausibel result.

Any ideas how can I solve this issue?

Thanks a lot in advance.

Best Regards.

It’s not clear from your post whether you want a symbolic expression for `a` or a numerical value. If you want a numerical value, rearrange your equation and pass it to `roots` or `fzero` or `fsolve` as appropriate. If you need a symbolic expression, you’re passing a floating point value which is problematic, and the “Waiting…” you see is from SymPy. You’ll have to replace the values like `0.5/0.95` and `3.50526` with other symbols like `b` and `c`, and cross-multiply to avoid a big division. You might as well square it as well if appropriate.

1 Like

Hi phys.mat

I have tested your code and I have also the same problem.

I’ve tried to solve the ecuation manually and using roots, the results are 4 roots with a
pair of complex solution.

After simplify the expresion I’ve got this equality :

-0.25x^4 - 2.5150x^3 + 6.1050x^2 - 5.6650x + 1.8250 = 0

using roots the solutions are:

``````r = [-0.2500  -2.5150   6.1050  -5.6650   1.8250];
roots(r)
``````

-12.2150 + 0i
0.7580 + 0.6006i
0.7580 - 0.6006i
0.6390 + 0i

2 Likes

@arungiridhar `I`m trying to solve the equation for a that I defined as eqn_TS and then receive a numerical value of a. a_number supposed to be the final solution as a number. The main idea behind the script is to solve the equation without rearranging it by myself, since it is possible to make some mistakes and it is much more convenient to let the computer/octave to do the job. Replacing the values such as `0.5/0.95 and 3.50526 `with symbols like` a and b won`t make a lot of difference… Matlab has no problems with it by the way. I`ve executed the script one more time in Matlab and have got the following output:

I need to solve it in Octave, because not everyone got a Matlab license in my class… I just don`t understand, why Octave has problems with the same script…

@89453728 Thanks for simplyfying the equation, but the number supposed to be real…

Any ideas what could go wrong?

@phys.mat I´m in the same situation like you. I have also a complicated equation with roots and octave has some problems to solve my equations. I´m also simplified your equation that you are trying to solve, but i´m still gettng the “waiting…” from octave.

See eqn_TS below.

``````clear all; close all; clc

pkg load io dataframe symbolic

syms a real

b = 1;
c = 0.5/0.95;
d = 3.50526;

eqn_TS = b^2*(c*d - c*(a/2) - (a/2)*d + a^2/4 - 2*a*c*d + c*a^2 + a^2*d - 0.5*a^3 + a^2*c*d - a^3*(c/2) - (a^3/2)*d - a^4/4) - a^2 == 0

a_solved = solve(eqn_TS, a)
``````

Maybe we should wait and hope that someone from the development team will answer us.

By the way, I also tried your original code in Matlab and i´m receiving the same value for a_number = 0.4893 as you.

To be very clear: The “Waiting…” you’re seeing is not from Octave but from SymPy. You’re barking up the wrong tree in blaming Octave for that.

If it is practical for you to rearrange the equation and put it in a standard polynomial form, you can use `roots` after that. You will get all roots for the polynomial, positive, negative, and complex. You’ll have to select the appropriate one(s) based on your domain expertise. You can select only the real ones by filtering based on `imag` beng small or zero for instance.