[APP]SOLVE - compsystems - 09-19-2016 12:15 PM
hello, testing solvers, something strange happens with fsolve
WITH CSOLVE COMMAND:
csolve((X^2-2*X) = -3,X) [ENTER])returns
{1+√2*i,1-√2*i}
approx(csolve({X+Y=2,X*Y=3},{X,Y})) [ENTER])returns
{[1.+1.41421356237*i,1.-1.41421356237*i],[1.-1.41421356237*i,1.+1.41421356237*i]}
WITH FSOLVE COMMAND:
fsolve({x+y = 2, x*y = 3},{x,y},{0,1-i}) [ENTER])returns
{1.+1.41421356237*i,1.-1.41421356237*i}
NOW WITH DIALOG BOX of FSOLVE ([APP]SOLVE [ENTER])
✓ E1: X+Y=2
✓ E2: X*Y=3
[NUM][v (down)] 1+i[ENTER]) show Error Input Invalid. Why?
RE: [APP]SOLVE - Didier Lachieze - 09-19-2016 12:37 PM
(09-19-2016 12:15 PM)compsystems Wrote: NOW WITH DIALOG BOX of FSOLVE ([APP]SOLVE [ENTER])
✓ E1: X+Y=2
✓ E2: X*Y=3
[NUM][v (down)] 1+i[ENTER]) show Error Input Invalid. Why?
As written at the beginning of chapter 14. Solve App in the manual:
Quote:Solve works only with real numbers.
RE: [APP]SOLVE - compsystems - 09-19-2016 01:09 PM
but why it works only with real numbers?
I think then do not call the function fsolve of CAS, if not a pseudo numerical solver
Operate only with real numbers is a useless application, the true algebra covers the field of to complex numbers y the hpprime is a modern calculator
RE: [APP]SOLVE - BERNARD MICHAUD - 09-20-2016 01:31 AM
Try Linear Solver+ App from the Software Library.
Similar to Linear Solver App, but works with Complex Numbers. 2x2 or 3x3.
7+8*i + 4+5*i = 22+4*i
4+5*i + 3+2*i = 18+6*i
X = 1.7-3.9*i
Polar = [4.2544,-66.44]
Y = 0.1+4.3*i
Polar = [4.30116,88.6677]
RE: [APP]SOLVE - compsystems - 09-20-2016 12:08 PM
ok, please convert it to an app (.hpapp, .hpappprgm) your LSX.hpprgm
LSX.hpprgm link
http://www.hpmuseum.org/forum/thread-6589.html
LSX.hpprgm
Code:
quit();
MAT2();
MAT3();
MAINMENU();
local OPN;
local Z10,Z11,Z12,Z13,Z14,Z15;
local Z16,Z17,Z18,Z19,Z20,Z21;
//_________________________________________________________
MAINMENU()
BEGIN
HFormat:=0;
LOCAL CH:=0;
CHOOSE(CH,"Linear Solver 2x2 and 3x3.",
{" Quit Linear Solver",
" Linear Solver 2x2.",
" Linear Solver 3x3."});
IF 0 THEN IFERR BREAK; BREAK; THEN END
END;
CASE
IF CH == 1 THEN
IFERR BREAK; BREAK; THEN END
END;
IF CH == 2 THEN MAT2();
END;
IF CH == 3 THEN MAT3();
END;
IF CH == 4 THEN PRINT();
PRINT("
Linear Solver.
by: Bernard Michaud.
Aug. 20 2016.
Toronto, ON.
");
IFERR REPEAT UNTIL GETKEY>-1;
THEN MAINMENU();
ELSE
MAINMENU();
END;
END;
DEFAULT IFERR BREAK; BREAK; THEN END
END;
END;
quit()
BEGIN
PRINT();
PRINT(" ");
IFERR REPEAT UNTIL GETKEY>-1;
THEN MAINMENU();
END;
MAINMENU();
END;
//----------------------------------------------------
MAT2()
begin
INPUT({
{Z10,[3],{5,22,1}},{Z11,[3],{40,22,1}},{Z12,[3],{72,22,1}},
{Z13,[3],{5,22,3}},{Z14,[3],{40,22,3}},{Z15,[3],{72,22,3}}},
"Solver 2x2.",
{"","X + ","Y =",
"","X + ","Y ="});
MAKEMAT(0,2,3)▶M1;
M1(1,1):=Z10;M1(1,2):=Z11;M1(1,3):=Z12;
M1(2,1):=Z13;M1(2,2):=Z14;M1(2,3):=Z15;
RREF(M1)▶M2;
col(M2,(3))▶M3;
PRINT();
PRINT("
X = "+M2(1,3)+" Polar = "+polar_coordinates(M2(1,3))+"
Y = "+M2(2,3)+" Polar = "+polar_coordinates(M2(2,3))+"
Press [ENTER] to Continue...");
IFERR REPEAT UNTIL GETKEY>-1;
THEN
CHOOSE(OPN,"",{"BM"});
CASE
IF OPN==1 THEN PRINT(); END;
DEFAULT
END;
ELSE
CHOOSE(OPN,"Choose Option below.",
{
" Back to Linear Solver 2x2",
" Back to Main Menu...",
" Quit"});
CASE
IF OPN==1 THEN MAT2(); END;
IF OPN==2 THEN MAINMENU(); END;
IF OPN==3 THEN IFERR BREAK; BREAK; THEN END END;
DEFAULT
END;
END;
END;
//_________________________________________________________
MAT3()
begin
INPUT({
{Z10,[3],{5,16,1}},{Z11,[3],{30,16,1}},{Z12,[3],{55,16,1}},{Z13,[3],{80,16,1}},
{Z14,[3],{5,16,3}},{Z15,[3],{30,16,3}},{Z16,[3],{55,16,3}},{Z17,[3],{80,16,3}},
{Z18,[3],{5,16,5}},{Z19,[3],{30,16,5}},{Z20,[3],{55,16,5}},{Z21,[3],{80,16,5}}},
"Solver 3x3.",
{"","X+","Y+","Z=","","X+","Y+","Z=","","X+","Y+","Z="});
MAKEMAT(0,3,4)▶M1;
M1(1,1):=Z10;M1(1,2):=Z11;M1(1,3):=Z12;M1(1,4):=Z13;
M1(2,1):=Z14;M1(2,2):=Z15;M1(2,3):=Z16;M1(2,4):=Z17;
M1(3,1):=Z18;M1(3,2):=Z19;M1(3,3):=Z20;M1(3,4):=Z21;
RREF(M1)▶M2;
col(M2,(4))▶M3;
PRINT();
PRINT("
X = "+M2(1,4)+" Polar = "+polar_coordinates(M2(1,4))+"
Y = "+M2(2,4)+" Polar = "+polar_coordinates(M2(2,4))+"
Z = "+M2(3,4)+" Polar = "+polar_coordinates(M2(3,4))+"
Press [ENTER] to Continue...");
IFERR REPEAT UNTIL GETKEY>-1;
THEN
CHOOSE(OPN,"",{"BM"});
CASE
IF OPN==1 THEN PRINT(); END;
DEFAULT
END;
ELSE
CHOOSE(OPN,"Choose Option below.",
{
" Back to Linear Solver 3x3",
" Back to Main Menu...",
" Quit"});
CASE
IF OPN==1 THEN MAT3(); END;
IF OPN==2 THEN MAINMENU(); END;
IF OPN==3 THEN IFERR BREAK; BREAK; THEN END END;
DEFAULT
END;
END;
END;
//___________________________________________________________
EXPORT LSX()//4K
BEGIN
MAINMENU();
END;
RE: [APP]SOLVE - compsystems - 09-20-2016 08:48 PM
for hp-prime team:
It not intended to be symbolic coefficients on app solve or linear solve, but at least they can be general case encompassing complex numbers, The hardware hp-prime can with more than app numerical and real problems.
I hope to be included in the next firmware
|