473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C++ Experts please help: Solving for X & linear equations with C++??

Hello everyone. I got a assignment that states.

The set of linear equations
a11X1 = a12X2 = c1
a21X1 = a22X2 = c2

May be solved using Cramer’s rule:
X1 = c1a22 – c2a12
a11a22 – a12a21

X2 = c2a11 – c1a21
A11a22 – a12a21

Use these equations to design, write, compile, execute and debug a program that will solve for X1 and X2 in the following equations.

3X1 + 4X2 = 40
5X1 = 2X2 = 34

Alright the question I have is how do begin? I'm new to the whole program and I have to admit I don't have the slightest clue what to do. This what I've got so far and I don't know where to go from here:

#include <iostream>
using namespace std;


int main()
{
double float,
return 0;
}

:-/

BTW, I use Visual C++ 2008 Express Edition if that matters.

Someone please help me. Thanks in advance.
Sep 10 '08 #1
1 3180
JosAH
11,448 Expert 8TB
If you have a 2x2 matrix and a vector (arrray) with two elements
you have to write the following functions:

Expand|Select|Wrap|Line Numbers
  1. double a[2][2]; /* the matrix */
  2. double c[2]; /* the rhs vector */
  3. ...
  4. void swap(int index);
  5. double det();
  6.  
The swap function swaps column 'index' with vector c and the det
function calculates the determinant of matrix a. On top of that
you need a bit of code to read the matrix and vector values
and print some results.

kind regards,

Jos
Sep 10 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Guenther Sohler | last post by:
I am looking for a apropriate c library to solve my sparse linear equation system. I have n variables and m equations. m might be less, equal or greater then n!!!! If there are less...
2
by: Anatoly | last post by:
Hi All !!! Can anyone give me link to the C++ source or to the compiled program unit (compatible with Microsoft VC++), designed for the solving of the algebraic linear systems with rare matrices...
15
by: nikie | last post by:
I'm a little bit stuck with NumPy here, and neither the docs nor trial&error seems to lead me anywhere: I've got a set of data points (x/y-coordinates) and want to fit a straight line through...
4
by: Thomas | last post by:
Hi, I've to solve a system of linear equations and inequations in C++. Are there (free) librarys for that topic? Regards, Thomas
3
by: mano | last post by:
Hello.... Can anybody give me some idea ... How to write programs on (...(In C++)) Gauss elimination LU Decomposition finding Inverse Thanks
7
by: Bigs | last post by:
Ok, I have been working on a Linear Equation program that will draw a line on my graph. But, I am not sure how to set up the y=mx+b in Java to return the (x1,y1) and (x2, y2) using only the slope and...
2
by: company1484 | last post by:
This program calculates the solution (x,y) of a system of linear equations in 2 variables. This is my third C programming assignment so be gentle. problem: 1)on my int menu() function definition,...
2
by: Federico Zenith | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello everybody, I am looking into a problem that probably someone had before, so I hope I can avoid reinventing the wheel... I am looking into...
4
by: sdufoo | last post by:
Hallo guys, I have to solve a system of Differential equations: http://picasaweb.google.de/sdufoo/EcuacionesDiferenciales02/photo#5228386949051570594 these are the equations of an induction...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.