[hp50g] is it possible to solve linear systems with unknown variables in it? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: [hp50g] is it possible to solve linear systems with unknown variables in it? (/thread-18954.html) |
[hp50g] is it possible to solve linear systems with unknown variables in it? - felipeek - 10-12-2022 11:16 PM For example, I wanna solve the following linear system: 7x + 2Ky = 0 3Kx - 8y = 2 where K is an unknown variable. The result of the solver should be a function of K. Is it possible with hp50g? How? Thanks in advance! RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - Gjermund Skailand - 10-13-2022 08:07 AM Hi (small update) Here's my take, You could solve it by using Cramer's Rule x = (DET [[ 0 2K], [2 -8]]) / (DET [[7 2K], [3K -8]] ) y = (DET [[ 7 0], [3K 2]]) / (DET [[7 2K], [3K -8]] ) rewrite it using SYST2MAT [[7x 2Ky] [ x [3Kx -8y=2]] y ] SYST2MAT then thus M [ 'x' 'y'] -> x y << SYST2MAT ->COL DROP -> C1 C2 C0 << C0 C2 2 COL-> DET C1 C2 2 COL-> DET / C1 C0 2 COL-> DET C1 C2 2 COL-> DET / >> >> which gives X = -4k/(6 K^2 + 56) Y = 14/(6 K^2 + 56) br Gjermund RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - Marco Polo - 10-13-2022 08:23 AM (10-12-2022 11:16 PM)felipeek Wrote: For example, I wanna solve the following linear system: Yes. LINSOLVE command Cheers RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - Gjermund Skailand - 10-13-2022 08:44 AM Thanks, seems I too need to read the manual from time to time. br Gjermund RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - Marco Polo - 10-13-2022 12:16 PM (10-13-2022 08:44 AM)Gjermund Skailand Wrote: Thanks,The 50g is so rich of features that it is almost impossible to find a user who uses all. :-) RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - felipeek - 10-14-2022 05:21 PM Thanks Gjermund and Marco for the responses. @Marco: could you give an example of how can I input an unknown variable in LINSYS command? The way I usually input a linear system is via "NUM.SLV -> Solve lin sys..." and then inputing the matrix there. However, when I try to input an undefined variable, I receive an error. What would be the correct way to do it? Thanks! RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - Marco Polo - 10-17-2022 01:22 PM (10-14-2022 05:21 PM)felipeek Wrote: Thanks Gjermund and Marco for the responses.I am not sure about what you are trying to do. If you refer to the system in the first message, you cannot solve it numerically but you need to use LINSOLVE, which is a CAS command and can be reached via S.SOLV (White Shift + 7). To input a variable or an expression in a matrix using Matrix Writer you shall use the symbol ', i.e. 'X' RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - ijabbott - 10-17-2022 05:32 PM In RPN, you can set stack level 2 to a vector containing the equations, and stack level 1 to a vector containing the variables to solve for, then use LINSOLVE (on the S.SLV menu): Code: ['7*X+2*K*Y=0' '3*K*X-8*Y=2'] You should end up with 3 items on the stack: Code: { [ '7×X+2×K×Y=0' '3×K×X-8×Y=2' ] [ 'X' 'Y' ] } The bottom line is the answer for 'X' and 'Y' in terms of 'K'. (I'm not sure what the 'Specific' line means.) This is equivalent to Gjermund Skailand's answer. The only difference is that the unknown 'K' has opposite sign. [EDIT: Actually that means that they are not equivalent. Substituting Gjermund's result into '3kx-8y=2' results in '-2=2'. What's going on?] RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - ijabbott - 10-17-2022 06:38 PM You can also divide a vector by a square matrix. Really, it multiplies by the inverse of the matrix. 1. Put the right hand side on the stack as a 2x1 matrix: Code: [[0] [2]] 2. Put the X and Y coefficients on the stack as a 2x2 matrix: Code: [[7 '2*K'] ['3*K' -8]] 3. Divide. Result is a 2x1 matrix. The first row is X, the second row is Y: Code: [[ '2*K/(3*K^2+28)' ] (I don't know why it doesn't factor out the 2 from the numerator and denominator for the 2nd row.) RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - felipeek - 10-17-2022 11:25 PM Thank you all for the responses. I tested all methods and they all work fine! My preferred method at the moment is the last one posted by @ijabbott. I think it is easier than using LINSOLVE directly since I don't need to explicitly define that I want to solve for X and Y (in this case). Also, the output is shown in a 'prettier' way. The only thing that bothers me is that I was only able to make it work in RPN mode. I tried dividing the matrices in algebric mode, but it doesn't work even though I see the matrices are being correctly recognized (even when the matrices contain only numbers). I don't use RPN very often so for now I will mostly be tweaking modes, but I assume there must be a way to do the same in ALG mode. Do you have any hints? Thanks!! Really appreciate it. RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - ijabbott - 10-18-2022 07:43 AM (10-17-2022 11:25 PM)felipeek Wrote: I don't use RPN very often so for now I will mostly be tweaking modes, but I assume there must be a way to do the same in ALG mode. Do you have any hints? You do not need the quotes in ALG mode, but do need commas between elements of a row, so this should work: Code: [[0][2]]/[[7,2*K][3*K,-8]] It works for me! RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - felipeek - 10-19-2022 03:47 PM Works like a charm @ ijabbott! Thank you! RE: [hp50g] is it possible to solve linear systems with unknown variables in it? - ObiWanKenobi - 10-23-2022 04:37 AM (10-17-2022 06:38 PM)ijabbott Wrote: My output is Code: [[ '0.3333*K/(K^2+9.3333)' ] Do anyone know which flag is reponsible for this? |