![]() |
[HP Prime CAS] Solve Commands (Bugs and Request) - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: [HP Prime CAS] Solve Commands (Bugs and Request) (/thread-247811.html) |
[HP Prime CAS] Solve Commands (Bugs and Request) - CompSystems - 08-04-2013 Hello
for linear systems
Example #1 [Request] tag the answers solve( 4*x+3*y=10 and 5*x-2*y=1, {x,y} ) [Enter] return { [ x=1, y=2 ] } OK OK and if { [ x=1, and: y=2 ] } OK, OK, OK /!\ "and:" as tag (idea) http://www.wolframalpha.com/input/?i=solve%28+4*x%2B3*y%3D10+and+5*x-2*y%3D1%2C+%7Bx%2Cy%7D%29 purpose, use the expression (output) in a program left(x = 3) => x // to extract the variable right(x = 3) => 3 // to extract the result [Request] rename left to leftPart and right to rightPart linSolve( 4*x+3*y=10 and 5*x-2*y=1, {x,y} ) [Enter] return [ 1, 2 ] OK and if [ x=1, y=2 ] OK OK, and if [ x=1, and:y=2 ] OK OK OK Example #2 [HP-Prime CAS] solve( 4*x+6*y=10 and 2*x-3*y=6, {x,y} ) [Enter] return {} [Request] Better a boolean output (true/false) like TI-CAS+ calculators solve( 4*x+6*y=10 and 2*x-3*y=6, {x,y} ) [Enter] return false purpose use the expression (output) in a program if solve( 4*x+6*y=10 and 2*x-3*y=6, {x,y} ) == true then ... else ... now required a "trick" use DIM( ... ) =( if DIM( solve( 4*x+6*y=10 and 2*x-3*y=6) )== true, {x,y} ) then // ugly use DIM( equal with linSolve linSolve( 4*x+6*y=10 and 2*x-3*y=6, {x,y} )return [ ] ?? empty vector, ugly and nothing didactic for teaching and learning of math best linSolve( 4*x+6*y=10 and 2*x-3*y=6, {x,y} )return false =) if linSolve( 4*x+6*y=10 and 2*x-3*y=6, {x,y} ) == true then ... // [BUG#0 solve cmds] with SIMULT simult( [ [ 4, 6 ] [ [10] [ 2, 3 ]], [6]] return [ 0 ; 1 ] ?? // Bug 4*0 + 6 * 1 = 10 => 6 = 10 => false simult( [ [ 4, 6 ] [ [10]
[ 2, 3 ]], [6]]
see wolframalpha Example #3 solve( 4*x+6*y=12 and 2*x-3*y=2, {x,y} ) [Enter] return false =) simult( [ [ 4, 6 ] [ [12] [ 2, 3 ]], [6]] return [ 1 ; 0 ] ?? // Bug simult( [ [ 4, 6 ] [ [12]
[ 2, 3 ]], [6]] Thanks
/////////////////////////////// REQUEST Se requiere un comando para etiquetar similar a ->TAG de la HP50 ejemplo tag( "cplx1:", 3+4*i ) [Enter] cplx1: 3+4*i tag({ "x:", "y:", "z:" }, [ 3 4 1 ] ) [Enter] [ x:3, y:4, z:1 ]
/!\ la etiqueta no afectaría los cálculos, es muy útil por ejemplo para indicar en pantalla resultados mas bonitos sin la necesidad de convertirlos a cadenas, pues se cambiaría el tipo de dato
Edited: 6 Aug 2013, 2:57 p.m. after one or more responses were posted
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - Gilles Carpentier - 08-05-2013 I don't understand at all why you want the result 'false' for a system of equation with no solution. For me it's a non sense. The 'system' is not false, there is no solution -> S={}. My english is limited for such things but an empty set is not 'false' I also don't like the solution in the format (x=xx and y=xx) or (x=xx and y=yy) : it is verbious and confusing with boolean operators. S={s1; s2; ...} is far better (a set of solution) or S={} if there is no solution (an empty set) You also not use the correct syntax for linsolve ( [] and not {} ), and solve ( idem) . The AND syntax to solve a system of equation is curious for me and not documented in on line help of the Prime
Edited: 5 Aug 2013, 2:47 a.m.
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - CompSystems - 08-05-2013 >> I don't understand at all why you want the result 'false' for a system of equation with no solution can also be infinite solutions, in a linear system a student think when see an empty list? while you would think if you see "false" or "true" or when return the same input? all these details are think by TI-CAS developers >> I also don't like the solution in the format (x=... and y=...) or (x=... and y=...) : it is verbious and confusing with boolean operators.
[Castillian] [Eng] sorry, Google translator on the contrary, is much "smarter" this response ((x=... and y=...) or (x=... and y=...)), I said that solutions are conditional, ie if the two or more solutions satisfy the equation or if any of them satisfies the equation Please watch the following equation with 4 solutions [HP-Prime CAS] solve ( x^2-10*x+y^2=-8 and x*y^2+x+10*y=-8, {x,y} ) [Enter] return { [1, 1], [2.19 , 3.02 ] } [HP-Prime CAS++] solve ( x^2-10*x+y^2=-8 and x*y^2+x+10*y=-8, {x,y} ) [Enter] return { [x:1, and y:1], [x: 2.19, and y:3.02 ] } (idea or request) "x:", "y:" & "and y:" as TAG (->TAG CMD HP50G), then to operate the label disappears
>> S={} if there is no solution (an empty set) When the HP-Prime can not calculate, returns {} [BUG], should return the same expression otherwise you would think that there are no solutions or infinite solutions, etc ... >> The AND syntax to solve a system of equation is curious for me and not documented in on line help of the Prime [HP-Prime CAS] solve ( x^2-10*x+y^2=-8 AND x*y^2+x+10*y=-8, {x,y} ) { x^2-10*x+y^2=-8 , x*y^2+x+10*y=-8 } == x^2-10*x+y^2=-8 AND x*y^2+x+10*y=-8 // =) TI-CAS and others CAS computer sofware style =] and if apply this input form, why not in the output?
Edited: 5 Aug 2013, 9:51 a.m.
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - Gilles Carpentier - 08-05-2013 I don't agree with you here In the same way, when the TI returns 'false' with solve or linsolve command it is an error: There are no such things as a 'false' equation or 'false' system of equations
5=5 is true, but it's not an equation, it's an equality but the system of equation :
/is not 'false'. S={} I you search the intersection of 2 straight lines wich are // , the system is not 'false'. There is no solution and that's a different thing The same with 2 circles you can get : {} or {[a,b]} or {[a,b],[c,d]} or the equation of circle if they are the same. But no 'false' results nor false system
EDIT : An emply list is a 'void set' (ensemble vide) = no solution
An infinity of solution can be :
or All (x,y) € |R² in very special cases If an infinity of solution results as {}, there is a bug The only bug I see here is (I cant test):
solve(sqrt(x^x))=x^sqrt(x)) You can find the obvious solutions {1.,4.} with the numeric solver And always the same thing : the Prime dont verify matrix dimensions with your simult with bad parameters EDIT 3
Quote: you can use if solve([eq1,eq2],[x,y])<>{}
Edited: 5 Aug 2013, 2:00 p.m.
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - CompSystems - 08-06-2013 Example #4 solve( x1-3*x2+x3=1 and 2*x1-x2-2*x3=-1 and x1+2*x2-3*x3=-1, {x1,x2, x3}) x1-(7/5)*x3 = 0 => x1 =7/5*x3 x2 -(4/5)x3 = 0 => x2 = (4/5)x3 0*x3 = 1 // => 0 = 1 inconsistent system (FALSE equation) source [request] factor( [ t; 4*t; (1/2)*t ] ) => t * [ 1; 4 ; 1/2 ] transpose([[ 1 2 ] [ a, b ]]) => [[ 1 2 ] [ a, b ]]T concat( M1, M2) => M1|M2
Edited: 6 Aug 2013, 3:10 p.m.
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - Gilles Carpentier - 08-07-2013 "0*x3 = 1 // => 0 = 1 inconsistent system (FALSE equation) " This '0*x3=1 => 0=1' hurts my eyes ;)
0*x^3=1 is an equation without solution (altough in some case x=oo ) 0*x3=1 => S={} as there is no x€|R that verify this. Is 'a*x=1' a sometimes true / sometimes false equation ?
Another example : That means that x/x=1 is not the same than x=x wich gives S=|R
Edited: 7 Aug 2013, 6:27 a.m.
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - CompSystems - 08-07-2013 [HP-prime CAS 0.8.3] solve (sqrt(x^x))=x^sqrt(x), x) [Enter] {} // BUG [HP-prime CAS 1.1.0] solve (sqrt(x^x))=x^sqrt(x), x) [Enter] ["Unable to isolate x in exp(1/2*x*ln(x))-exp(exp(1/2*ln(x))*ln(x))"] // OK // I hope in the coming months, that CAS can solve this =) ... [Spn] =( translate.google.en Se ha corregido MAL un BUG que reporte recientemente, el cual es que si un sistema lineal no tiene solución, o infinitas soluciones SIMULT, retornaba como salida el vector columna final de la operación RREF, este resultado o vector no satisface las ecuaciones, por lo tanto como lo hacen otros CAS, debe arrojar un mensaje de error, ahora la HP-Prime CAS, retorna un BAD mensaje de error
M1: = [[1,-3,1],[2,-1,-2],[1,2,-3]] [HP-prime CAS 0.8.3] simult( M1, V1 ) => [ ] // BUG
[HP-prime CAS 1.1.0] simult( M1, V1 ) =>
simult( M1, V1 ) => "Infinitas soluciones" o "no hay solución" pero no "Bad Argument Value" como que "Mal Valor de Argumento"??, cual el primero o el segundo argumento es un mal valor?, Acá no hay error en los argumentos, por lo tanto lo considero nuevamente como un BUG Es muy fácil detectar si hay "Infinitas soluciones" o "no hay solución" se realiza RREF( CONCAT( M1,V1 )) y se analiza las ecuaciones de salida, para determinar si hay "solución única", "Infinitas soluciones" or "no hay solución", yo programe esto hace mucho tiempo en la HP48GX [Request] permitir el operador | como concatenación de matrices/vectores CONCAT( M1,V1 ) == M1|V1, otros CAS usan barra vertical punteada RREF( CONCAT( M1,V1 )) => RREF( M1 | V1 )
Edited: 7 Aug 2013, 6:45 p.m.
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - CompSystems - 08-08-2013 El TI-CAS es un CAS mas "inteligente" que el HP-CAS, por que se aproxima mas a como un ser humano lo haría, mientras que el HP-CAS sus respuestas no son tan intuitivas y como es para un mercado estudiantil pre-universitario, dudo que tenga buena acogida, casi siempre en la HP-Prime hay que estar re-escribiendo las expresiones para obtener algo mas facil de manipular Ejemplo: Sistemas de ecuaciones lineales con "Soluciones infinitas" x1-3*x2+x3 = 1 2*x1-x2-2*x3 = -1 2*x1-6*x2+2*x3 = 2 en forma A*x=b [[1,-3,1,1], [ x1; x2; x3 ] = [ 1; -1; 2 ] [2,-1,-2,-1], * [2,-6,2,2]] M1:= [[1,-3,1], [2,-1,-2], [2,-6,2]] x:= [[ x1],[x2][x3]] b: = [[1], [-1],[2]] sol:={} Aplicando RREF (reduced row echelon form) rref( concat( M1, b ) ) [Enter] => [[1,0,-7/5,-4/5], [0,1,-4/5,-3/5], [0,0,0,0]] x1=(7/5)*x3-4/5 x2=(4/5)*x3-3/5 x3=x3 [TI-CAS] solve( x1 -3*x2 +x3 = 1 and 2*x1 -x2 -2*x3 = -1 and 2*x1 -6*x2 +2*x3 = 3), { x1, x2, x3 } ) :) x1=(7* c1 -4)/5 and x2=(4*c1-3 /5) and x3=c1 sol:= Ans sol:= x1=(7* c1 -4)/5 and x2=(4*c1-3 /5) and x3=c1 reemplaza x3 = c1, en la parte derecha de las expresiones, salida en función de un parámetro, el cual tiene un propósito evaluar las expresiones sin afectar la variable parametro x1=(7* c1 -4)/5 and x2=(4*c1-3 /5) and x3=c1 | (c1 =2) => x1=1 and x2 = 1 and x3=2 pueden observar con mas detalle la solución en:
[HP-CAS] solve( x1 -3*x2 +x3 = 1 and 2*x1 -x2 -2*x3 = -1 and 2*x1 -6*x2 +2*x3 = 3), { x1, x2, x3 } ) Comparen las dos respuestas anteriores, por cual calculadora se inclinarían? sol:= Ans sol:= { [ x1, -1/35*(-20*x1+5), -1/4*(5/35*(-20*x1+5)-3) ] } re-escribiendo las expresiones anterior sol := simplify( Sol ) sol := simplify( { [ x1, -1/35*(-20*x1+5), -1/4*(5/35*(-20*x1+5)-3)] } => sol := [ x1, (4*x1-1)/7, (5*x1+4)/7] reescribiendo para que sea útil dentro de un programa x := sol // fail transpose(x) := sol // fail vx : = [ x1, x2, x3 ] // se requiere una nueva definición del vector x como vector fila sol: = (vx = sol) => sol:= ([ x1, x2, x3 ] = [ x1, (4*x1-1)/7, (5*x1+4)/7 ]) sol:=([ x1 = x1, x2 = (4*x1-1)/7, x3=(5*x1+4)/7 ] ) todos los pasos anteriores para poder tener una respuesta mejor :( en resulmen en la HP-Prime [ x1, x2, x3 ] = simplify ( solve ( x1 -3*x2 +x3 = 1 and 2*x1 -x2 -2*x3 = -1 and 2*x1 -6*x2 +2*x3 = 3), { x1, x2, x3 } ) ) [ x1 = x1, x2 = (4*x1-1)/7, x3=(5*x1+4)/7 ] mientras que en la TI-CAS solve ( x1 -3*x2 +x3 = 1 and 2*x1 -x2 -2*x3 = -1 and 2*x1 -6*x2 +2*x3 = 3), { x1, x2, x3 } ) x1=(7* c1 -4)/5 and x2=(4*c1-3 /5) and x3=c1 con el comando LInSolve las cosas son mejores [ x1, x2, x3 ] = solve ( x1 -3*x2 +x3 = 1 and 2*x1 -x2 -2*x3 = -1 and 2*x1 -6*x2 +2*x3 = 3), { x1, x2, x3 } ) [ x1=(7/5* x3 -4), x2=(4/5*x3-3 ), x3=x3 ] pero hay un problema [ x1=(7/5* x3 -4), x2=(4/5*x3-3 ), x3=x3 ] | x=3 => [ x1 = 2, x2=1, 2=2 ] ver tercer elemento ( 2 =2 ) Si linsolve arrojara en función de un parámetro seria fabuloso y si incluyera las variables, se igualria al CAS de las TI-calculators linSolve ( x1 -3*x2 +x3 = 1 and 2*x1 -x2 -2*x3 = -1 and 2*x1 -6*x2 +2*x3 = 3), { x1, x2, x3 } ) [ x1=(7/5* t -4), x2=(4/5*t-3 ), x3=t ] // Super CAS [ x1=(7/5* t -4), x2=(4/5*t-3 ), x3=t ] | t = 2
[ x1 = 2, x2=1, x3=2 ] Edited: 8 Aug 2013, 10:11 a.m.
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - Gilles Carpentier - 08-08-2013
Quote:
What a complex way to do ! s:=linsolve([x1-3*x2+x3=1,2*x1-x2-2*x3=-1,2*x1-6*x2+2*x3=2],[x1,x2,x3]) s|x3=2
Edit : Your system of equation is not the same in the beginning and the end of your post. I take the first one.
Edited: 8 Aug 2013, 12:32 p.m. after one or more responses were posted
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - CompSystems - 08-08-2013 I think as you would do in a program, not in the entry line
Please can create a program that made the steps above, detecting the parameter Edited: 8 Aug 2013, 12:33 p.m.
Re: [HP Prime CAS] Solve Commands (Bugs and Request) - Gilles Carpentier - 08-08-2013 Sorry but I don't understand spanish, I dont'see see any program Cheers, EDIT : For what I understand of your TI example, to do the same on the HP linsolve([x1-3*x2+x3=1,2*x1-x2-2*x3=-1,2*x1-6*x2+2*x3=2],[x1,x2,x3]) STO> s s|x3=c1 STO> s s|c1=2 But I don't see any interest to replace x3 with c1
The last rev has auto-simplification options in CAS setup Edited: 8 Aug 2013, 5:11 p.m.
|