Work of a force field [closed]
$begingroup$
I have a parameter curve in 3d:
r1[t_] := {Cos[2 Pi t], Sin[2 Pi t], t}
r2[t_] := {1, 0, t}
r3[t_] := {1 - 1/2 Sin[Pi t], 0, 1/2 - Cos[Pi t]}
with a vector field:
F[x_, y_, z_] := {-2 x y + z^3, -1 - x^2, 3 x z^2};
r = {x, y, z}
Now I want to calculate work of force field as the path integral for r1
, r2
and r3
as a procedure, that uses arguments F(r)
and r(t)
and times t0
& t1
.
Has someone an idea how to realize it into Mathematica code?
Thanks a lot!
looks great!
I also want to visualize the curves in a ParametricPlot3D, I did this:
r1[t] = ParametricPlot3D[{{Cos[2*Pi*t], Sin[2*Pi*t], t}}, {t, 0, 1}]
r2[t] = ParametricPlot3D[{{1, 0, t}}, {t, 0, 1}]
r3[t] = ParametricPlot3D[{{1 - 1/2*Sin[Pi*t], 0,
1/2*(1 - Cos[Pi*t])}}, {t, 0, 1}]
How can I define the path of the curves from (1,0,0) to (1,0,1)
?
function-construction physics
$endgroup$
closed as off-topic by MarcoB, Henrik Schumacher, Αλέξανδρος Ζεγγ, zhk, bbgodfrey Dec 24 '18 at 21:29
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Henrik Schumacher, Αλέξανδρος Ζεγγ, zhk, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
I have a parameter curve in 3d:
r1[t_] := {Cos[2 Pi t], Sin[2 Pi t], t}
r2[t_] := {1, 0, t}
r3[t_] := {1 - 1/2 Sin[Pi t], 0, 1/2 - Cos[Pi t]}
with a vector field:
F[x_, y_, z_] := {-2 x y + z^3, -1 - x^2, 3 x z^2};
r = {x, y, z}
Now I want to calculate work of force field as the path integral for r1
, r2
and r3
as a procedure, that uses arguments F(r)
and r(t)
and times t0
& t1
.
Has someone an idea how to realize it into Mathematica code?
Thanks a lot!
looks great!
I also want to visualize the curves in a ParametricPlot3D, I did this:
r1[t] = ParametricPlot3D[{{Cos[2*Pi*t], Sin[2*Pi*t], t}}, {t, 0, 1}]
r2[t] = ParametricPlot3D[{{1, 0, t}}, {t, 0, 1}]
r3[t] = ParametricPlot3D[{{1 - 1/2*Sin[Pi*t], 0,
1/2*(1 - Cos[Pi*t])}}, {t, 0, 1}]
How can I define the path of the curves from (1,0,0) to (1,0,1)
?
function-construction physics
$endgroup$
closed as off-topic by MarcoB, Henrik Schumacher, Αλέξανδρος Ζεγγ, zhk, bbgodfrey Dec 24 '18 at 21:29
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Henrik Schumacher, Αλέξανδρος Ζεγγ, zhk, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.
1
$begingroup$
It should beCos[2*Pi*t]
orCos[2 Pi t]
, notcos(2*Pi*t)
.
$endgroup$
– Henrik Schumacher
Dec 16 '18 at 12:56
add a comment |
$begingroup$
I have a parameter curve in 3d:
r1[t_] := {Cos[2 Pi t], Sin[2 Pi t], t}
r2[t_] := {1, 0, t}
r3[t_] := {1 - 1/2 Sin[Pi t], 0, 1/2 - Cos[Pi t]}
with a vector field:
F[x_, y_, z_] := {-2 x y + z^3, -1 - x^2, 3 x z^2};
r = {x, y, z}
Now I want to calculate work of force field as the path integral for r1
, r2
and r3
as a procedure, that uses arguments F(r)
and r(t)
and times t0
& t1
.
Has someone an idea how to realize it into Mathematica code?
Thanks a lot!
looks great!
I also want to visualize the curves in a ParametricPlot3D, I did this:
r1[t] = ParametricPlot3D[{{Cos[2*Pi*t], Sin[2*Pi*t], t}}, {t, 0, 1}]
r2[t] = ParametricPlot3D[{{1, 0, t}}, {t, 0, 1}]
r3[t] = ParametricPlot3D[{{1 - 1/2*Sin[Pi*t], 0,
1/2*(1 - Cos[Pi*t])}}, {t, 0, 1}]
How can I define the path of the curves from (1,0,0) to (1,0,1)
?
function-construction physics
$endgroup$
I have a parameter curve in 3d:
r1[t_] := {Cos[2 Pi t], Sin[2 Pi t], t}
r2[t_] := {1, 0, t}
r3[t_] := {1 - 1/2 Sin[Pi t], 0, 1/2 - Cos[Pi t]}
with a vector field:
F[x_, y_, z_] := {-2 x y + z^3, -1 - x^2, 3 x z^2};
r = {x, y, z}
Now I want to calculate work of force field as the path integral for r1
, r2
and r3
as a procedure, that uses arguments F(r)
and r(t)
and times t0
& t1
.
Has someone an idea how to realize it into Mathematica code?
Thanks a lot!
looks great!
I also want to visualize the curves in a ParametricPlot3D, I did this:
r1[t] = ParametricPlot3D[{{Cos[2*Pi*t], Sin[2*Pi*t], t}}, {t, 0, 1}]
r2[t] = ParametricPlot3D[{{1, 0, t}}, {t, 0, 1}]
r3[t] = ParametricPlot3D[{{1 - 1/2*Sin[Pi*t], 0,
1/2*(1 - Cos[Pi*t])}}, {t, 0, 1}]
How can I define the path of the curves from (1,0,0) to (1,0,1)
?
function-construction physics
function-construction physics
edited Dec 17 '18 at 5:38
march
17.4k22769
17.4k22769
asked Dec 16 '18 at 12:47
TomTom
805
805
closed as off-topic by MarcoB, Henrik Schumacher, Αλέξανδρος Ζεγγ, zhk, bbgodfrey Dec 24 '18 at 21:29
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Henrik Schumacher, Αλέξανδρος Ζεγγ, zhk, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by MarcoB, Henrik Schumacher, Αλέξανδρος Ζεγγ, zhk, bbgodfrey Dec 24 '18 at 21:29
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Henrik Schumacher, Αλέξανδρος Ζεγγ, zhk, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.
1
$begingroup$
It should beCos[2*Pi*t]
orCos[2 Pi t]
, notcos(2*Pi*t)
.
$endgroup$
– Henrik Schumacher
Dec 16 '18 at 12:56
add a comment |
1
$begingroup$
It should beCos[2*Pi*t]
orCos[2 Pi t]
, notcos(2*Pi*t)
.
$endgroup$
– Henrik Schumacher
Dec 16 '18 at 12:56
1
1
$begingroup$
It should be
Cos[2*Pi*t]
or Cos[2 Pi t]
, not cos(2*Pi*t)
.$endgroup$
– Henrik Schumacher
Dec 16 '18 at 12:56
$begingroup$
It should be
Cos[2*Pi*t]
or Cos[2 Pi t]
, not cos(2*Pi*t)
.$endgroup$
– Henrik Schumacher
Dec 16 '18 at 12:56
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
It is more about physics, rather than Mathematica. You should express the work as follows: $ intvec{F}cdotvec{r}_1'(t), mathrm dt $ After that it is easy to write the Mathematica expression:
Integrate[
F[r1[t][[1]], r1[t][[2]], r1[t][[3]]].D[r1[t], t], {t, t0, t1}]
(* 1/4 (-4 t0^3 Cos[2 [Pi] t0] + 4 t1^3 Cos[2 [Pi] t1] +
5 Sin[2 [Pi] t0] + Sin[6 [Pi] t0] - 5 Sin[2 [Pi] t1] -
Sin[6 [Pi] t1]) *)
The rest you can do analogously.
Have fun!
$endgroup$
add a comment |
$begingroup$
I guess codes below would work:
(F @@ #).D[#, t] & /@ {r1[t], r2[t], r3[t]} // Simplify
Integrate[%, {t, t0, t1}]
$endgroup$
add a comment |
$begingroup$
Here are two ways, one involving DSolve
and differential one-forms (the first one is like the others, except for being packaged up in a line integral function). See this answer by LLlAMnYP for the DSolve
approach.
ClearAll[lineInt];
(* integrate a vector field *)
lineInt[F_?VectorQ, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[Integrate]] :=
Integrate[(F /. Thread[c]).D[rt, t], {t, a, b}, opts];
(* integrate a one form *)
oneFormQ[ω_, X_] := (* linear && homogenenous in differentials Dt@X *)
Internal`LinearQ[ω, Dt[X]] && PossibleZeroQ[ω /. Thread[Dt[X] -> 0]];
lineInt[ω_, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[DSolve]] := Module[{W},
DSolveValue[
{{Dt[W[t]] == ω, Dt[X] == Dt[rt]} /. Thread[X -> Through[X[t]]],
W[a] == 0, Through[X[a]] == rt /. t -> a},
W[b],
t, opts] /; oneFormQ[ω, X]
];
X = {x, y, z};
lineInt[(F @@ X).Dt[X], X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{0.196, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
lineInt[F @@ X, X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{2.19, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
Integrate
must do a lot of checking that DSolve
skips, I guess.
$endgroup$
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
It is more about physics, rather than Mathematica. You should express the work as follows: $ intvec{F}cdotvec{r}_1'(t), mathrm dt $ After that it is easy to write the Mathematica expression:
Integrate[
F[r1[t][[1]], r1[t][[2]], r1[t][[3]]].D[r1[t], t], {t, t0, t1}]
(* 1/4 (-4 t0^3 Cos[2 [Pi] t0] + 4 t1^3 Cos[2 [Pi] t1] +
5 Sin[2 [Pi] t0] + Sin[6 [Pi] t0] - 5 Sin[2 [Pi] t1] -
Sin[6 [Pi] t1]) *)
The rest you can do analogously.
Have fun!
$endgroup$
add a comment |
$begingroup$
It is more about physics, rather than Mathematica. You should express the work as follows: $ intvec{F}cdotvec{r}_1'(t), mathrm dt $ After that it is easy to write the Mathematica expression:
Integrate[
F[r1[t][[1]], r1[t][[2]], r1[t][[3]]].D[r1[t], t], {t, t0, t1}]
(* 1/4 (-4 t0^3 Cos[2 [Pi] t0] + 4 t1^3 Cos[2 [Pi] t1] +
5 Sin[2 [Pi] t0] + Sin[6 [Pi] t0] - 5 Sin[2 [Pi] t1] -
Sin[6 [Pi] t1]) *)
The rest you can do analogously.
Have fun!
$endgroup$
add a comment |
$begingroup$
It is more about physics, rather than Mathematica. You should express the work as follows: $ intvec{F}cdotvec{r}_1'(t), mathrm dt $ After that it is easy to write the Mathematica expression:
Integrate[
F[r1[t][[1]], r1[t][[2]], r1[t][[3]]].D[r1[t], t], {t, t0, t1}]
(* 1/4 (-4 t0^3 Cos[2 [Pi] t0] + 4 t1^3 Cos[2 [Pi] t1] +
5 Sin[2 [Pi] t0] + Sin[6 [Pi] t0] - 5 Sin[2 [Pi] t1] -
Sin[6 [Pi] t1]) *)
The rest you can do analogously.
Have fun!
$endgroup$
It is more about physics, rather than Mathematica. You should express the work as follows: $ intvec{F}cdotvec{r}_1'(t), mathrm dt $ After that it is easy to write the Mathematica expression:
Integrate[
F[r1[t][[1]], r1[t][[2]], r1[t][[3]]].D[r1[t], t], {t, t0, t1}]
(* 1/4 (-4 t0^3 Cos[2 [Pi] t0] + 4 t1^3 Cos[2 [Pi] t1] +
5 Sin[2 [Pi] t0] + Sin[6 [Pi] t0] - 5 Sin[2 [Pi] t1] -
Sin[6 [Pi] t1]) *)
The rest you can do analogously.
Have fun!
edited Dec 16 '18 at 13:40
Αλέξανδρος Ζεγγ
4,4311929
4,4311929
answered Dec 16 '18 at 13:36
Alexei BoulbitchAlexei Boulbitch
21.8k2470
21.8k2470
add a comment |
add a comment |
$begingroup$
I guess codes below would work:
(F @@ #).D[#, t] & /@ {r1[t], r2[t], r3[t]} // Simplify
Integrate[%, {t, t0, t1}]
$endgroup$
add a comment |
$begingroup$
I guess codes below would work:
(F @@ #).D[#, t] & /@ {r1[t], r2[t], r3[t]} // Simplify
Integrate[%, {t, t0, t1}]
$endgroup$
add a comment |
$begingroup$
I guess codes below would work:
(F @@ #).D[#, t] & /@ {r1[t], r2[t], r3[t]} // Simplify
Integrate[%, {t, t0, t1}]
$endgroup$
I guess codes below would work:
(F @@ #).D[#, t] & /@ {r1[t], r2[t], r3[t]} // Simplify
Integrate[%, {t, t0, t1}]
edited Dec 16 '18 at 13:39
answered Dec 16 '18 at 13:26
Αλέξανδρος ΖεγγΑλέξανδρος Ζεγγ
4,4311929
4,4311929
add a comment |
add a comment |
$begingroup$
Here are two ways, one involving DSolve
and differential one-forms (the first one is like the others, except for being packaged up in a line integral function). See this answer by LLlAMnYP for the DSolve
approach.
ClearAll[lineInt];
(* integrate a vector field *)
lineInt[F_?VectorQ, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[Integrate]] :=
Integrate[(F /. Thread[c]).D[rt, t], {t, a, b}, opts];
(* integrate a one form *)
oneFormQ[ω_, X_] := (* linear && homogenenous in differentials Dt@X *)
Internal`LinearQ[ω, Dt[X]] && PossibleZeroQ[ω /. Thread[Dt[X] -> 0]];
lineInt[ω_, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[DSolve]] := Module[{W},
DSolveValue[
{{Dt[W[t]] == ω, Dt[X] == Dt[rt]} /. Thread[X -> Through[X[t]]],
W[a] == 0, Through[X[a]] == rt /. t -> a},
W[b],
t, opts] /; oneFormQ[ω, X]
];
X = {x, y, z};
lineInt[(F @@ X).Dt[X], X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{0.196, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
lineInt[F @@ X, X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{2.19, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
Integrate
must do a lot of checking that DSolve
skips, I guess.
$endgroup$
add a comment |
$begingroup$
Here are two ways, one involving DSolve
and differential one-forms (the first one is like the others, except for being packaged up in a line integral function). See this answer by LLlAMnYP for the DSolve
approach.
ClearAll[lineInt];
(* integrate a vector field *)
lineInt[F_?VectorQ, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[Integrate]] :=
Integrate[(F /. Thread[c]).D[rt, t], {t, a, b}, opts];
(* integrate a one form *)
oneFormQ[ω_, X_] := (* linear && homogenenous in differentials Dt@X *)
Internal`LinearQ[ω, Dt[X]] && PossibleZeroQ[ω /. Thread[Dt[X] -> 0]];
lineInt[ω_, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[DSolve]] := Module[{W},
DSolveValue[
{{Dt[W[t]] == ω, Dt[X] == Dt[rt]} /. Thread[X -> Through[X[t]]],
W[a] == 0, Through[X[a]] == rt /. t -> a},
W[b],
t, opts] /; oneFormQ[ω, X]
];
X = {x, y, z};
lineInt[(F @@ X).Dt[X], X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{0.196, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
lineInt[F @@ X, X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{2.19, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
Integrate
must do a lot of checking that DSolve
skips, I guess.
$endgroup$
add a comment |
$begingroup$
Here are two ways, one involving DSolve
and differential one-forms (the first one is like the others, except for being packaged up in a line integral function). See this answer by LLlAMnYP for the DSolve
approach.
ClearAll[lineInt];
(* integrate a vector field *)
lineInt[F_?VectorQ, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[Integrate]] :=
Integrate[(F /. Thread[c]).D[rt, t], {t, a, b}, opts];
(* integrate a one form *)
oneFormQ[ω_, X_] := (* linear && homogenenous in differentials Dt@X *)
Internal`LinearQ[ω, Dt[X]] && PossibleZeroQ[ω /. Thread[Dt[X] -> 0]];
lineInt[ω_, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[DSolve]] := Module[{W},
DSolveValue[
{{Dt[W[t]] == ω, Dt[X] == Dt[rt]} /. Thread[X -> Through[X[t]]],
W[a] == 0, Through[X[a]] == rt /. t -> a},
W[b],
t, opts] /; oneFormQ[ω, X]
];
X = {x, y, z};
lineInt[(F @@ X).Dt[X], X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{0.196, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
lineInt[F @@ X, X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{2.19, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
Integrate
must do a lot of checking that DSolve
skips, I guess.
$endgroup$
Here are two ways, one involving DSolve
and differential one-forms (the first one is like the others, except for being packaged up in a line integral function). See this answer by LLlAMnYP for the DSolve
approach.
ClearAll[lineInt];
(* integrate a vector field *)
lineInt[F_?VectorQ, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[Integrate]] :=
Integrate[(F /. Thread[c]).D[rt, t], {t, a, b}, opts];
(* integrate a one form *)
oneFormQ[ω_, X_] := (* linear && homogenenous in differentials Dt@X *)
Internal`LinearQ[ω, Dt[X]] && PossibleZeroQ[ω /. Thread[Dt[X] -> 0]];
lineInt[ω_, c : (X_?VectorQ -> rt_?VectorQ), {t_, a_, b_},
opts : OptionsPattern[DSolve]] := Module[{W},
DSolveValue[
{{Dt[W[t]] == ω, Dt[X] == Dt[rt]} /. Thread[X -> Through[X[t]]],
W[a] == 0, Through[X[a]] == rt /. t -> a},
W[b],
t, opts] /; oneFormQ[ω, X]
];
X = {x, y, z};
lineInt[(F @@ X).Dt[X], X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{0.196, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
lineInt[F @@ X, X -> r1[t], {t, t0, t1}] // RepeatedTiming
(*
{2.19, 1/4 (-4 t0^3 Cos[2 π t0] + 4 t1^3 Cos[2 π t1] +
5 Sin[2 π t0] + Sin[6 π t0] - 5 Sin[2 π t1] -
Sin[6 π t1])}
*)
Integrate
must do a lot of checking that DSolve
skips, I guess.
edited Dec 17 '18 at 14:57
answered Dec 16 '18 at 20:32
Michael E2Michael E2
148k12198478
148k12198478
add a comment |
add a comment |
1
$begingroup$
It should be
Cos[2*Pi*t]
orCos[2 Pi t]
, notcos(2*Pi*t)
.$endgroup$
– Henrik Schumacher
Dec 16 '18 at 12:56