Skip to main content
Became Hot Network Question
added 6 characters in body
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13

I tried two ways of substituting which should have be equivalent.

(1) The fist way is that I collected varsol and dvarsol in a global variablea global variable solGolbal then do the substituting, and thesubstituting;

(2)The second way is that I collected varsol and dvarsol in a local variablelocal variable solModule and then do the substituting.

-------The The above code is fine. The problem occured in following lines.   ------

 

figure   

The problem confusing me is :

Why did dpdxGlobal[t] hashave one more term than dpdxModule[t], as shown in the red box in my second figure?

I tried two ways of substituting which should have be equivalent. The fist way is that I collected varsol and dvarsol in a global variable solGolbal then do the substituting, and the second way is that I collected varsol and dvarsol in a local variable solModule and then do the substituting.

-------The above code is fine. The problem occured in following lines. ------

figure  The problem confusing me is :

Why dpdxGlobal[t] has one more term than dpdxModule[t] as shown in the red box in my second figure?

I tried two ways of substituting which should have be equivalent.

(1) The fist way is that I collected varsol and dvarsol in a global variable solGolbal then do the substituting;

(2)The second way is that I collected varsol and dvarsol in a local variable solModule and then do the substituting.

------- The above code is fine. The problem occured in following lines.   ------

 

figure 

The problem confusing me is :

Why did dpdxGlobal[t] have one more term than dpdxModule[t], as shown in the red box in my second figure?

deleted 44 characters in body
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13

The results of these two ways I think should be the same, however they showd apparent differencedifference (i.e., the global way has one more term than the local way, as shown in the red box in the figure below).

compute[_] := Module[{solModule}, solModule = {varsol, dvarsol} // Flatten;(*local way*) solGolbalsolModule = {varsol, dvarsol} // Flatten;  dpdxModule[t_] = Evaluate[(-1000 D[U, t] + S)[[5]] /. solModule];  (*global way*)   solGolbal = {varsol, dvarsol} // Flatten; dpdxGlobal[t_] = Evaluate[(-1000 D[U, t] + S)[[5]] /. solGolbal]; Print[solModule - solGolbal]; {dpdxModule[t], dpdxGlobal[t]}]; F[t_] = compute[1];   F[t](*global way has one more term than local way*) ParametricPlot[{{vp[t], F[t][[1]]}, {vp[t], F[t][[2]]}}, {t, 5 T, 6 T}, AspectRatio -> 1/GoldenRatio, PlotLegends -> {"use module solution", "use global solution"}] 

The results of these two ways I think should be the same, however they showd apparent difference as shown in the figure below.

compute[_] := Module[{solModule}, solModule = {varsol, dvarsol} // Flatten; solGolbal = {varsol, dvarsol} // Flatten; dpdxModule[t_] = Evaluate[(-1000 D[U, t] + S)[[5]] /. solModule]; dpdxGlobal[t_] = Evaluate[(-1000 D[U, t] + S)[[5]] /. solGolbal]; Print[solModule - solGolbal]; {dpdxModule[t], dpdxGlobal[t]}]; F[t_] = compute[1]; F[t] ParametricPlot[{{vp[t], F[t][[1]]}, {vp[t], F[t][[2]]}}, {t, 5 T, 6 T}, AspectRatio -> 1/GoldenRatio, PlotLegends -> {"use module solution", "use global solution"}] 

The results of these two ways I think should be the same, however they showd apparent difference (i.e., the global way has one more term than the local way, as shown in the red box in the figure below).

compute[_] := Module[{solModule}, (*local way*) solModule = {varsol, dvarsol} // Flatten;  dpdxModule[t_] = Evaluate[(-1000 D[U, t] + S)[[5]] /. solModule];  (*global way*)   solGolbal = {varsol, dvarsol} // Flatten; dpdxGlobal[t_] = Evaluate[(-1000 D[U, t] + S)[[5]] /. solGolbal]; Print[solModule - solGolbal]; {dpdxModule[t], dpdxGlobal[t]}]; F[t_] = compute[1];   F[t](*global way has one more term than local way*) ParametricPlot[{{vp[t], F[t][[1]]}, {vp[t], F[t][[2]]}}, {t, 5 T, 6 T}, AspectRatio -> 1/GoldenRatio, PlotLegends -> {"use module solution", "use global solution"}] 
deleted 44 characters in body
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13

figure As you can see, theThe problem shouldconfusing me is :

Why dpdxGlobal[t] has one more term than dpdxModule[t] as shown in the last several lines of code. Where did difference between the two results come from? and Why? Is this a possible bugred box in my second figure?

figuredpdxGlobal[t] has one more term than dpdxModule[t]

As you can see, the problem should in the last several lines of code. Where did difference between the two results come from? and Why? Is this a possible bug?

figure

figure The problem confusing me is :

Why dpdxGlobal[t] has one more term than dpdxModule[t] as shown in the red box in my second figure?

dpdxGlobal[t] has one more term than dpdxModule[t]

deleted 44 characters in body
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading
edited title
Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading
added 27 characters in body
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading
added 137 characters in body
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading
Source Link
xinxin guo
  • 1.5k
  • 11
  • 13
Loading