>What is EOF Short for End-Of-File, EOF is a code placed by a computer after a file's last byte of data. EOF marks are helpful in data transmission and storage. Files are stored in blocks, and the end marker helps the computer know it has allocated enough space to store the file.
The EOF is commonly represented by pressing and holding CTRL and pressing Z in DOS and OS/2 or pressing and holding CTRL and pressing D in Unix.
No fuck you. I hate doing systems of equations on paper, I'm not gonna spend all afternoon writing your fucking homework.
Levi Clark
How did you pass year 10?
Daniel Moore
idk lol
i never even took trig
Christian Reed
Next /dpc/ will be on trig
Aaron Turner
wrong. 1, 3, and 5 should have the variable z, otherwise the question you're posing makes no sense (how can you output a three variable solution when you're only using two variables?).
Really, you've poorly defined the question. You should translate it like this:
1,2,3,4 translates to
1x+2y+3z+4=0
This whole eof thing is silly too and this is a poor way of implementing it into a problem to teach it to people. arguments should be sent to main or read from the input stream, no EOF is necessary (barring file reading), nor are commas, as that's up to your implementation choice.
Lincoln Wright
I do like the idea of /dpc/ being a thing though, provided you're actually not just a bitch who can't do easy cs problems and is tryign to get g to do your homework
Aiden Morales
oh yes
4,-3,1,-10,EOF 2,1,3,0,EOF -1,2,-5,17,EOF
translates to
4x-3y+z=-10 2x+y+3z=0 -x+2-5z=17
So the answer is: (x,y,z) = (1,4,-2)
Christian Jones
Hey OP I'll play ball if you can explain how to solve systems of equations with matrices.
The example you posted introduces the number 17 out of nowhere, what the fuck.
Chase Evans
Step 1: write system of equations in AX=B form Step 2: look up and code how to inverse a matrix Step 3: multiply inverse of A by B to get all X values
>Gaussian elimination I'd love to see an algorithm for that
Joshua Russell
Correction to my methods: Step 1: write system of equations in AX=B form Step 2: look up and code how to check determinants of matrices, if determinant not equal to 0: inverse matrix. Step 3: look up and code how to inverse a matrix Step 3: multiply inverse of A by B to get all X values
int main() { vector3_t x, y, z, r; scanf("%lf,%lf,%lf,%lf, ", &x[0], &y[0], &z[0], &r[0]); scanf("%lf,%lf,%lf,%lf, ", &x[1], &y[1], &z[1], &r[1]); scanf("%lf,%lf,%lf,%lf, ", &x[2], &y[2], &z[2], &r[2]); double da = det(x, y, z); if (da == 0) printf("cannot solve\n"); else printf("(%lf,%lf,%lf)\n", det(r, y, z)/da, det(x, r, z)/da, det(x, y, r)/da); }
Dylan Thompson
completely unnecessary in this use case. For example in C++ you can designate the delim character, so why the hell would you make the user type EOF (in whatever incarnation that takes in your operating system) when you #1 aren't using a file #2 are separating your inputs into three chunks.
It's a bad use case for EOF and concepts should be taught in use cases where they shine (provided said cases aren't extremely complex)
Grayson Bell
Do I win?
int det3(int mat[3][4]) { /* get 2x2 matrix determinants */ unsigned i, j, r, x = 0, det = 0; for (r = 0; r < 3; r++) /* current row */ { unsigned a[4], idx = 0; for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) if (r != i && r != j) a[idx++] = mat[i][j]; int neg = (r == 1) ? -1 : 1; det += neg * (mat[r][x++] * ((a[0] * a[3]) - (a[1] * a[2]))); } return det; }
struct int3 systemofeq(int m[3][4]) { int d[3], det = det3(m); unsigned i, j; for (i = 0; i < 3; i++) { int z[3][4]; unsigned k, l; for (k = 0; k < 3; k++) /* copy */ for (l = 0; l < 4; l++) z[k][l] = m[k][l]; for (j = 0; j < 3; j++) /* overwrite */ z[j][i] = m[j][3]; d[i] = det3(z); } struct int3 ans = { det / d[0], det / d[1], det / d[2] }; return ans; }
Jaxon Gutierrez
There are times I wish I didn't drop out of college. This is one of them.
Mason Williams
No it's ok. Knowing how to solve a system of equations is pretty useless in the real world.
Elijah Mitchell
kek
Blake Brown
import numpy as np
inp = np.zeros((3, 4)) for i in range(3): inp[i, :] = eval(input())
mat = inp[:, :3] vec = inp[:, 3]
np.linalg.solve(mat, vec)
Juan Allen
[spoiler] bump [/spoiler]
Gavin Bailey
Is this feels like cheating... with Ada.Numerics.Generic_Real_Arrays; with Ada.Text_IO; use Ada.Text_IO;
procedure System_of_Equations is package RA is new Ada.Numerics.Generic_Real_Arrays(Long_Float); use type RA.Real_Matrix; use type RA.Real_Vector; package Float_IO is new Ada.Text_IO.Float_IO(Long_Float);
Lack of real matrix libraries isn't going stop ME from wasting my time solving the general case.
William Peterson
Gaussian elimination.
gauss1 :: (Eq a, Fractional a) => [[a]] -> [[a]] gauss1 m | length m [a] gauss2 m | length m == 1 = [(m!!0!!1)/(m!!0!!0)] | otherwise = [newsolution] ++ solutions where solutions = gauss2 [[m!!i!!j | j 0] | i 0] newsolution = ((m!!0!!(cols-1)) - sum [(m!!0!!j)*(solutions!!(j-1)) | j
Jack Butler
You must not get those retarded FB posts that are basically linear algebra problems in picture form, or you've never been in a high paying field where applied math is the core of everything you do.
Kayden Sanchez
Nice
Problem is, that code is barely readable since I am not accustomed to functional programming
Brandon Morgan
I bet it's terrible for those who are accustomed too, I just wanted it to work.