HP Forums
Probs solving sys. of eqs. programatically. - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Probs solving sys. of eqs. programatically. (/thread-11664.html)



Probs solving sys. of eqs. programatically. - John P - 10-25-2018 08:33 PM

How do I enter system of eqs using program, ex. PROG(sys_eqs,vars). I try variable as strings with/without curly/square brackets and nothing works. What I do wrong? Strings as arguments to programs used to work with CAS(),EXPR(). Does that changed in the latest beta? I use the latest beta firmware. In the PRGM in CAS I use solve or fsolve.


RE: Probs solving sys. of eqs. programatically. - sasa - 10-26-2018 05:52 AM

Perhaps it is more convenient to work directly with objects.

For instance:
Code:

#cas
SZ_T1(eq_list)
begin

  local n:= size(eq_list);
  local i, eq; 

  print ("");
  print ("There is " + n + " objects");

  for i from 1 to n do
    eq:= eq_list[i];    
    print (i + ": " + eq);    
  end;
   
end;
#end

#cas
SZ_T2(eq_list, var_list)
begin
  local n:= size(eq_list);
  local i, eq; 

  print ("");
  print ("There is " + n + " objects");

  for i from 1 to n do
    eq:= eq_list[i];    
    print (i + ": " + eq);    
  end;

  print(" ");
  print("Var list: ")
  print(var_list);

  print(" ");
  print("Solution: ");
  print(solve(eq_list,var_list));
 
end;
#end

Examples:

SZ_T1( (2*x+3*y)=1, (x+y) = 2 )
SZ_T2([(2*x+3*y) = 1,(x+y) = 2],[x,y])


RE: Probs solving sys. of eqs. programatically. - John P - 10-26-2018 04:42 PM

Thank you sasa.