summaryrefslogtreecommitdiff
path: root/Chemistry_by_R_Chang/15-Acids_and_Bases.ipynb
blob: 42c11d192ddb8afaf5ef22fd6383353db8836570 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
{
"cells": [
 {
		   "cell_type": "markdown",
	   "metadata": {},
	   "source": [
       "# Chapter 15: Acids and Bases"
	   ]
	},
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.10: Computation_of_pH_for_weak_base_of_given_molarity.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Computation of pH for weak base of given molarity\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.10\n');\n",
"\n",
"InitNH3=0.4;//Initial concentration of NH3 solution, M\n",
"\n",
"//Let 'x' be the equilibrium concentration of the [OH-] and [NH4+] ions, M\n",
"\n",
"Kb=1.8*10^-5;//ionisation constant of NH3, M\n",
"x=sqrt(Kb*InitNH3);//from the definition of ionisation constant Kb=[OH-]*[NH4+]/[NH3]=x*x/(InitNH3-x), which reduces to x*x/InitNH3, as x<<InitNH3 (approximation)\n",
"\n",
"approx=x/InitNH3*100;//this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value\n",
"\n",
"if(approx>5)\n",
"     x1=(-Kb+sqrt((Kb^2)-(-4*1*Kb*InitNH3)))/(2*1);\n",
"     x2=(-Kb-sqrt((Kb^2)-(-4*1*Kb*InitNH3)))/(2*1);\n",
"\n",
"    if(x1>0)//as only one root is positive\n",
"         x=x1;\n",
"    else \n",
"         x=x2;\n",
"    end\n",
"end;\n",
"\n",
"pOH=-log10(x);//since x is the conc. of [H+] ions\n",
"\n",
"pH=14-pOH;\n",
"\n",
"printf('\t the pH of the NH3 solution is : %4.2f \n',pH);\n",
"\n",
"\n",
"//End"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.11: Computation_of_concentration_of_all_the_species_in_solution_of_Oxalic_acid.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Computation of concentration of all the species in solution of Oxalic acid\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.11\n');\n",
"\n",
"InitC2H2O4=0.1;//Initial concentration of C2H2O4 solution, M\n",
"\n",
"//Let 'x1' be the equilibrium concentration of the [H+] and [C2HO4-] ions, M\n",
"\n",
"//First stage of ionisation\n",
"\n",
"Kw=10^-14;//ionic product of water, M^2\n",
"Ka1=6.5*10^-2;//ionisation constant of C2H2O4, M\n",
"x=sqrt(Ka1*InitC2H2O4);//from the definition of ionisation constant Ka1=[H+]*[C2HO4-]/[C2H2O4]=x*x/(InitC2H2O4-x), which reduces to x*x/InitC2H2O4, as x<<InitC2H2O4 (approximation)\n",
"\n",
"approx=x/InitC2H2O4*100;//this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value\n",
"\n",
"if(approx>5)\n",
"     x1=(-Ka1+sqrt((Ka1^2)-(-4*1*Ka1*InitC2H2O4)))/(2*1);\n",
"     x2=(-Ka1-sqrt((Ka1^2)-(-4*1*Ka1*InitC2H2O4)))/(2*1);\n",
"\n",
"    if(x1>0)//as only one root is positive\n",
"         x=x1;\n",
"    else \n",
"         x=x2;\n",
"    end\n",
"end;\n",
"C2H2O4=InitC2H2O4-x;//equilibrium value\n",
"printf('\t the concentration of the C2H2O4 in the solution is : %4.3f M\n',C2H2O4);\n",
"\n",
"\n",
"//Second stage of ionisation\n",
"\n",
"InitC2HO4=x;//concentration of C2HO4 from first stage of ionisation\n",
"\n",
"Ka2=6.1*10^-5;//ionisation constant of C2HO4-, M\n",
"\n",
"//Let 'y' be the concentration of the [C2HO4-] dissociated to form [H+] and [C2HO4-] ions, M\n",
"y=Ka2;//from the definition of ionisation constant Ka2=[H+]*[C2O4-2]/[C2HO4-]=(0.054+y)*y/(0.054-y), which reduces to y, as y<<InitC2HO4 (approximation)\n",
"\n",
"approx=y/InitC2HO4*100;//this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value\n",
"\n",
"if(approx>5)\n",
"     x1=(-Ka2+sqrt((Ka2^2)-(-4*1*Ka2*InitC2HO4)))/(2*1);\n",
"     x2=(-Ka2-sqrt((Ka2^2)-(-4*1*Ka2*InitC2HO4)))/(2*1);\n",
"\n",
"    if(x1>0)//as only one root is positive\n",
"         y=x1;\n",
"    else \n",
"         y=x2;\n",
"    end\n",
"end;\n",
"\n",
"C2HO4=InitC2HO4-y;//from first and second stages of ionisation\n",
"H=x+y;//from first and second stages of ionisation\n",
"C2O4=y;//from the assumption\n",
"OH=Kw/H;// From the formula (ionic product)Kw=[H+]*[OH-]\n",
"\n",
"printf('\t the concentration of the [C2HO4-] ion in the solution is : %4.3f M\n',C2HO4);\n",
"printf('\t the concentration of the [H+] ion in the solution is : %4.3f M\n',H);\n",
"printf('\t the concentration of the [C2O4-2] ion in the solution is : %4.1f*10^-5 M\n',C2O4*10^5);\n",
"printf('\t the concentration of the [OH-] ion in the solution is : %f*10^-13 M\n',OH*10^13);\n",
"\n",
"\n",
"//End"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.13: Computation_of_pH_for_a_solution_of_salt_of_weak_acid_and_strong_base.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Computation of pH for a solution of salt of weak acid and strong base\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.13\n');\n",
"\n",
"InitCH3COONa=0.15;//Initial concentration of CH3COONa solution, M\n",
"\n",
"InitCH3COO=InitCH3COONa;//concentration of [CH3COO-] ion after dissociation of CH3COONa solution, M\n",
"//Let 'x' be the equilibrium concentration of the [OH-] and [CH3COOH] ions after hydrolysis of [CH3COO-], M\n",
"\n",
"Kb=5.6*10^-10;//equilibrium constant of hydrolysis, M\n",
"\n",
"x=sqrt(Kb*InitCH3COO);//from the definition of ionisation constant Kb=[OH-]*[CH3COOH]/[CH3COO-]=x*x/(0.15-x), which reduces to x*x/0.15, as x<<0.15 (approximation)\n",
"\n",
"approx=x/InitCH3COO*100;//this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value\n",
"\n",
"if(approx>5)\n",
"     x1=(-Kb+sqrt((Kb^2)-(-4*1*Kb*InitCH3COO)))/(2*1);\n",
"     x2=(-Kb-sqrt((Kb^2)-(-4*1*Kb*InitCH3COO)))/(2*1);\n",
"\n",
"    if(x1>0)//as only one root is positive\n",
"         x=x1;\n",
"    else \n",
"         x=x2;\n",
"    end\n",
"end;\n",
"\n",
"pOH=-log10(x);//since x is the conc. of [OH-] ions\n",
"pH=14-pOH;\n",
"\n",
"printf('\t the pH of the salt solution is : %4.2f \n',pH);\n",
"\n",
"percenthydrolysis=x/InitCH3COO*100;\n",
"printf('\t the percentage of hydrolysis of the salt solution is : %5.4f percent\n',percenthydrolysis);\n",
"\n",
"//End"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.2: computation_of_hydronium_ion_concentration_from_hydroxide_ion_concentration.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// computation of [H+] ion concentration from [OH-] ion concentration\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.2\n');\n",
"\n",
"OH=0.0025 ;// [OH-] ion concentration, M\n",
"Kw=1*10^-14 ;// ionic product of water, M^2\n",
"\n",
"H=Kw/OH; // From the formula (ionic product)Kw=[H+]*[OH-]\n",
"printf('\t The [H+] ion concentration of the solution is : %3.1f*10^-12 M\n',H*10^12);\n",
"\n",
"//end"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.3: Computation_of_pH_of_a_solution_from_hydonium_ion_concentration.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Computation of pH of a solution from [H+] ion concentration\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.3\n');\n",
"\n",
"H1=3.2*10^-4; //Concentration of [H+] ion on first occasion, M\n",
"\n",
"pH1=-log10(H1);//from the definition of pH\n",
"printf('\t pH of the solution on first occasion is: %4.2f \n',pH1);\n",
"\n",
"H2=1*10^-3; //Concentration of [H+] ion on second occasion, M\n",
"\n",
"pH2=-log10(H2);//from the definition of pH\n",
"printf('\t pH of the solution on second occasion is : %4.2f \n',pH2);\n",
"\n",
"//End"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.4: Computation_of_hydronium_ion_concentration_from_pH.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Computation of [H+] ion concentration from pH\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.4\n');\n",
"\n",
"pH=4.82;//Given\n",
"H=10^(-pH);//Concentration of [H+] ion, M, formula from the definition of pH\n",
"\n",
"printf('\t The [H+] ion concentration of the solution is : %3.1f*10^-5 M\n',H*10^5);\n",
"\n",
"\n",
"//End"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.5: Computation_of_pH_of_a_solution_from_hydroxide_ion_concentration.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Computation of pH of a solution from [OH-] ion concentration\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.5\n');\n",
"\n",
"OH=2.9*10^-4;//Concentration of [OH-] ion, M\n",
"\n",
"pOH=-log10(OH);//by definition of p(OH)\n",
"\n",
"pH=14-pOH;\n",
"\n",
"printf('\t the pH of the solution is : %4.2f \n',pH);\n",
"\n",
"//End"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.6: Computation_of_pH_of_solutions_for_solutions_of_given_concentrations.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Computation of pH of solutions for solutions of given concentrations\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.6\n');\n",
"\n",
"//for HCL solution\n",
"\n",
"ConcHCl=1*10^-3;//Concentration of HCl solution, M\n",
"H=ConcHCl;//Concentration of [H+] ion after ionisation of HCl\n",
"pH=-log10(H);\n",
"printf('\t the pH of the HCl solution is : %4.2f \n',pH);\n",
"\n",
"//for Ba(OH)2 solution\n",
"\n",
"ConcBaOH2=0.02;//Concentration of Ba(OH)2 solution, M\n",
"OH=ConcBaOH2*2;//Concentration of [OH-] ion after ionisation of Ba(OH)2 as two ions are generated per one molecule of Ba(OH)2\n",
"pOH=-log10(OH);\n",
"pH2=14-pOH;\n",
"printf('\t the pH of the Ba(OH)2 solution is : %4.2f \n',pH2);\n",
"\n",
"//End"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.8: Computation_of_pH_for_weak_acid.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Computation of pH for weak acid\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.8\n');\n",
"\n",
"InitHNO2=0.036;//Initial concentration of HNO2 solution, M\n",
"\n",
"//Let 'x' be the equilibrium concentration of the [H+] and [NO2-] ions, M\n",
"\n",
"Ka=4.5*10^-4;//ionisation constant of HNO2, M\n",
"x=sqrt(Ka*InitHNO2);//from the definition of ionisation constant Ka=[H+]*[NO2-]/[HNO2]=x*x/(0.036-x), which reduces to x*x/0.036, as x<<InitHNO2 (approximation)\n",
"\n",
"approx=x/InitHNO2*100;//this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value\n",
"\n",
"if(approx>5)\n",
"     x1=(-Ka+sqrt((Ka^2)-(-4*1*Ka*InitHNO2)))/(2*1);\n",
"     x2=(-Ka-sqrt((Ka^2)-(-4*1*Ka*InitHNO2)))/(2*1);\n",
"\n",
"    if(x1>0)//as only one root is positive\n",
"         x=x1;\n",
"    else \n",
"         x=x2;\n",
"    end\n",
"end;\n",
"\n",
"pH=-log10(x);//since x is the conc. of [H+] ions\n",
"\n",
"printf('\t the pH of the HNO2 solution is : %4.2f \n',pH);\n",
"\n",
"\n",
"//End"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 15.9: Computation_of_ionisation_constant_from_pH_of_a_weak_acid.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Computation of ionisation constant from pH of a weak acid\n",
"\n",
"clear;\n",
"clc;\n",
"\n",
"printf('\t Example 15.9\n');\n",
"\n",
"pH=2.39;// pH of the HCOOH acid solution\n",
"\n",
"InitHCOOH=0.1;//initial concentration of the solution\n",
"H=10^(-pH);//[H+] ion concentration from the definition of pH, M\n",
"\n",
"Ka=(H^2)/(InitHCOOH-H);//ionisation constant of the acid, M, Ka=[H+]*[HCOO-]/[HCOOH]\n",
"\n",
"printf('\t the ionisation constant of the given solution is : %4.2f*10^-4 M \n',10^4*Ka);\n",
"\n",
"//End"
   ]
   }
],
"metadata": {
		  "kernelspec": {
		   "display_name": "Scilab",
		   "language": "scilab",
		   "name": "scilab"
		  },
		  "language_info": {
		   "file_extension": ".sce",
		   "help_links": [
			{
			 "text": "MetaKernel Magics",
			 "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
			}
		   ],
		   "mimetype": "text/x-octave",
		   "name": "scilab",
		   "version": "0.7.1"
		  }
		 },
		 "nbformat": 4,
		 "nbformat_minor": 0
}