Click here to Skip to main content
15,891,828 members
Home / Discussions / C#
   

C#

 
QuestionChemical Equation Balance Pin
stephen.darling20-Jul-11 7:54
stephen.darling20-Jul-11 7:54 
AnswerRe: Chemical Equation Balance Pin
Ian Shlasko20-Jul-11 8:07
Ian Shlasko20-Jul-11 8:07 
GeneralRe: Chemical Equation Balance Pin
stephen.darling20-Jul-11 8:11
stephen.darling20-Jul-11 8:11 
GeneralRe: Chemical Equation Balance Pin
Ian Shlasko20-Jul-11 8:25
Ian Shlasko20-Jul-11 8:25 
GeneralRe: Chemical Equation Balance Pin
secorbett21-Jul-11 2:34
secorbett21-Jul-11 2:34 
AnswerRe: Chemical Equation Balance Pin
Chris Losinger20-Jul-11 9:48
professionalChris Losinger20-Jul-11 9:48 
AnswerRe: Chemical Equation Balance Pin
Keith Barrow20-Jul-11 10:47
professionalKeith Barrow20-Jul-11 10:47 
GeneralRe: Chemical Equation Balance Pin
David198720-Jul-11 11:27
David198720-Jul-11 11:27 
No trial and error or inelegant algorithms are needed.
The problem can be solved by solving a system of linear equations, constructed like this:

As2S3 + HNO3 + H2O = H3AsO4 + H2SO4 + NO (unbalanced)
Should be turned into the system: (disclaimer: it was really quite late when I did this, so don't look at the numbers too closely the general principle should be sound though)
2 x0 + 0 x1 + 0 x2 - 1 x3 - 0 x4 - 0 x5 = 0  // for As
3 x0 + 0 x1 + 0 x2 - 0 x3 - 1 x4 - 0 x5 = 0  // for S
0 x0 + 1 x1 + 2 x2 - 3 x3 - 1 x4 - 0 x5 = 0  // for H
0 x0 + 1 x1 + 0 x2 - 0 x3 - 0 x4 - 1 x5 = 0  // for N
0 x0 + 3 x1 + 1 x2 - 4 x3 - 4 x4 - 1 x5 = 0  // for O

The variables correspond to how many times the molecule from the unbalanced equation is needed, the coefficients correspond to how many of the element are in the corresponding molecule.

If I did the math correctly, it gives:
3 As2S3 + 28 HNO3 + 4 H2O = 6 H3AsO4 + 9 H2SO4 + 28 NO

Does that help you any?
GeneralRe: Chemical Equation Balance Pin
Luc Pattyn20-Jul-11 14:31
sitebuilderLuc Pattyn20-Jul-11 14:31 
GeneralRe: Chemical Equation Balance Pin
Richard Andrew x6420-Jul-11 15:07
professionalRichard Andrew x6420-Jul-11 15:07 
GeneralRe: Chemical Equation Balance Pin
Luc Pattyn20-Jul-11 15:28
sitebuilderLuc Pattyn20-Jul-11 15:28 
GeneralRe: Chemical Equation Balance Pin
stephen.darling21-Jul-11 2:50
stephen.darling21-Jul-11 2:50 
GeneralRe: Chemical Equation Balance Pin
David198721-Jul-11 3:06
David198721-Jul-11 3:06 
GeneralRe: Chemical Equation Balance Pin
stephen.darling21-Jul-11 4:08
stephen.darling21-Jul-11 4:08 
AnswerRe: Chemical Equation Balance Pin
dasblinkenlight20-Jul-11 16:26
dasblinkenlight20-Jul-11 16:26 
GeneralRe: Chemical Equation Balance Pin
stephen.darling21-Jul-11 2:51
stephen.darling21-Jul-11 2:51 
AnswerRe: Chemical Equation Balance Pin
Ennis Ray Lynch, Jr.21-Jul-11 3:45
Ennis Ray Lynch, Jr.21-Jul-11 3:45 
QuestionO'Reilly Confused me on classes Pin
Herboren20-Jul-11 6:47
Herboren20-Jul-11 6:47 
AnswerRe: O'Reilly Confused me on classes Pin
PIEBALDconsult20-Jul-11 7:04
mvePIEBALDconsult20-Jul-11 7:04 
AnswerRe: O'Reilly Confused me on classes PinPopular
Richard MacCutchan20-Jul-11 7:05
mveRichard MacCutchan20-Jul-11 7:05 
GeneralRe: O'Reilly Confused me on classes Pin
Herboren20-Jul-11 7:07
Herboren20-Jul-11 7:07 
GeneralRe: O'Reilly Confused me on classes Pin
Richard MacCutchan20-Jul-11 7:34
mveRichard MacCutchan20-Jul-11 7:34 
QuestionLucene.Net: using NOT operator Pin
NarVish20-Jul-11 4:11
NarVish20-Jul-11 4:11 
AnswerRe: Lucene.Net: using NOT operator Pin
Dave Kreskowiak20-Jul-11 7:14
mveDave Kreskowiak20-Jul-11 7:14 
AnswerRe: Lucene.Net: using NOT operator Pin
dmoses4820-Jul-11 9:22
dmoses4820-Jul-11 9:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.