Roots of Equations in Scientific Contexts
Nikhilesh Sutradhar
September 24, 2025
Part 1
Roots of equations: (e.g., the volume of van der Waals gas and comparison with ideal gas, pH
of a weak acid). Practical
Part 1
In mathematics and science, finding the roots of an equation means finding the values of a
variable that make the equation true. For an equation formatted as f (x) = 0, the roots are the
specific values of *x* that satisfy the condition. These ”solutions” or ”zeros” are fundamental
to solving problems across various scientific disciplines. Here, we explore this concept using the
behavior of real gases and the chemistry of weak acids.
Volume of a Van der Waals Gas
To describe the behavior of gases, the Ideal Gas Law, P V = nRT , is often used as a simple
model. It assumes that gas particles have no volume and do not interact with each other.
However, real gases deviate from this ideal behavior, especially under high pressure or at low
temperature.
The van der Waals equation provides a more accurate model by introducing two correc-
tive parameters: ’a’ for intermolecular attractive forces and ’b’ for the volume occupied by the
gas molecules themselves.
The equation is:
an2
P + 2 (V − nb) = nRT
V
Where:
• P is pressure
• V is volume
• n is the number of moles
• R is the ideal gas constant
• T is temperature
• a and b are constants specific to the gas
1
To find the volume (V ) of a real gas under given conditions of pressure and temperature,
this equation must be solved. If we rearrange it into a polynomial form, it becomes a cubic
equation in terms of V :
2
abn3
3 nRT 2 an
V − nb + V + V − =0
P P P
Solving for the volume of the gas is now a problem of finding the roots of this cubic equation.
A cubic equation can have one or three real roots. In a gas-liquid transition region, these three
roots have physical significance: the largest root corresponds to the volume of the gas phase,
the smallest to the volume of the liquid phase, and the intermediate root represents an unstable
state.
Comparison: Ideal Gas vs. Van der Waals Gas
Feature Ideal Gas Van der Waals Gas (Real
Gas)
Particle Volume Assumed to be zero (point Particles have a finite, non-
masses). zero volume.
Intermolecular Forces No attractive or repulsive Accounts for attractive forces
forces between particles. between
particles.
an2
Governing Equation P V = nRT P+ V2
(V − nb) = nRT
Conditions Accurate at low pressure and More accurate across a wider
high temperature. range of pressures and tem-
peratures.
Solving for Volume Simple algebraic rearrange- Requires finding the roots of a
ment. cubic equation.
pH of a Weak Acid
Calculating the pH of a solution containing a weak acid is another excellent example of root
finding. A weak acid, represented as HA, only partially dissociates in water:
HA ⇌ H + + A−
The acid dissociation constant, Ka , describes the equilibrium of this reaction:
[H + ][A− ]
Ka =
[HA]
To find the hydrogen ion concentration, [H + ], and thus the pH (− log[H + ]), we can set up an
ICE (Initial, Change, Equilibrium) table. If the initial concentration of the acid is C, and the
amount that dissociates is x:
[HA] [H + ] [A− ]
Initial C 0 0
Change -x +x +x
Equilibrium C-x x x
Substituting the equilibrium concentrations into the Ka expression gives:
(x)(x) x2
Ka = =
C −x C −x
2
Rearranging this equation into the standard polynomial form (ax2 + bx + c = 0) yields a
quadratic equation:
x2 + K a x − K a C = 0
Here, x represents the equilibrium concentration of [H + ]. To find this value, we must find the
roots of this quadratic equation using the quadratic formula. The equation will yield two roots,
but only the positive root is chemically meaningful, as concentration cannot be a negative value.
Practical Applications
• Van der Waals Equation: This equation is crucial in chemical engineering and
thermodynamics. It is used to predict the conditions under which a gas will liquefy,
which is essential for the transportation and storage of gases like propane and natural gas.
• pH of Weak Acids: The ability to calculate the pH of weak acid solutions is fundamental
in numerous fields such as Biochemistry (blood buffer system), Pharmacology (drug
absorption), Food Science (preservatives), and Environmental Chemistry (acid rain).
This video explains the deviations of real gases from ideal behavior: Real gases and the van der
Waals equation.
3
Part 2
In BASIC Program
1. pH of a Weak Acid
This program solves the quadratic equation x2 + Ka x − Ka C = 0 to find the hydrogen ion
concentration [H + ] and the corresponding pH.
1 CLS
2 PRINT " pH Calculator for a Weak Acid "
3 PRINT " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
4
5 ’--- User Input ---
6 INPUT " Enter initial acid concentration (C in mol /L): ", C
7 INPUT " Enter acid dissociation constant ( Ka ): ", Ka
8
9 ’--- Solve the quadratic equation : x ˆ2 + Ka *x - Ka *C = 0 ---
10 ’ where a =1 , b=Ka , c=- Ka *C
11 A = 1
12 B = Ka
13 C_coeff = -Ka * C
14
15 ’--- Calculate the discriminant ---
16 discriminant = B ˆ2 - 4 * A * C_coeff
17
18 ’--- Check for valid roots ---
19 IF discriminant < 0 THEN
20 PRINT " Error : No real solution exists ."
21 ELSE
22 ’--- Calculate the two roots ---
23 root1 = (-B + SQR ( discriminant )) / (2 * A)
24 root2 = (-B - SQR ( discriminant )) / (2 * A)
25
26 ’--- The positive root is the physically meaningful one ---
27 IF root1 > 0 THEN
28 H_conc = root1
29 ELSE
30 H_conc = root2
31 END IF
32
33 ’--- Calculate pH ( LOG is natural log , convert to base 10) ---
34 pH = - LOG ( H_conc ) / LOG (10)
35
36 ’--- Display the results ---
37 PRINT
38 PRINT " Results :"
39 PRINT "[ H +] Concentration = "; H_conc ; " mol /L"
40 PRINT " pH = "; pH
41 END IF
42
43 END
Listing 1: pH Calculator for a Weak Acid
2. Volume of a Van der Waals Gas
This program uses the Newton-Raphson method to quickly approximate the volume of the
gas.
4
1 CLS
2 PRINT " Van der Waals Gas Volume Calculator ( using Newton - Raphson method )"
3 PRINT " - - - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - -- - - -- - - -- -"
4
5 ’--- Constants for Carbon Dioxide ( CO2 ) ---
6 ’--- Using L - atm - mol -K units for this example ---
7 a = 3.592 ’ L ˆ2* atm / mol ˆ2
8 b = 0.04267 ’ L/ mol
9 R = 0.08206 ’ L* atm /( mol *K)
10
11 PRINT " Using constants for Carbon Dioxide ( CO2 )"
12 PRINT
13
14 ’--- User Input ---
15 INPUT " Enter moles of gas (n): ", n
16 INPUT " Enter temperature (T in Kelvin ): ", T
17 INPUT " Enter pressure (P in atm ): ", P
18
19 ’--- Initial guess for Volume V using the Ideal Gas Law ---
20 V = ( n * R * T) / P
21 PRINT " Initial guess ( from Ideal Gas Law ): V ="; V; "L"
22 PRINT
23
24 ’--- Newton - Raphson Iteration ---
25 PRINT " Finding root ..."
26 FOR i = 1 TO 20 ’ 20 iterations is usually more than enough
27 ’ f ( V ) = (P + a*n ˆ2/ V ˆ2) *( V - n*b) - n*R*T
28 fV = ( P + a * n ˆ2 / (V ˆ2) ) * (V - n * b) - n * R * T
29
30 ’ f ’( V ) = Derivative of f(V) with respect to V
31 ’ f ’( V ) = P - a*n ˆ2/ V ˆ2 + 2* a*b*n ˆ3/ V ˆ3
32 fV_prime = P - (a * n ˆ2 / (V ˆ2) ) + (2 * a * b * n ˆ3 / (V ˆ3) )
33
34 ’ Check for division by zero
35 IF fV_prime = 0 THEN
36 PRINT " Error : Derivative is zero . Cannot continue ."
37 END
38 END IF
39
40 ’ Newton ’s formula : V_new = V_old - f(V)/f ’( V)
41 V = V - ( fV / fV_prime )
42 NEXT i
43
44 ’--- Display Final Result ---
45 PRINT
46 PRINT " Calculation Complete ."
47 PRINT " The volume of the real gas is approximately : "; V; " L"
48
49 END
Listing 2: Van der Waals Gas Volume Calculator
5
Part 3
1. pH of a Weak Acid
The Program
1 CLS
2 PRINT " pH Calculator for a Weak Acid "
3 PRINT " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
4
5 ’--- User Input ---
6 INPUT " Enter initial acid concentration (C in mol /L): ", C
7 INPUT " Enter acid dissociation constant ( Ka ): ", Ka
8
9 ’--- Solve the quadratic equation : x ˆ2 + Ka *x - Ka *C = 0 ---
10 A = 1
11 B = Ka
12 C_coeff = -Ka * C
13 discriminant = B ˆ2 - 4 * A * C_coeff
14
15 IF discriminant < 0 THEN
16 PRINT " Error : No real solution exists ."
17 ELSE
18 root1 = (-B + SQR ( discriminant )) / (2 * A)
19 root2 = (-B - SQR ( discriminant )) / (2 * A)
20 IF root1 > 0 THEN
21 H_conc = root1
22 ELSE
23 H_conc = root2
24 END IF
25 pH = - LOG ( H_conc ) / LOG (10)
26 PRINT
27 PRINT " Results :"
28 PRINT "[ H +] Concentration = "; H_conc ; " mol /L"
29 PRINT " pH = "; pH
30 END IF
31 END
Listing 3: pH Calculator for a Weak Acid
Sample Run
Let’s calculate the pH of a 0.1 M solution of acetic acid, which has a Ka of 1.8 × 10−5 .
Input:
Enter initial acid concentration (C in mol/L): 0.1
Enter acid dissociation constant (Ka): 1.8e-5
Output:
Results:
[H+] Concentration = 1.33267E-03 mol/L
pH = 2.875258
2. Volume of a Van der Waals Gas
The Program
6
1 CLS
2 PRINT " Van der Waals Gas Volume Calculator ( using Newton - Raphson method )"
3 PRINT " - - - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - -- - - -- - - -- -"
4 ’--- Constants for Carbon Dioxide ( CO2 ) ---
5 a = 3.592 ’ L ˆ2* atm / mol ˆ2
6 b = 0.04267 ’ L/ mol
7 R = 0.08206 ’ L* atm /( mol *K)
8 PRINT " Using constants for Carbon Dioxide ( CO2 )"
9 PRINT
10 ’--- User Input ---
11 INPUT " Enter moles of gas (n): ", n
12 INPUT " Enter temperature (T in Kelvin ): ", T
13 INPUT " Enter pressure (P in atm ): ", P
14 ’--- Initial guess for Volume V using the Ideal Gas Law ---
15 V = ( n * R * T) / P
16 PRINT " Initial guess ( from Ideal Gas Law ): V ="; V; "L"
17 PRINT
18 ’--- Newton - Raphson Iteration ---
19 PRINT " Finding root ..."
20 FOR i = 1 TO 20
21 fV = ( P + a * n ˆ2 / (V ˆ2) ) * (V - n * b) - n * R * T
22 fV_prime = P - (a * n ˆ2 / (V ˆ2) ) + (2 * a * b * n ˆ3 / (V ˆ3) )
23 IF fV_prime = 0 THEN
24 PRINT " Error : Derivative is zero . Cannot continue ."
25 END
26 END IF
27 V = V - ( fV / fV_prime )
28 NEXT i
29 ’--- Display Final Result ---
30 PRINT
31 PRINT " Calculation Complete ."
32 PRINT " The volume of the real gas is approximately : "; V; " L"
33 END
Listing 4: Van der Waals Gas Volume Calculator
Sample Run
Let’s find the volume of 1 mole of CO gas at a temperature of 300 K and a pressure of 50 atm.
Input:
Enter moles of gas (n): 1
Enter temperature (T in Kelvin): 300
Enter pressure (P in atm): 50
Output:
Using constants for Carbon Dioxide (CO2)
Initial guess (from Ideal Gas Law): V = .49236 L
Finding root...
Calculation Complete.
The volume of the real gas is approximately: .3802148 L
As you can see, under these conditions, the real volume (0.38 L) is significantly smaller than
the volume predicted by the Ideal Gas Law (0.49 L).