if isset _POST matrix echo form action method post óñêîðåíèå ñâîáîäíîã

  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
<?
if (!isset($_POST['matrix'])) {
echo "
<form action=\"\" method=\"post\">
g (óñêîðåíèå ñâîáîäíîãî ïàäåíèÿ) <input type=\"text\" name=\"g\" style=\"width: 50px\" value=\"9.81\"> ì/c*c<br/>
l (äëèíà) <input type=\"text\" name=\"l\" style=\"width: 50px\" value=\"0.63\"> ì<br/>
Òî÷íîñòü äî <input type=\"text\" name=\"round\" value=\"2\" style=\"width: 50px\"> çíàêà ïîñëå çàïÿòîé</br>
Ðåçóëüòàòû èçìåðåíèé ìîæíî ñêîïèðîâàòü èç Exel âûäåëåâ íóæíûé êóñîê òàáëèöû (ðàçäåëèòåëü öåëîé è äðîáíîé ÷àñòè - ÒÎ×ÊÀ)<br />
<textarea name=\"matrix\" style=\"width: 700px;height: 200px;\">68.38 14 62.96 22 61.20 28 59.82 35 58.91 41
68.83 14 62.58 21 61.64 28 60.14 34 58.56 40
68.44 14 62.73 22 60.94 28 59.87 35 59.18 40
69.70 15 63.30 21 61.26 29 59.23 35 58.53 41
67.88 14 63.56 22 61.01 28 60.68 34 60.33 40
67.37 15 63.96 21 60.93 28 59.93 35 58.84 41
68.83 14 63.34 21 61.55 28 59.64 35 59.51 41
68.35 15 62.29 21 60.45 28 59.58 35 58.62 40
69.08 14 63.90 21 61.04 28 59.36 35 58.30 41
68.40 14 63.84 21 61.82 28 60.54 34 58.82 40</textarea>
<br />
<input type=\"submit\" value=\"GO\">
</form>
";
die();
}
define("COUNT",10);
define("FONT_SIZE",13);
define("MASS",0.019);
define("ROUND",(int)$_POST['round']);
set_time_limit(0);
$l = (float)$_POST['l'];
$g = (float)$_POST['g'];
include("./mathpublisher.php");
$matrix = preg_replace("#[^\t\.\r\n\s0-9]+#is","",$_POST['matrix']);
/*
$matrix = "68.98 13 66.49 22.5 62.68 28 60.52 35 58.68 40
73.86 12 64.08 22 62.93 29.5 60.64 35 59.04 39.5
69.21 14 65.46 21.5 62.06 29.5 59.53 34 57.95 40.5
71.9 14 66.47 21 61.41 28.5 59.61 35 58.52 40
68.65 15 64.8 22.5 61.74 29.5 60.93 34 58.44 40
68.09 15.5 66.08 22 61.21 28 59.59 34 58.6 40.5
70.36 14.6 64.62 22.5 61.31 27.5 59.74 35 58.18 38.5
68.79 15 64.34 22 63.06 28 59.71 34.5 58.57 39
70.3 14.5 64.34 21.5 61.62 29 60.52 35 58.89 40
68.51 15.6 65.62 22 61.11 28.5 59.35 35 58.37 39.5";
*/
function mySplit($array) {
return preg_split("#[\t\s]+#",$array);
}
function mathecho($str) {
echo mathfilter($str,FONT_SIZE,"img/");
}
function ctg($alpha) {
return tan(M_PI/2 - $alpha);
}
$matrix = explode("\r\n",$matrix);
$matrix = array_map("mySplit",$matrix);
$average = array();
$average_visual = array();
// Âû÷èñëÿåì ñðåäíèè çíà÷åíèÿ
for ($i=0;$i<COUNT;$i++) {
for ($n=0;$n<COUNT;$n=$n+2) {
if (!isset($average_visual["time_".$n/2])) $average_visual["time_".$n/2] = "{";
if (!isset($average_visual["angle_".$n/2])) $average_visual["angle_".$n/2] = "{";
$average_visual["time_".$n/2] .= ($i+1 < COUNT) ? $matrix[$i][$n]."+" : $matrix[$i][$n]."}/".COUNT;
$average_visual["angle_".$n/2] .= ($i+1 < COUNT) ? $matrix[$i][$n+1]."+" : $matrix[$i][$n+1]."}/".COUNT;
@$average['time_'.$n/2] += round($matrix[$i][$n]/COUNT,ROUND);
@$average['angle_'.$n/2] += round($matrix[$i][$n+1]/COUNT,ROUND);
}
}
echo "<style>
.shift {
margin-left: 80px;
}
table {
border: 1px #000 solid;
text-align: center;
}
td {
border: 1px #000 solid;
padding: 5px;
}
</style>
";
// Âûâîä ñðåäíèõ çíà÷åíèé
echo "<h3>Âû÷èñëåíèå ñðåäíèõ çíà÷åíèé</h3>";
for ($i=0;$i<COUNT/2;$i++) {
echo "Ñðåäíèè çíà÷åíèÿ äëÿ óãëà ".mathfilter("<m>alpha = ".(20+$i*10)."^circ </m>",FONT_SIZE,"img/")."<br /><br />\r\n\r\n";
echo "<div class='shift'>\r\n";
echo mathfilter("\t<m><tau> = ".$average_visual["time_".$i]." = ".$average["time_".$i]."</m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo mathfilter("\t<m>alpha_{cp} = ".$average_visual["angle_".$i]."= ".$average["angle_".$i]."^circ</m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo "</div>\r\n\r\n";
}
// Âûâîäèì ôîðìóëû äëÿ ðàñ÷åòà
echo mathfilter("<h3>Ôîðìóëû äëÿ ðàñ÷åòà <m>upsilon_1~upsilon_2~<F>~<tau>~</m></h3>",FONT_SIZE,"img/");
echo "<div class='shift'>\r\n";
echo mathfilter("\t<m>upsilon_{1,2} = 2{sin{alpha_{1,2}/2}}{sqrt{gl}}</m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo mathfilter("\t<m><F> = {m(upsilon_1 + upsilon_2)}/{<tau>}</m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo mathfilter("\t<m>varepsilon = upsilon_2/upsilon_1</m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo "</div>\r\n\r\n";
// Ñ÷èòàåì îñíîâíûå âåëè÷èíû
echo mathfilter("<h3>Âû÷èñëåíèå <m>upsilon_1~upsilon_2~<F>~<tau>~</m></h3>",FONT_SIZE,"img/");
for ($i=0;$i<COUNT/2;$i++) {
echo "Çíà÷åíèÿ äëÿ óãëà ".mathfilter("<m>alpha = ".(20+$i*10)."^circ </m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo "<div class='shift'>\r\n";
// ðàñ÷åò
$vars['v_1_'.$i] = round((2*sin(deg2rad(20+$i*10)/2))*sqrt($g*$l),ROUND);
$vars['v_2_'.$i] = round((2*sin(deg2rad($average["angle_".$i])/2))*sqrt($g*$l),ROUND);
$vars['f_'.$i] = round((MASS*($vars['v_1_'.$i]+$vars['v_2_'.$i]))/($average["time_".$i]*0.000001),ROUND);
$vars['e_'.$i] = round($vars['v_2_'.$i]/$vars['v_1_'.$i],ROUND);
// Âûâîä
echo mathfilter("\t<m>upsilon_1 = 2{sin{".(20+$i*10)."^circ/2}}{sqrt{".$g."*".$l."}} = ".$vars['v_1_'.$i]."</m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo mathfilter("\t<m>upsilon_2 = 2{sin{".($average["angle_".$i])."^circ/2}}{sqrt{".$g."*".$l."}} = ".$vars['v_2_'.$i]."</m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo mathfilter("\t<m><F> = {".MASS."*(".$vars['v_1_'.$i]." + ".$vars['v_2_'.$i].")}/{".$average["time_".$i]."*10^{-6}} = ".$vars['f_'.$i]."</m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo mathfilter("\t<m>varepsilon = ".$vars['v_2_'.$i]."/".$vars['v_1_'.$i]." = ".$vars['e_'.$i]."</m>",FONT_SIZE,"img/")."<br /><br />\r\n";
echo "</div>\r\n\r\n";
}
// Âñå äàëüøå èäóò ïîãðåøíîñòè :(
echo mathfilter("<h3>Ðàñ÷¸ò ïîãðåøíîñòè èñõîäíûõ äàííûõ</h3>",FONT_SIZE,"img/");
$m = 0.019;
$dl = 0.001;
$dg = 0.005;
$dm = 0.0001;
$da = 0.5;
$dt = 0.01;
$e_l = round($dl/$l,ROUND+2);
$e_g = round($dg/$g,ROUND+2);
$e_m = round($dm/$m,ROUND+2);
$t_10 = 2.26;
$t_inf = 1.96;
$alph = 2.29;
echo "<div class='shift'>\r\n";
echo mathfilter("\t<m>L = (".$l ." pm ".$dl.")</m><br />\r\n",FONT_SIZE,"img/");
echo mathfilter("\t<m>g = (".$g ." pm ".$dg.")</m><br />\r\n",FONT_SIZE,"img/");
echo mathfilter("\t<m>m = (".$m ." pm ".$dm.")</m><br /><br />\r\n",FONT_SIZE,"img/");
echo mathfilter("\t<m>E_L~=~{{Delta{L}}/L}*100%~=~{".$dl."/".$l."}*100%~=~".($e_l*100)."%</m><br /><br />\r\n",FONT_SIZE,"img/");
echo mathfilter("\t<m>E_m~=~{{Delta{m}}/m}*100%~=~{".$dm."/".$m."}*100%~=~".($e_m*100)."%</m><br /><br />\r\n",FONT_SIZE,"img/");
echo mathfilter("\t<m>E_g~=~{{Delta{g}}/g}*100%~=~{".$dg."/".$g."}*100%~=~".($e_g*100)."%</m><br /><br />\r\n",FONT_SIZE,"img/");
echo mathfilter("\tÄîâåðèòåëüíàÿ ïîãðåøíîñòü <m>P~=~95%</m><br /><br />\r\n",FONT_SIZE,"img/");
echo "\tÊîýôôèöèåíòû Ñòüþäåíòà:<br /><br />\r\n";
echo mathfilter("\t<m>t_{p,n}~=~t_{95,10}~=~".$t_10."</m><br /><br />\r\n",FONT_SIZE,"img/");
echo mathfilter("\t<m>t_{p,infty}~=~t_{95,infty}~=~".$t_inf."</m><br /><br />\r\n",FONT_SIZE,"img/");
echo "</div>\r\n\r\n";
echo "<h3>Ðàñ÷¸ò ñðåäíåé êâàäðàòè÷íîé ïîãðåøíîñòè:</h3>";
//echo mathfilter("Èñõîäÿ èç ÷èñëà îïûòîâ êîýôôèöèåíò <m>alpha</m> ïðèíèìàåì ðàâíûì <m>".$alph."</m><br /><br />\r\n",FONT_SIZE,"img/");
for ($i=0;$i<COUNT/2;$i++) {
echo "Ðàñ÷¸ò ïîãðåøíîñòåé ïðÿìûõ èçìåðåíèé:<br /><br />\r\n";
echo "<div class='shift'>\r\n";
$e_a = round(($da/(20+$i*10)),ROUND);
mathecho("<m>alpha_1 = (".(20+$i*10)." pm ".$da."),~E_{alpha_1} = {{delta{alpha_1}}/alpha_1}*100% = {{".$da."}/{".(20+$i*10)."}}*100% = ".(($e_a)*100)."%</m><br /><br />\r\n");
$p_visual = "sqrt{{";
$p_a[$i] = 0;
for($n=0;$n<COUNT;$n++) {
$p_a[$i] += round(pow($matrix[$n][$i*2+1]-$average["angle_".$i],2),ROUND);
$p_visual .= ($n+1 < COUNT) ? "(".$matrix[$n][$i*2+1]."-".$average["angle_".$i].")^2+" : "(".$matrix[$n][$i*2+1]."-".$average["angle_".$i].")^2";
}
$p_visual .= "}/{".COUNT."*(".COUNT."-1)}}";
$p_a[$i] = round(sqrt($p_a[$i]/(COUNT*(COUNT-1))),ROUND);
$d_a2[$i] = round(sqrt(pow($t_10*$p_a[$i],2) + pow((1/3)*$t_inf*$da,2)),ROUND);
$e_a2[$i] = round($d_a2[$i]/$average["angle_".$i],ROUND);
mathecho("\t<m>S_{<alpha_2>,10} = sqrt{1/{N(N-1)}sum{i=1}{N}{(alpha_{2i} + <alpha_2>)^2}} = ".$p_visual ." = ".$p_a[$i]."</m><br /><br />\r\n");
mathecho("\t<m>Delta{alpha_2} = sqrt{(t_{95,10}*S_{<alpha_2>})^2+(1/3 t_{95,infty}*delta{alpha_2})^2} = sqrt{(".$t_10."*".$p_a[$i].")^2+(1/3 ".$t_inf."*".$da.")^2} = ".$d_a2[$i] ."</m><br /><br />\r\n");
mathecho("\t<m>alpha_2 = (".$average["angle_".$i]." pm ".$d_a2[$i]."), ~ E_{alpha_2} = {".$d_a2[$i]."/".$average["angle_".$i]."}*100% = ".($e_a2[$i]*100)."%, ~ P=95%</m><br /><br />\r\n");
echo "</div>\r\n\r\n";
echo "Ðàñ÷¸ò ïîãðåøíîñòè âðåìåíè óäàðà:<br /><br />\r\n";
echo "<div class='shift'>\r\n";
$p_visual = "sqrt{{";
$p_t[$i] = 0;
for($n=0;$n<COUNT;$n++) {
$p_t[$i] += round(pow($matrix[$n][$i*2]-$average["time_".$i],2));
$p_visual .= ($n+1 < COUNT) ? "(".$matrix[$n][$i*2]."-".$average["time_".$i].")^2+" : "(".$matrix[$n][$i*2]."-".$average["time_".$i].")^2";
}
$p_visual .= "}/{".COUNT."*(".COUNT."-1)}}";
$p_t[$i] = round(sqrt($p_t[$i]/(COUNT*(COUNT-1))),ROUND);
$d_t[$i] = round(sqrt(pow($t_10*$p_t[$i],2) + pow((1/3)*$t_inf*$dt,2)),ROUND);
$e_t[$i] = round($d_t[$i]/$average["time_".$i],ROUND);
mathecho("\t<m>S_{<tau>,10} = sqrt{1/{N(N-1)}sum{i=1}{N}{(tau_i + <tau>)^2}} = ".$p_visual." = ".$p_t[$i]."</m><br /><br />\r\n");
mathecho("\t<m>Delta{tau} = sqrt{(t_{95,10}*S_{<tau>})^2+(1/3 t_{95,infty}*delta{tau})^2} = sqrt{(".$t_10."*".$p_t[$i].")^2+(1/3 ".$t_inf."*".$dt.")^2} = ".$d_t[$i] ."</m><br /><br />\r\n");
mathecho("\t<m>tau = (".$average["time_".$i]." pm ".$d_t[$i]."), ~ E_{tau} = {".$d_t[$i]."/".$average["time_".$i]."}*100% = ".($e_t[$i]*100)."%, ~ P=95%</m><br /><br />\r\n");
echo "</div>\r\n\r\n";
echo "Ðàñ÷¸ò ïîãðåøíîñòåé êîñâåííûõ èçìåðåíèé:<br /><br />\r\n";
echo "1. Ïîãðåøíîñòü ñêîðîñòè<br /><br />\r\n";
echo "<div class='shift'>\r\n";
$e_v1 = round((1/2)*sqrt(pow($e_g,2) + pow($e_l,2) + pow(ctg(deg2rad((20+$i*10)/2))*deg2rad($da),2)),ROUND);
$d_v1 = round($e_v1*$vars['v_1_'.$i],ROUND);
mathecho("\t<m>E_{upsilon_1} = 1/2 sqrt{{E_g}^2+{E_l}^2+(ctg{alpha_1/2}Delta{alpha_1})^2} = 1/2 sqrt{{".$e_g."}^2+{".$e_l."}^2+(ctg{".((20+$i*10)/2)."^circ}*".$da."^circ)^2} = 1/2 sqrt{{".$e_g."}^2+{".$e_l."}^2+(".round(ctg(deg2rad((20+$i*10)/2)),ROUND)."*".round(deg2rad($da),ROUND).")^2} =".$e_v1."</m><br /><br />\r\n");
mathecho("\t<m>Delta{upsilon_1} = E_{upsilon_1}*upsilon_1 = ".$e_v1."*".$vars['v_1_'.$i]." = ".$d_v1."</m><br /><br />\r\n");
mathecho("\t<m>upsilon_1 = (".$vars['v_1_'.$i]." ~ pm ~ ".$d_v1.")</m><br /><br />\r\n");
$e_v2 = round((1/2)*sqrt(pow($e_g,2) + pow($e_l,2) + pow(ctg(deg2rad(($average["angle_".$i])/2))*deg2rad($d_a2[$i]),2)),ROUND);
$d_v2 = round($e_v2*$vars['v_1_'.$i],ROUND);
mathecho("\t<m>E_{upsilon_2} = 1/2 sqrt{{E_g}^2+{E_l}^2+(ctg{alpha_2/2}Delta{alpha_2})^2} = 1/2 sqrt{{".$e_g."}^2+{".$e_l."}^2+(ctg{".($average["angle_".$i]/2)."^circ}*".$d_a2[$i]."^circ)^2} = 1/2 sqrt{{".$e_g."}^2+{".$e_l."}^2+(".round(ctg(deg2rad($average["angle_".$i]/2)),ROUND)."*".round(deg2rad($d_a2[$i]),ROUND).")^2} =".$e_v2."</m><br /><br />\r\n");
mathecho("\t<m>Delta{upsilon_2} = E_{upsilon_2}*upsilon_2 = ".$e_v2."*".$vars['v_2_'.$i]." = ".$d_v2."</m><br /><br />\r\n");
mathecho("\t<m>upsilon_1 = (".$vars['v_2_'.$i]." ~ pm ~ ".$d_v2.")</m><br /><br />\r\n");
echo "</div>\r\n\r\n";
echo "2. Ïîãðåøíîñòü êîíñòàíòû óäàðà<br /><br />\r\n";
echo "<div class='shift'>\r\n";
$e_e = round(sqrt(pow($e_v1,2)+pow($e_v2,2)),ROUND);
$d_e = round($vars['e_'.$i]*$e_e,ROUND);
mathecho("\t<m>E_E = sqrt{{E_{upsilon_1}}^2 + {E_{upsilon_2}}^2 } = sqrt{{".$e_v1."}^2 + {".$e_v2."}^2 } = ".$e_e."</m><br /><br />\r\n");
mathecho("\t<m>Delta{E} = E_E * <E> = ".$vars['e_'.$i]."*".$e_e."= ".$d_e."</m><br /><br />\r\n");
mathecho("\t<m>E = (".$vars['e_'.$i]." ~ pm ~".$d_e.")</m><br /><br />\r\n");
echo "</div>\r\n\r\n";
echo "3. Ïîãðåøíîñòü ñðåäíåé ñèëû óäàðà:<br /><br />\r\n";
echo "<div class='shift'>\r\n";
$e_f = round(sqrt(pow($e_m,2) + pow($e_t[$i],2) + (pow($d_v1,2) + pow($d_v2,2))/pow($vars['v_1_'.$i] + $vars['v_2_'.$i],2)),ROUND);
$d_f = round($e_f*$vars['f_'.$i],ROUND);
mathecho("\t<m>Delta{overline{F}} = E_{overline{F}}*<overline{F}></m><br /><br />\r\n");
mathecho("\t<m>E_{overline{F}} = sqrt{{E_m}^2+{E_{<tau>}}^2+{E_(upsilon_1+<upsilon_2>)}^2}</m><br /><br />\r\n");
mathecho("\t<m>{E_(upsilon_1+<upsilon_2>)}^2 = {Delta^2(upsilon_1+<upsilon_2>)}/(upsilon_1+<upsilon_2>)^2 = {(Delta{upsilon_1}^2)+(Delta{upsilon_2}^2)}/(upsilon_1+<upsilon_2>)^2 </m><br /><br />\r\n");
mathecho("\t<m>E_{overline{F}} = sqrt{".$e_m."^2 + ".$e_t[$i]."^2 +{".$d_v1."^2 + ".$d_v2."^2}/(".$vars['v_1_'.$i]." + ".$vars['v_2_'.$i].")^2 }= ".$e_f."</m><br /><br />\r\n");
mathecho("\t<m>Delta{overline{F}} = E_{overline{F}}*<overline{F}> = ".$e_f."*".$vars['f_'.$i]." = ".$d_f."</m><br /><br />\r\n");
mathecho("\t<m>overline{F} = ".$vars['f_'.$i]." ~ pm ~ ".$d_f ."</m><br /><br />\r\n");
echo "</div>\r\n\r\n";
// Ñîõðàíÿåì ðåçóëòàòû
$result[$i]['d_f'] = $d_f;
$result[$i]['d_v1'] = $d_v1;
$result[$i]['d_t'] = $d_t[$i];
echo "<br /><br /><hr/>\r\n";
}
echo "<table>\r\n";
mathecho("<tr><td><m>alpha_1</m></td><td><m><F></m></td><td><m>upsilon_1</m></td><td><m>upsilon_2</m></td><td><m><tau></m></td><td><m>varepsilon</m></td><td><m>Delta{F}</m></td><td><m>Delta{upsilon_1}</m></td><td><m>Delta{tau}</m></td></tr>\r\n");
for ($i=0;$i<COUNT/2;$i++) {
mathecho("<tr><td><m>".(20+$i*10)."^circ</m></td><td>".$vars['f_'.$i]."</td><td>".$vars['v_1_'.$i]."</td><td>".$vars['v_2_'.$i]."</td><td>".$average["time_".$i]."</td><td>".$vars['e_'.$i]."</td><td>".$result[$i]['d_f']."</td><td>".$result[$i]['d_v1']."</td><td>".$result[$i]['d_t']."</td></tr>\r\n");
}
echo "</table>\r\n";
?>