JESÚS AVALOS RODRÍGUEZ
Docente del Departamento Académico de Matemáticas
Facultad de Ciencias Físicas y Matemáticas
Universidad Nacional de Trujillo
E-mail: javalos@unitru.edu.pe
Docente del Departamento Académico de Matemáticas
Facultad de Ciencias Físicas y Matemáticas
Universidad Nacional de Trujillo
E-mail: javalos@unitru.edu.pe
==============================
Manipulate[
Module[{func, curve, arcLength, arcLengthValue, arcLengthComputation,
coords, points, polygonal, para2D, para3D, pol, polyLength},
Switch[mode, 1,
max = 2; func = curves;
curve =
Plot[func, {x, 0, max}, PlotRange -> All, AxesOrigin -> {0, 0}];
arcLength = NIntegrate[Sqrt[D[func, x]^2 + 1], {x, 0, max}];
arcLengthValue =
If[MemberQ[{x^3, Sin[Pi/2 x]}, curves],
NIntegrate[Sqrt[D[func, x]^2 + 1], {x, 0, max}],
Integrate[Sqrt[D[func, x]^2 + 1], {x, 0, max}]];
arcLengthComputation =
Row[{"\!\(\*SubsuperscriptBox[\(\[Integral]\), \(\(\\\ \\\ \
\)\(0\)\), \(2\)]\)", TraditionalForm[Sqrt[D[func, x]^2 + 1]],
it["d\[InvisibleSpace]x"],
If[MemberQ[{x^3, Sin[Pi/2 x]}, curves],
Row[{" \[TildeTilde] ", arcLength}],
Row[{" = ", arcLengthValue, " \[TildeTilde] ", arcLength}]]}];
coords = Table[{x, func}, {x, 0, max, max/n}];
points = Graphics[{PointSize[0.02], Point[coords]}];
polygonal = Graphics[Line[coords]],
2,
max = 2 Pi; para2D = curves;
curve = ParametricPlot[para2D, {t, 0, max}, PlotRange -> All];
arcLength =
NIntegrate[
Sqrt[D[para2D[[1]], t]^2 + D[para2D[[2]], t]^2], {t, 0, max}];
arcLengthValue =
If[MemberQ[{{2 Cos[t], Sin[t]}, {Cos[t], Sin[3 t]}}, curves],
NIntegrate[
Sqrt[D[para2D[[1]], t]^2 + D[para2D[[2]], t]^2], {t, 0, max}],
Integrate[
Sqrt[D[para2D[[1]], t]^2 + D[para2D[[2]], t]^2], {t, 0, max}]];
arcLengthComputation =
Row[{"\!\(\*SubsuperscriptBox[\(\[Integral]\), \(\(\\\ \\\ \
\)\(0\)\), \(2 \[Pi]\)]\)",
TraditionalForm[
Sqrt[D[para2D[[1]], t]^2 + D[para2D[[2]], t]^2]],
it["d\[InvisibleSpace]t"],
If[MemberQ[{{2 Cos[t], Sin[t]}, {Cos[t], Sin[3 t]}}, curves],
Row[{" \[TildeTilde] ", arcLength}],
If[MemberQ[{{Cos[t], Sin[t]}}, curves],
Row[{" = ", arcLengthValue, " \[TildeTilde] ", arcLength}],
Row[{" = ", arcLengthValue}]]]}];
coords = Table[para2D, {t, 0, max, max/n}];
points = Graphics[{PointSize[0.02], Point[coords]}];
polygonal = Graphics[Line[coords]],
3,
max = 4 Pi; para3D = curves;
curve =
ParametricPlot3D[para3D, {t, 0, max}, PlotRange -> All,
AspectRatio -> 1];
arcLength =
NIntegrate[
Sqrt[D[para3D[[1]], t]^2 + D[para3D[[2]], t]^2 +
D[para3D[[3]], t]^2], {t, 0, max}];
arcLengthValue =
If[MemberQ[{{Cos[t], Sin[t], Cos[t/2]}}, curves],
NIntegrate[
Sqrt[D[para3D[[1]], t]^2 + D[para3D[[2]], t]^2 +
D[para3D[[3]], t]^2], {t, 0, max}],
Integrate[
Sqrt[D[para3D[[1]], t]^2 + D[para3D[[2]], t]^2 +
D[para3D[[3]], t]^2], {t, 0, max}]];
arcLengthComputation =
Row[{"\!\(\*SubsuperscriptBox[\(\[Integral]\), \(\(\\\ \\\ \
\)\(0\)\), \(4 \[Pi]\)]\)",
TraditionalForm[
Sqrt[D[para3D[[1]], t]^2 + D[para3D[[2]], t]^2 +
D[para3D[[3]], t]^2]], it["dt"],
If[MemberQ[{{Cos[t], Sin[t], Cos[t/2]}}, curves],
Row[{" \[TildeTilde] ", arcLength}],
Row[{" = ", arcLengthValue, " \[TildeTilde] ", arcLength}]]}];
coords = Table[para3D, {t, 0, max, max/n}];
points = Graphics3D[{PointSize[0.02], Point[coords]}];
polygonal = Graphics3D[Line[coords]],
4,
max = 2 Pi; pol = curves;
curve = PolarPlot[pol, {\[Theta], 0, max}, PlotRange -> All];
arcLength =
NIntegrate[Sqrt[D[pol, \[Theta]]^2 + pol^2], {\[Theta], 0, max}];
arcLengthValue =
If[MemberQ[{}, curves],
NIntegrate[Sqrt[D[pol, \[Theta]]^2 + pol^2], {\[Theta], 0, max}],
Integrate[Sqrt[D[pol, \[Theta]]^2 + pol^2], {\[Theta], 0, max}]];
arcLengthComputation =
Row[{"\!\(\*SubsuperscriptBox[\(\[Integral]\), \(\(\\\ \\\ \
\)\(0\)\), \(2 \[Pi]\)]\)",
TraditionalForm[Sqrt[D[pol, \[Theta]]^2 + pol^2]], it["d"],
"\[Theta]",
If[MemberQ[{3 Sin[2 \[Theta]], 1 + 2 Cos[\[Theta]]}, curves],
Row[{" \[TildeTilde] ", arcLength}],
If[MemberQ[{\[Theta], \[Theta]^2}, curves],
Row[{" = ", arcLengthValue, " \[TildeTilde] ", arcLength}],
Row[{" = ", arcLengthValue}]]]}];
coords =
Table[{pol Cos[\[Theta]], pol Sin[\[Theta]]}, {\[Theta], 0, max,
max/n}];
points = Graphics[{PointSize[0.02], Point[coords]}];
polygonal = Graphics[Line[coords]]
];
polyLength =
Sum[Norm[N[coords[[i + 1]]] - N[coords[[i]]]], {i, 1, n}];
Text@Pane[
Column[{If[arc,
Show[curve, points,
PlotLabel -> Style[Row[{curves, " on [0, ", max, "]"}], 18],
ImageSize -> {300, 300}],
Show[curve, points, polygonal,
PlotLabel -> Style[Row[{curves, " on [0, ", max, "]"}], 18],
ImageSize -> {300, 300}]],
If[arc,
Style[Row[{"The length of the curve above is ",
TraditionalForm@arcLengthComputation, "."}], 18],
Style[Row[{"The length of the polygonal curve when subdividing\
\n[0, ", max, "] into ", it["n"], " = ", n ,
" equal subintervals is ", polyLength, "."}], 18]]},
Alignment -> Center], ImageSize -> {400, 400}]],
Row[{"choose a mode:"}],
ButtonBar[{Row[{it["y"], "=", it["f"], "(", it["x"], ")"}] :> {mode =
1; curves = curveLists[[mode, 1]]},
Row[{it["r"], "=", it["f"], "(\[Theta])"}] :> {mode = 4;
curves = curveLists[[mode, 1]]}, "parametric 2D" :> {mode = 2;
curves = curveLists[[mode, 1]]},
"parametric 3D" :> {mode = 3; curves = curveLists[[mode, 1]]}},
Appearance -> "Vertical"],
Delimiter,
Row[{"choose a curve:"}],
{{mode, 1}, ControlType -> None},
{{max, 2}, ControlType -> None},
{{curveList, curveLists[[1]]}, ControlType -> None},
{{curves, curveLists[[1, 1]], Null}, curveLists[[mode]],
ControlType -> PopupMenu, ImageSize -> 150},
Delimiter,
Row[{"choose a display:"}],
ButtonBar[{"arc length formula" :> {arc = True; n = 1},
"polygonal approximation" :> {arc = False}},
Appearance -> "Vertical"],
{{arc, True}, {False, True}, ControlType -> None},
{{n, 1}, 1, 50, 1, Enabled -> (arc == False),
Appearance -> "Labeled", ImageSize -> Small},
ControlPlacement -> Left,
TrackedSymbols -> True,
Initialization :> (it = Style[#, Italic] &;
curveLists = {{x^2, x^3, x^(3/2), Sqrt[x], Cosh[x],
Sin[Pi/2 x]}, {{Cos[t], Sin[t]}, {2 Cos[t], Sin[t]}, {Cos[t],
Sin[3 t]}, {t - Sin[t], 1 - Cos[t]}, {Cos[t]^3,
Sin[t]^3}}, {{Cos[t], Sin[t], t}, {Cos[t], Sin[t],
Cos[t/2]}}, {\[Theta], \[Theta]^2, 1 + Sin[\[Theta]],
3 Sin[2 \[Theta]], 1 + 2 Cos[\[Theta]]}}),
AutorunSequencing -> {5, 6}]
==============================
a = 0;
(*beginning point*)
b = 3; (*ending point*)
f[x_] := (1 - x)^2;(*function*)
points[x_] :=
Table[{i, f[i]}, {i, a,
b, (b - a)/
x}]; (*generates a list of the points for the line segments*)
distance[x_] :=
Sum[Sqrt[((b - a)/x)^2 + (f[i] - f[i - (b - a)/x])^2], {i,
a + (b - a)/x,
b, (b - a)/
x}];(*evaluates the approximate length of the line segment*)
================================
Manipulate[
Solutionab = x /. NSolve[f[x] == \[Alpha], x];
a1 = If[\[Alpha] < 50, Solutionab[[2]], Solutionab[[1]]];
b1 = If[\[Alpha] < 50, Solutionab[[3]], Solutionab[[2]]];
(*{a1,b1}=Select[Solutionab,-7\[LessEqual]#\[LessEqual]4&];*)
Solutionc1 =
y /. N[Solve[f[y] == Integrate[f[x], {x, a1, y}]/(y - a1), y]];
c1 = Select[Solutionc1, a1 + .1 < Re[#] < b1 &][[1]];
Solutionc2 =
y /. N[Solve[f[y] == Integrate[f[x], {x, y, b1}]/(b1 - y), y]];
c2 = Select[Solutionc2, a1 < Re[#] < b1 - .1 &][[1]];
(*{c}=Select[Solutionc,-7\[LessEqual]#\[LessEqual]4&& (#-a1)f[a1]\
\[Equal]Integrate[f[x],{x,a1,#}]&];*)
Grid[{
{Plot[{f[x], \[Alpha]} , {x, -7.5, 4.5}, Filling -> {1 -> Axis},
FillingStyle -> Directive[Opacity[0], Red],
AxesOrigin -> {0, 0}, PlotRange -> {{-7.5, 4.2}, {-15, 110}},
PlotStyle -> {{Thickness[.004], Blue}, {Thickness[.003], Dashed,
Red}},
Prolog -> {Text[Style["a", Medium, Italic, Blue], {a1, -10}],
Text[Style["b", Medium, Italic, Blue], {b1, -10}],
Text[Style["c", Medium, Italic, Blue], {c1, -10}],
{Gray, Dashed, Thickness[0.001], Line[{{a1, 0}, {a1, f[a1]}}]},
Text[
Style[Row[{Style["y", Italic], " = \[Alpha]"}], Medium,
Black], {3, \[Alpha] + 5}],
{Gray, Dashed, Thickness[0.001], Line[{{b1, 0}, {b1, f[b1]}}]},
{Blue, Opacity[.4], Rectangle[{a1, 0}, {c1, f[c1]}]},
{Yellow, Opacity[.5], Thickness[0.01],
Table[Line[{{a1 + h, 0}, {a1 + h, f[a1 + h]}}], {h, .1,
c1 - a1, .1}]},
{Gray, Dashed, Thickness[0.001], Line[{{c1, 0}, {c1, f[c1]}}]}},
Epilog -> {}, ImageSize -> {295, 200}],
Plot[{f[x], \[Alpha]} , {x, -7.5, 4.5}, Filling -> {1 -> Axis},
FillingStyle -> Directive[Opacity[0], Red],
AxesOrigin -> {0, 0}, PlotRange -> {{-7.5, 4.2}, {-15, 110}},
PlotStyle -> {{Thickness[.004], Blue}, {Thickness[.003], Dashed,
Red}},
Prolog -> {Text[Style["a", Medium, Italic, Blue], {a1, -10}],
Text[Style["b", Medium, Italic, Blue], {b1, -10}],
Text[Style["d", Medium, Italic, Blue], {c2, -10}],
{Gray, Dashed, Thickness[0.001], Line[{{a1, 0}, {a1, f[a1]}}]},
Text[
Style[Row[{Style["y", Italic], " = \[Alpha]"}], Medium,
Black], {3, \[Alpha] + 5}],
{Gray, Dashed, Thickness[0.001], Line[{{b1, 0}, {b1, f[b1]}}]},
{Blue, Opacity[.4], Rectangle[{c2, 0}, {b1, f[c2]}]}, {Yellow,
Opacity[.5], Thickness[0.01],
Table[Line[{{c2 + h, 0}, {c2 + h, f[c2 + h]}}], {h, 0,
b1 - c2, .1}]},
{Gray, Dashed, Thickness[0.001], Line[{{c1, 0}, {c1, f[c1]}}]}},
Epilog -> {}, ImageSize -> {295, 200}]},
{Text[Style["blue area = yellow area", 15, Blue]],
Text[Style["blue area = yellow area", 15, Blue]]
}}],
{{\[Alpha], 70, "\[Alpha]"}, 10, 100, Appearance -> "Labeled"},
SaveDefinitions -> True,
TrackedSymbols -> {\[Alpha]}
]
======================================
===================================================
Manipulate[
With[{ans = Integrate[func, {x, x1, x2}]},
Show[Graphics[
Plot[func, {x, -2, 2},
PlotLabel ->
Style[Framed[Row[{"Area = ", NumberForm[ans, {2, 4}]}]],
If[ans > 0, RGBColor[1, .47, 0], RGBColor[.12, .61, .78]], 12,
"Label"] ]],
Graphics[
If[x1 == x2, {},
Plot[func, {x, x1, x2}, Filling -> 0 ,
FillingStyle ->
If[ans > 0, RGBColor[1, .47, 0], RGBColor[.12, .61, .78]]]]],
ImageSize -> {350, 350}]], {{x1 , 0, "x1"}, -2, 2,
Appearance -> "Labeled"}, {{x2, 1, "x2"}, -2, 2,
Appearance -> "Labeled"} , {{func , f1,
"curve"} , {f1 -> "constant line", f2 -> "sine wave",
f3 -> "parabola"}, ControlType -> SetterBar},
SaveDefinitions -> True ]
===================================================
A Riemann sum is an approximation to the area between a curve and the x axis, made by adding together the areas of a set of rectangles. A summation calculation is involved, of the form Sum[f(x)./\x], where /\x is the width of each rectangle. The limit of the Riemann sum as /\x approaches zero is the (Riemann) integral of the function. This manipulation uses a left Riemann sum, in which the value of f(x) that is used is the one at the left edge of each rectangle. It is easy to adapt the code for right Riemann sums and for the trapezoidal rule; try it!