Mathematica Workshop Roushan
Section1
2+2
4
All in-buit function start with upper case letters-Plot,Integrate,etc...
Function Arguments go inside[...]
Lists/Ranges are given in {...}
Roushan
Range[- 10 , 10, 0.5]
{- 10., - 9.5, - 9., - 8.5, - 8., - 7.5, - 7., - 6.5, - 6., - 5.5, - 5.,
- 4.5, - 4., - 3.5, - 3., - 2.5, - 2., - 1.5, - 1., - 0.5, 0., 0.5, 1., 1.5, 2.,
2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6., 6.5, 7., 7.5, 8., 8.5, 9., 9.5, 10.}
Range[10]
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Join[{1, 2, 3, 4}, {a, b, c}]
{1, 2, 3, 4, a, b, c}
Join[Range[10], Range[5]]
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5}
List1 = Join[{1, 2, 3, 4}, {a, b, c}]
{1, 2, 3, 4, a, b, c}
List1[[5]]
a
List1[[3 ;; 7]]
{3, 4, a, b, c}
List1[[- 5]]
3
List1[[10]]
Part: Part 10 of {1, 2, 3, 4, a, b, c} does not exist.
{1, 2, 3, 4, a, b, c}〚10〛
Range[10]
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
2 roushan workshop .nb
Table[k, {k, 1, 10}]
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Table[{k, k ^ 2, k ^ 3}, {k, 1, 5}]
{{1, 1, 1}, {2, 4, 8}, {3, 9, 27}, {4, 16, 64}, {5, 25, 125}}
list2 = Table[{k, k ^ 2, k ^ 3}, {k, 1, 5}]
{{1, 1, 1}, {2, 4, 8}, {3, 9, 27}, {4, 16, 64}, {5, 25, 125}}
MatrixForm[list2]
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
list2[[4]]
{4, 16, 64}
list2[[All, 3]]
{1, 8, 27, 64, 125}
list2[[4, 2]]
16
Table[{k, k ^ 2, k ^ 3}, {k, 1, 5}][[4]]
{4, 16, 64}
Plot[Sin[x], {x, - 6, 6}]
1.0
0.5
-6 -4 -2 2 4 6
-0.5
-1.0
roushan workshop .nb 3
Plot[{Sin[x], Sin[2 x], Sin[3 x]}, {x, 0, 2 Pi}, PlotLegends "Expressions"]
1.0
0.5
sin(x)
sin(2 x)
1 2 3 4 5 6
sin(3 x)
-0.5
-1.0
Manipulate[Plot[Sin[freq * x], {x, - 6, 6}], {freq, 1, 10}]
CloudObject`Private`freq
1.0
0.5
-6 -4 -2 2 4 6
-0.5
-1.0
Plot3D[Sin[x + 2 y], {x, - 3, 3}, {y, - 3, 3}]
4 roushan workshop .nb
Manipulate[Plot3D[Sin[a * x + 2 * b * y], {x, - 3, 3}, {y, - 3, 3}], {a, 1, 3}, {b, 1, 2}]
CloudObject`Private`a
CloudObject`Private`b
ContourPlot[Sin[x + 2 y], {x, - 3, 3}, {y, - 3, 3}]
roushan workshop .nb 5
ContourPlot[x ^ 2 + y ^ 2 4, {x, - 3, 3}, {y, - 3, 3}]
3
-1
-2
-3
-3 -2 -1 0 1 2 3
Manipulate[ContourPlot[x ^ 2 + y ^ 2 k, {x, - 3, 3}, {y, - 3, 3}], {k, 1, 5}]
CloudObject`Private`k
-1
-2
-3
-3 -2 -1 0 1 2 3
6 roushan workshop .nb
ContourPlot[{x ^ 2 + y ^ 2 4, x + y 1}, {x, - 3, 3}, {y, - 3, 3}]
3
-1
-2
-3
-3 -2 -1 0 1 2 3
Manipulate[ContourPlot[{x ^ 2 + y ^ 2 k, x + y m}, {x, - 3, 3}, {y, - 3, 3}],
{k, 1, 5}, {m, - 3, 3}]
CloudObject`Private`k
CloudObject`Private`m
-1
-2
-3
-3 -2 -1 0 1 2 3
roushan workshop .nb 7
RegionPlot[x ^ 2 + y ^ 2 ≤ 4, {x, - 3, 3}, {y, - 3, 3}]
Manipulate[RegionPlot[{x ^ 2 + y ^ 2 <= k, x + y <= m}, {x, - 3, 3}, {y, - 3, 3}],
{k, 1, 5}, {m, - 3, 3}]
CloudObject`Private`k
CloudObject`Private`m
8 roushan workshop .nb
PolarPlot[{1, 1 + 1 / 10 Sin[10 t]}, {t, 0, 2 Pi}]
1.0
0.5
-1.0 -0.5 0.5 1.0
-0.5
-1.0
x x^2 3x 10
Randbetween[-5,5]
xlsdata = Import["C:\\Users\\roush\\Desktop\\rou.xlsx"]
{{{1., 1., 3., 10., 3., 17.}, {2., 4., 6., 10., - 4., 16.}, {3., 9., 9., 10., - 2., 26.},
{4., 16., 12., 10., - 4., 34.}, {5., 25., 15., 10., 4., 54.},
{6., 36., 18., 10., 1., 65.}, {7., 49., 21., 10., 2., 82.}, {8., 64., 24., 10., 4., 102.},
{9., 81., 27., 10., - 3., 115.}, {10., 100., 30., 10., - 4., 136.},
{11., 121., 33., 10., 1., 165.}, {12., 144., 36., 10., - 3., 187.},
{13., 169., 39., 10., 1., 219.}, {14., 196., 42., 10., 4., 252.},
{15., 225., 45., 10., - 4., 276.}, {16., 256., 48., 10., 1., 315.},
{17., 289., 51., 10., 2., 352.}, {18., 324., 54., 10., 2., 390.},
{19., 361., 57., 10., - 2., 426.}, {20., 400., 60., 10., 2., 472.}},
{{A, P, D}, {B, P, D}, {C, P, D}, {D, P, D}, {A, P, D}, {B, P, D}, {C, P, D}, {D, P, D},
{A, P, D}, {B, P, D}, {C, P, D}, {D, P, D}, {A, P, D}, {B, P, D}, {C, P, D}}}
roushan workshop .nb 9
dat1 = xlsdata[[1, All, {1, 2, 3, 4, 5, 6}]]
{{1., 1., 3., 10., 3., 17.}, {2., 4., 6., 10., - 4., 16.}, {3., 9., 9., 10., - 2., 26.},
{4., 16., 12., 10., - 4., 34.}, {5., 25., 15., 10., 4., 54.},
{6., 36., 18., 10., 1., 65.}, {7., 49., 21., 10., 2., 82.}, {8., 64., 24., 10., 4., 102.},
{9., 81., 27., 10., - 3., 115.}, {10., 100., 30., 10., - 4., 136.},
{11., 121., 33., 10., 1., 165.}, {12., 144., 36., 10., - 3., 187.},
{13., 169., 39., 10., 1., 219.}, {14., 196., 42., 10., 4., 252.},
{15., 225., 45., 10., - 4., 276.}, {16., 256., 48., 10., 1., 315.},
{17., 289., 51., 10., 2., 352.}, {18., 324., 54., 10., 2., 390.},
{19., 361., 57., 10., - 2., 426.}, {20., 400., 60., 10., 2., 472.}}
dat1 = xlsdata[[1, All, {1, 6}]]
{{1., 17.}, {2., 16.}, {3., 26.}, {4., 34.}, {5., 54.}, {6., 65.}, {7., 82.}, {8., 102.},
{9., 115.}, {10., 136.}, {11., 165.}, {12., 187.}, {13., 219.}, {14., 252.},
{15., 276.}, {16., 315.}, {17., 352.}, {18., 390.}, {19., 426.}, {20., 472.}}
lp = ListPlot[dat1]
400
300
200
100
5 10 15 20
c1+c2x+c3x^2
fit=linearmodelfit
fit = LinearModelFit[dat1, {x, x ^ 2}, x]
FittedModel 9.78158 + 2.96251 x + 1.00461 x2
Normal[fit]
9.78158 + 2.96251 x + 1.00461 x2
10 roushan workshop .nb
pf = Plot[Normal[fit], {x, 1, 20}]
400
300
200
100
5 10 15 20
Plot[Normal[fit]]
Plot9.781578947368216` + 2.9625085440875467` x + 1.0046138072453836` x2
Plot: Plot called with 1 argument; 2 arguments are expected.
Plot9.781578947368216` + 2.9625085440875467` x + 1.0046138072453836` x2 , lp, {x, 1, 20}
400
300
200
100
5 10 15 20
plt = Plot[fit[x], {x, 0, 20}, PlotStyle Dashed ]
400
300
200
100
5 10 15 20
roushan workshop .nb 11
Show[lp, Plt]
400
Show : Could not combine the graphics objects in Show200 , Plt.
300
100
5 10 15 20
400
300
Show200
100
, Plt
5 10 15 20
fit
FittedModel 9.78158 + 2.96251 x + 1.00461 x2
fit["Properties"]
{AdjustedRSquared, AIC, AICc, ANOVATable, ANOVATableDegreesOfFreedom,
ANOVATableEntries, ANOVATableFStatistics, ANOVATableMeanSquares,
ANOVATablePValues, ANOVATableSumsOfSquares, BasisFunctions, BetaDifferences,
BestFit, BestFitParameters, BIC, CatcherMatrix, CoefficientOfVariation,
CookDistances, CorrelationMatrix, CovarianceMatrix, CovarianceRatios, Data,
DesignMatrix, DurbinWatsonD, EigenstructureTable, EigenstructureTableEigenvalues,
EigenstructureTableEntries, EigenstructureTableIndexes, EigenstructureTablePartitions,
EstimatedVariance, FitDifferences, FitResiduals, Function, FVarianceRatios,
HatDiagonal, MeanPredictionBands, MeanPredictionConfidenceIntervals,
MeanPredictionConfidenceIntervalTable, MeanPredictionConfidenceIntervalTableEntries,
MeanPredictionErrors, ParameterConfidenceIntervals, ParameterConfidenceIntervalTable,
ParameterConfidenceIntervalTableEntries, ParameterConfidenceRegion, ParameterErrors,
ParameterPValues, ParameterTable, ParameterTableEntries, ParameterTStatistics,
PartialSumOfSquares, PredictedResponse, Properties, Response, RSquared,
SequentialSumOfSquares, SingleDeletionVariances, SinglePredictionBands,
SinglePredictionConfidenceIntervals, SinglePredictionConfidenceIntervalTable,
SinglePredictionConfidenceIntervalTableEntries, SinglePredictionErrors,
StandardizedResiduals, StudentizedResiduals, VarianceInflationFactors}
fit["ANOVATable"]
DF SS MS F-Statistic P-Value
x 1 384 938. 384 938. 39 846.3 4.30887 × 10-30
x2 1 17 718.4 17 718.4 1834.09 9.2856 × 10-19
Error 17 164.23 9.66059
Total 19 402 821.
fit = LinearModelFit[dat1, {x, x ^ 2, x ^ 3}, x]
FittedModel 9.2582 + 3.22956 x + 0.973584 x2 + 0.000985083 x3
12 roushan workshop .nb
pf
400
300
200
100
5 10 15 20
plt
400
300
200
100
5 10 15 20
lp
400
300
200
100
5 10 15 20
roushan workshop .nb 13
Show[lp, plt]
400
300
200
100
5 10 15 20
RandomReal[]
0.873476
r1 = RandomReal[]
0.962754
r2 := RandomReal[]
{r2, r2, r2}
{0.49811, 0.356356, 0.210168}
{r1, r1, r1}
{0.962754, 0.962754, 0.962754}
Defining function
fun1[x_] := Sin[x] + x ^ 2
fun1[0.5]
0.729426
fun1[y]
y2 + Sin[y]
fun1[plt]
2
+ Sin200
400 400
300 300
200
100 100
5 10 15 20 5 10 15 20
Table[{x, fun1[x]}, {x, - 5, 5, 0.5}]
{{- 5., 25.9589}, {- 4.5, 21.2275}, {- 4., 16.7568}, {- 3.5, 12.6008}, {- 3., 8.85888},
{- 2.5, 5.65153}, {- 2., 3.0907}, {- 1.5, 1.25251}, {- 1., 0.158529}, {- 0.5, - 0.229426},
{0., 0.}, {0.5, 0.729426}, {1., 1.84147}, {1.5, 3.24749}, {2., 4.9093}, {2.5, 6.84847},
{3., 9.14112}, {3.5, 11.8992}, {4., 15.2432}, {4.5, 19.2725}, {5., 24.0411}}
14 roushan workshop .nb
Plot[fun1[x], {x, - 5, 5}]
25
20
15
10
-4 -2 2 4
D[x ^ 2 Sin[x], x]
x2 Cos[x] + 2 x Sin[x]
Sin '[x]
Cos[x]
D[Sin[2 x + 3 y] + x y ^ 3, {x, 2}, {y, 1}]
- 12 Cos[2 x + 3 y]
D[Sin[2 x + 3 y] + x y ^ 3, {x, 1}, {y, 1}]
3 y2 - 6 Sin[2 x + 3 y]
3*y^2 - 6*Sin[2*x + 3*y]
$Aborted
fun1 ''[x]
2 - Sin[x]
Plot[{fun1[x], fun1 '[x]}, {x , - 5, 5}, PlotLegends "Expressions"]
25
20
15
fun1(x)
fun1′ (x)
10
-4 -2 2 4
-5
-10
PLotx2 + Sin[x], 2 x + Cos[x], {x, - 5, 5}, PlotLegends "Expressions"
PLotx2 + Sin[x], 2 x + Cos[x], {x, - 5, 5}, PlotLegends Expressions
roushan workshop .nb 15
N[Sin[10], 5]
- 0.54402
FindRoot[fun1[x] fun1 '[x], {x, 2}]
{x 1.41249}
FindRoot[fun1[x] fun1 '[x], {x, - 2}]
{x - 0.540089}
Integrate[1 / (x ^ 3 + 1), {x, 0, 1}]
2 3 π + Log[64]
1
18
NIntegrate[1 / (x ^ 3 + 1), {x, 0, 1}]
0.835649
Integrate[Sin[x]]
Integrate : Integrate called with 1 argument; 2 or more arguments are expected.
Integrate[SinIntegral]
DSolve[y '[x] + y[x] a Sin[x], y[x], x]
y[x] -x C[1] + a (- Cos[x] + Sin[x])
1
2
DSolve[{y '[x] + y[x] a Sin[x], y[0] 0}, y[x], x]
y[x] - a -x - 1 + x Cos[x] - x Sin[x]
1
2
Infinity
∞
N[1 / In]
1
In
Sin[x] x
- Cos[x]
1 / (x ^ 4 + x ^ 5) x
- + - - Log[x] + Log[1 + x]
1 1 1
3 x3 2 x2 x
16 roushan workshop .nb
PlotEvaluate 1 / (x ^ 4 + x ^ 5) x, {x, 2, 12}
4 6 8 10 12
-0.0005
-0.0010
-0.0015
-0.0020
-0.0025
+ - - Log[x] + Log[1 + x], {x, 2, 12}
1 1 1
Plot
3x 3
2x 2 x
0.025
0.020
0.015
0.010
0.005
4 6 8 10 12
1 / (x ^ 4 + x ^ 5) x
- + - - Log[x] + Log[1 + x]
1 1 1
3 x3 2 x2 x
Linear Algebra
mat1 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
Dimensions[mat1]
{3, 3}
Transpose[mat1]
{{1, 4, 7}, {2, 5, 8}, {3, 6, 9}}
MatrixForm[mat1]
1 2 3
4 5 6
7 8 9
roushan workshop .nb 17
mat1.{a, b, c}
{a + 2 b + 3 c, 4 a + 5 b + 6 c, 7 a + 8 b + 9 c}
Det[mat1]
0
MatrixRank[mat1]
2
Eigenvalues[mat1]
5 + 33 , 5 - 33 , 0
3 3
2 2
Eigenvectors[mat1]
- 15 - 4 6 + 33 15 - 4 - 6 + 33
- , 1, - , 1, {1, - 2, 1}
33 33
33 + 7 33 + 7 - 33 + 7 - 33 + 7
, ,
33 33 33 33
{u, w, v } = SingularValueDecomposition[{1, 2}, {3, 4}]
SingularValueDecomposition: Argument 1 at position 1 is not a non-empty rectangular matrix.
Set: Lists {u, w, v} and SingularValueDecomposition[{1, 2}, {3, 4}] are not the same shape.
SingularValueDecomposition[{1, 2}, {3, 4}]
mat2 = {{a, b}, {c, d}}
{{a, b}, {c, d}}
Det[mat2]
-b c + a d
Eigenvalues[mat2]
a+d- a2 + 4 b c - 2 a d + d2 , a+d+ a2 + 4 b c - 2 a d + d2
1 1
2 2
IdentityMatrix[6]
{{1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 1}}
MatrixForm[%]
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
Eigenvalues[%]
{1, 1, 1, 1, 1, 1}
18 roushan workshop .nb
Eigenvectors[IdentityMatrix[6]]
{{0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 1, 0}, {0, 0, 0, 1, 0, 0},
{0, 0, 1, 0, 0, 0}, {0, 1, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0}}
Programing with Mathematica
Procedural Programing -Loops
For[i = 1, i ≤ 5, i ++, Print[i ^ 2]]
1
16
25
list = Table[0, {i, 1, 5}]
{0, 0, 0, 0, 0}
For[k = 1, k ≤ 5, k ++, list[[k]] = k ^ 2 + 2 k + 3]
list
{6, 11, 18, 27, 38}
Functional Programing
fun1[x_] := Sin[x] + x ^ 2
? fun1
CloudObject`Private`fun1
fun1[x_] := Sin[x] + x2
Map[f, {1, 2, 3, 4}]
{f[1], f[2], f[3], f[4]}
Map[fun1, {1, 2, 3, 4}]
{1 + Sin[1], 4 + Sin[2], 9 + Sin[3], 16 + Sin[4]}
fun2[{x_, y_}] := x ^ 2 + 2 x + 3 y + 100
fun2[{1, 3}]
112
Map[fun2, {{1, 3}, {4, 5}, {a, b}, {- 5, 5}}]
112, 139, 100 + 2 a + a2 + 3 b, 130
fun3[x_Real] := x ^ 2
roushan workshop .nb 19
fun3[0.5]
0.25
fun3[5]
fun3[5.]
25.
fun4[x_Real /; x > 5] := x ^ 3
fun4[5.5]
166.375
fun5[{x_Real, y_Integer}] := x + 2 y
fun5[{0.5 , 6}]
12.5
fun5[{0.5`, 6}]
fun5[{0.5, 6}]
Rule-based programing
p + q /. p 5
5+q
p + q + r + z /. {p 5, r 7, Z 0}
12 + q + z
Remove[x]
{1, 2.0, 0.5, 0.6, a, b, c} /. x_Real x ^ 2
{1., 4., 0.25, 0.36, a, b, c}
Sort[{1., 4., 0.25, 0.36, a, b, c}]
{0.25, 0.36, 1., 4., a, b, c}
{{1, 2}, {0.5, 3}, {a, b}, {- 0.5, 0.6}} /. {x_Real /; x < 0, Y_Integer} x ^ 2 + y ^ 2
{{1, 2}, {0.5, 3}, {a, b}, {- 0.5, 0.6}}
{{1, 2}, {0.5, 3}, {a, b}, {- 0.5, 0.6}} /. {x_Real /; x < 0, y_} x ^ 2 + y ^ 2
{{1, 2}, {0.5, 3}, {a, b}, 0.61}
Project-Point distance from origin
points = {{- 5, 4}, {4.5, 1}, {3, 4}, {- 2.3, - 5}}
{{- 5, 4}, {4.5, 1}, {3, 4}, {- 2.3, - 5}}
20 roushan workshop .nb
Method 1-Procedural Approach - For loop
lis = Table[0, {i, 1, Length[points]}]
{0, 0, 0, 0}
For[k = 1, k ≤ Length[points], k ++,
lis[[k]] = Sqrt[points[[k, 1]] ^ 2 + points[[k, 2]] ^ 2]]
lis
41 , 4.60977, 5, 5.50364
Length[points]
4
points[[1, 1]]
-5
points[[1, 2]]
4
points[[3, 1]]
3
Method 2-Functional programing
dist[{x_, y_}] := Sqrt[x ^ 2 + y ^ 2]
dist[{1, 2}]
Map [dist, points]
41 , 4.60977, 5, 5.50364
Map [points, dist]
dist
Method 3-Rule based Programming
points /. {x_, y_} Sqrt[x ^ 2 + y ^ 2]
41 , 4.60977, 5, 5.50364
Project 2-Least Square Fit
dat1
dat1
roushan workshop .nb 21
xlsdata = Import["C:\\Users\\roush\\Desktop\\rou.xlsx"]
{{{1., 1., 3., 10., 3., 17.}, {2., 4., 6., 10., - 4., 16.}, {3., 9., 9., 10., - 2., 26.},
{4., 16., 12., 10., - 4., 34.}, {5., 25., 15., 10., 4., 54.},
{6., 36., 18., 10., 1., 65.}, {7., 49., 21., 10., 2., 82.}, {8., 64., 24., 10., 4., 102.},
{9., 81., 27., 10., - 3., 115.}, {10., 100., 30., 10., - 4., 136.},
{11., 121., 33., 10., 1., 165.}, {12., 144., 36., 10., - 3., 187.},
{13., 169., 39., 10., 1., 219.}, {14., 196., 42., 10., 4., 252.},
{15., 225., 45., 10., - 4., 276.}, {16., 256., 48., 10., 1., 315.},
{17., 289., 51., 10., 2., 352.}, {18., 324., 54., 10., 2., 390.},
{19., 361., 57., 10., - 2., 426.}, {20., 400., 60., 10., 2., 472.}},
{{A, P, D}, {B, P, D}, {C, P, D}, {D, P, D}, {A, P, D}, {B, P, D}, {C, P, D}, {D, P, D},
{A, P, D}, {B, P, D}, {C, P, D}, {D, P, D}, {A, P, D}, {B, P, D}, {C, P, D}}}
dat1 = xlsdata[[1, All, {1, 6}]]
{{1., 17.}, {2., 16.}, {3., 26.}, {4., 34.}, {5., 54.}, {6., 65.}, {7., 82.}, {8., 102.},
{9., 115.}, {10., 136.}, {11., 165.}, {12., 187.}, {13., 219.}, {14., 252.},
{15., 276.}, {16., 315.}, {17., 352.}, {18., 390.}, {19., 426.}, {20., 472.}}
errf[{x_, y_}] := a x ^ 2 + b x + c - y
Map[errf, dat1] ^ 2
(- 17. + 1. a + 1. b + c)2 , (- 16. + 4. a + 2. b + c)2 , (- 26. + 9. a + 3. b + c)2 ,
(- 34. + 16. a + 4. b + c)2 , (- 54. + 25. a + 5. b + c)2 , (- 65. + 36. a + 6. b + c)2 ,
(- 82. + 49. a + 7. b + c)2 , (- 102. + 64. a + 8. b + c)2 , (- 115. + 81. a + 9. b + c)2 ,
(- 136. + 100. a + 10. b + c)2 , (- 165. + 121. a + 11. b + c)2 ,
(- 187. + 144. a + 12. b + c)2 , (- 219. + 169. a + 13. b + c)2 , (- 252. + 196. a + 14. b + c)2 ,
(- 276. + 225. a + 15. b + c)2 , (- 315. + 256. a + 16. b + c)2 , (- 352. + 289. a + 17. b + c)2 ,
(- 390. + 324. a + 18. b + c)2 , (- 426. + 361. a + 19. b + c)2 , (- 472. + 400. a + 20. b + c)2
rmserr = Sqrt[Total[Map[errf, dat1] ^ 2] / Length[dat1]]
(- 17. + 1. a + 1. b + c)2 + (- 16. + 4. a + 2. b + c)2 +
1
2 5
(- 26. + 9. a + 3. b + c)2 + (- 34. + 16. a + 4. b + c)2 + (- 54. + 25. a + 5. b + c)2 +
(- 65. + 36. a + 6. b + c)2 + (- 82. + 49. a + 7. b + c)2 + (- 102. + 64. a + 8. b + c)2 +
(- 115. + 81. a + 9. b + c)2 + (- 136. + 100. a + 10. b + c)2 + (- 165. + 121. a + 11. b + c)2 +
(- 187. + 144. a + 12. b + c)2 + (- 219. + 169. a + 13. b + c)2 + (- 252. + 196. a + 14. b + c)2 +
(- 276. + 225. a + 15. b + c)2 + (- 315. + 256. a + 16. b + c)2 + (- 352. + 289. a + 17. b + c)2 +
(- 390. + 324. a + 18. b + c)2 + (- 426. + 361. a + 19. b + c)2 + (- 472. + 400. a + 20. b + c)2
NMinimize[rmserr, {a, b, c}]
{2.86557, {a 1.00461, b 2.96251, c 9.78158}}
Length[dat1]
20
22 roushan workshop .nb
xlsdata = Import["C:\\Users\\roush\\Desktop\\isoelectric point Book1.xlsx"]
{{{Volume of NaOH added (in ml), PH}, {0., 1.64}, {3., 1.73}, {6., 1.84},
{9., 1.94}, {12., 2.1}, {15., 2.3}, {18., 2.54}, {21., 2.99}, {24., 3.49},
{24.5, 3.7}, {25., 4.04}, {25.5, 5.33}, {26., 7.72}, {26.5, 8.27},
{27., 8.49}, {27.5, 8.49}, {28., 8.67}, {30., 8.82}, {33., 9.1}, {36., 9.4},
{39., 9.63}, {42., 9.84}, {45., 10.07}, {48., 10.31}, {51., 11.28},
{54., 11.57}, {57., 11.75}, {60., 11.91}, {63., 11.96}, {66., 12.02}}}
dat2 = xlsdata
{{{Volume of NaOH added (in ml), PH}, {0., 1.64}, {3., 1.73}, {6., 1.84},
{9., 1.94}, {12., 2.1}, {15., 2.3}, {18., 2.54}, {21., 2.99}, {24., 3.49},
{24.5, 3.7}, {25., 4.04}, {25.5, 5.33}, {26., 7.72}, {26.5, 8.27},
{27., 8.49}, {27.5, 8.49}, {28., 8.67}, {30., 8.82}, {33., 9.1}, {36., 9.4},
{39., 9.63}, {42., 9.84}, {45., 10.07}, {48., 10.31}, {51., 11.28},
{54., 11.57}, {57., 11.75}, {60., 11.91}, {63., 11.96}, {66., 12.02}}}
lp = ListPlot[dat2]
12
10
10 20 30 40 50 60
Dynamic[CurrentImage[], 396]
roushan workshop .nb 23
Table[ Pause[1]; CurrentImage[], {5}]
, ,
, ,
ListAnimate[CurrentImage[30]]
Dynamic[ImageDifference @@ CurrentImage[2]]
24 roushan workshop .nb
MathMLForm