HP Forums

Full Version: HP Prime Solving Nonlinear System of Equations for Complex Results
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Apparently, the built-in App (Solve) doesn't allow complex starting values, and doesn't search for complex solutions - - or does it?

I tried to use csolve(), but that only allows a single equation to be entered, and also fsolve(), but the syntax is not clear to me. The help screen states, that a numerical solution of a system of equations can be returned, but the syntax given is fsolve(Expr, Var, [Guess or interval], [Method]). I'm not sure how to use this with more than one non-linear equation.

By the way, how many methods are there to choose from? Not clear from the user's guide).

I'm really looking for something like Sune Bredahl's excellent Solvesys for the HP49G+ and HP50G (couldn't something along those lines have been implemented for the Prime?), or even like the somewhat clunkier and slower MSLV (both return complex solutions).

For the built in solver (numeric view), some diagnostic output would be helpful as well (convergence, # iterations, etc.), along with an indication that the solver is running (so that he user isn't staring at a static screen, wondering if the Solve softkey has been tapped successfully).

You can get complex results by using the reduced row echelon method of solving a linear system.

For example, suppose you have the following two equations:

(5+6i)x + (3+8i)y = 9

(2+4i)x + (-3+5i)y = 4.5+6i

You would create a matrix (i.e., M1) as follows:

5+6i 3+8i 9

2+4i -3+5i 4.5+6i

Now use the command RREF(M1) and you will get the following resulting matrix (I'm rounding the values for simplicity):

1 0 0.058+0.410i

0 1 0.196-1.322i

which means x=0.058+0.410i and y=0.196-1.322i.

Using this method, you can solve a linear system with pretty much any number of equations (well except for the limitations that the prime has on matrix sizes.)

Hope this helps.


Yes this works for a linear, complex system - - thanks for the tip with RREF!

However, if the complex system is non-linear in the parameters . . .

Oops... I misread the title of your post as "linear" instead of "nonlinear". My apologies.


It looks like fsolve should do it, but even the example in the help section for fsolve causes an error in both home and CAS mode.


Use the cZeros function in CAS mode. Suppose there is a system of non-linear equations as follows:



The input form is cZeros({x^2+y^2=1,y=-x-3},{x,y}). You'll get the result you want.

Edited: 29 Sept 2013, 2:33 p.m.

The example given for fsolve, i.e., fsolve(COS(x)=x,x)

works for me in CAS mode, returns .739...

Not in home mode, though, fsolve(COS(X)=X,X) returns "undef"

YES! Thanks so much!

In HOME mode, use FNROOT instead of fsolve:


Yes, that works! - - but not for systems of equations.

Thanks - - so for this problem (one variable nonlinear equation) use FNROOT in Home, and csolve in CAS!

. . . with the caveat, that cZeros seems to be only working for polynomials, and not for general non-linear equations. try it and you will get an error, e.g., [x, x^y, sin (x*y)] is not rational w.r.t.

It isn't supported for the moment.

Edited: 30 Sept 2013, 3:45 a.m.