Help Balance Chemical Equations with Java

  • Context: Java 
  • Thread starter Thread starter benzun_1999
  • Start date Start date
  • Tags Tags
    Logic
Click For Summary

Discussion Overview

The discussion revolves around the challenge of balancing chemical equations using Java programming. Participants explore different approaches and logic to implement this functionality in code, while also addressing the underlying chemistry concepts involved in balancing equations.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant requests logic for balancing chemical equations in Java, expressing difficulty in implementing the functionality.
  • Another participant emphasizes that balancing equations is fundamentally a problem of linear equations and trial-and-error.
  • A specific example is provided, illustrating how to assign multipliers to each component of a chemical equation and equate coefficients to find integer solutions.
  • Some participants express confusion about the chemistry involved, particularly regarding nomenclature and the interpretation of chemical reactions.
  • There is a discussion about the importance of understanding the final balanced equation versus the initial unbalanced equation.
  • One participant suggests that the original poster is seeking a method to determine the necessary amounts of reactants to achieve a desired product.
  • Another participant comments that balancing is straightforward, while others challenge this view by questioning the clarity of the example provided.

Areas of Agreement / Disagreement

Participants express varying levels of understanding regarding the chemistry involved in balancing equations. Some agree on the mathematical approach, while others find the chemistry concepts confusing, leading to a lack of consensus on the clarity of the examples discussed.

Contextual Notes

Participants highlight potential confusion stemming from chemical nomenclature and the need for clarity in the representation of chemical reactions. There are unresolved questions about the interpretation of specific examples and the steps involved in balancing equations.

benzun_1999
Messages
260
Reaction score
0
Hi guys
Can u guys pls give me a logic to balance cheical euations. I have done some work in java but am unable to get any balancing equation logic. Can anyone tell me how to make computer perform some fuction in a specific order using Java
 
Technology news on Phys.org
Hello,

Is'int there someone to help me. pls i need help. i am desperate.
-Benzun
 
How many computer-oriented people understand how to equate chemical balance? Personally I couldn't wrap my brain around it. I can grasp the physics, but the actual calculations might as well be in sanskrit for all the good they do for me.
 
This is more of a linear equations/trial-and-error problem then anything else.

Let's take a simple example:

Cu + O2 ----> Cu2O

1) Give each portion of the equation a unique multiplier

X1*Cu + X2*O2 ---> X3*Cu2O

2) Equate same elements

X1*Cu = X3*Cu2
X2*O2 = X3*O

3)Bring subscript to front

X1*Cu = 2*X3*Cu
2*X2*O = X3*O

4) Equate Cofficients

X1 = 2*X3
2*X2 = X3

5) Select a variable, say X3, and equate it to 1. Sove for other cofficients. Are all the cofficients integers? No? Try X3=2. Are all the cofficients integers? Yes? X1 = 4, X2=1, X3=2

Solution:

4Cu + O2 ----> 2Cu2O

Hint: Your definitely going to use arrays to store the equation cofficients.
 
Last edited:
Dngrsone ----> head explodey
 
If there is anything confusing about chemistry it is definitely nomenclature. Balancing is easy.
 
dduardo said:
If there is anything confusing about chemistry it is definitely nomenclature. Balancing is easy.

If that's so, then what happened to the other two copper atoms in the last equation?
 
Last edited:
What do you mean? The 4 copper atoms are combining with the O2 molecule to create 2 Copper (I) Oxide molecules.

Copper (I) Oxide: Cu -- O -- Cu
 
Last edited:
Okay, I can see the sense in that, but now your first example looks wrong-- I see one copper atom and an O2 molecule becoming a Copper Oxide molecule
 
  • #10
That's why it is called an unbalanced equation to start with. The reaction couldn't happen otherwise. The final solution is what you need to make the reaction happen.

Let me put it this way: Say your making a cake with a gallon of milk and a tablespoon of cake mix. You know this combination is not going to work. Thats why you need to scale or "balance" the ingredients so that the cake does come out right.
 
Last edited:
  • #11
Okay... I see the equation now. So what the original poster wants is a way to figure out the amounts needed of each ingredint to produce the desired output?

Here I was thinking he wanted to know what happens when you combine two ingredients... getting all the valences, ionizations and all that crap straight and knowing how the chemicals will actually interact is what causes my head to go explody.
 
  • #12
Yeah, I think you where making the problem harder than it really is.
 

Similar threads

Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K