473,761 Members | 3,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

20 New Member
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 3207
JosAH
11,448 Recognized Expert MVP
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
4256
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 equations than variables, the system should effectively set undefined variables to 0
2
1438
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 ? The main problem is next: the main rare matrix of the system is in the common form, but not in the special (non triangular, non symmetric, ...). That's why many methods for such systems is unusual. Because of being rare, matrix can be huge,...
15
2201
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 them, using LMSE linear regression. Simple enough. I thought instead of looking up the formulas I'd just see if there isn't a NumPy function that does exactly this. What I found was "linear_least_squares", but I can't figure out what kind of...
4
9356
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
1084
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
4112
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 y-intercept. Can anyone tell me how to set up the linear equation in java. if (Global.psize == 1)//Check If Line Should Be Graphed { Global.slope = x1i2; Global.yinter = y1i2; Global.yinter = Global.y1i1;// b=y For First Point On y Axis....
2
6658
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, how would I include the scanf( "%d", &choice ); in the function definition for it to run right. It runs right without it, but I need it in there. #include <stdio.h> void displayMessage(); int hasSolution(double a, double b, double...
2
2110
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 different alternatives to simulate a chemical process with a number of unit operations (heat exchangers, chemical reactors and so on). There are some commercial products (such as Hysys) that do this,
4
4881
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 motor, I have to program it in C because I will use a DSP (ADSP21062) in order to control the torque of the motor. I've read a little bit, and I think that I have to solve the equations using numerical methods, but there a lot of them, and It could be...
0
9554
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9989
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.