Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5302
| From | "Rob Y. H. Chai" <yhchai@ucdavis.edu> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Integrating a Piecewise function four times but different results |
| Date | 2011-10-01 07:08 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j66e9t$hch$1@smc.vnet.net> (permalink) |
Hello everyone,
I tried to integrate a piecewise function 4 times but got different results
for two supposedly identical cases. The integration was done in the Mathematica
version 8.0.1.0. I am interested in what I did wrong, so any comments will
be appreciated. My code is below.
Sincerely
Rob Y. H. Chai
UC Davis
(* Introduction p1[x] as piecewise funtion *)
p1[x_] = Piecewise[{{2*wmax*x/L, x <= L/2}, {2*wmax*(1 - x/L), x > L/2}}];
(* p2[x] is a specialized case of p1[x] with wmax = 1 and L = 1 *)
p2[x_] = p1[x] /. wmax -> 1 /. L -> 1;
(* now integrate p1[x] 4 times and introduce integration constants *)
soln1[x_] = Integrate[Integrate[Integrate[Integrate[p1[x], x], x], x], x] +
a*x^3 + b*x^2 + c*x + d ;
(* solve for integration constants in the solution of p1[x] *)
eq1a = soln1[0] == 0;
eq1b = (D[soln1[x], {x, 2}] /. x -> 0) == 0;
eq1c = soln1[L] == 0;
eq1d = ( D[soln1[x], {x, 2}] /. x -> L) == 0;
soln1A[x_] = soln1[x] /. Simplify[Solve[{eq1a, eq1b, eq1c, eq1d}, {a, b, c,
d}], L > 0][[1]];
(* check case 1 solution at x = L/2 *)
soln1A[L/2] /. wmax -> 1 /. L -> 1
17/1920
(* similarly integrate p2[x] 4 times and introduce integration constants *)
soln2[x_] = Integrate[Integrate[Integrate[Integrate[p2[x], x], x], x], x] +
r*x^3 + s*x^2 + u*x + v;
(* solve for integration constants in the solution of p2[x] *)
eq2a = soln2[0] == 0;
eq2b = (D[soln2[x], {x, 2}] /. x -> 0) == 0;
eq2c = soln2[1] == 0;
eq2d = ( D[soln2[x], {x, 2}] /. x -> 1) == 0;
soln2A[x_] = soln2[x] /. Simplify[Solve[{eq2a, eq2b, eq2c, eq2d}, {r, s, u,
v}]][[1]];
soln2A[1/2] (* case 2 solution at x = 1/2 *)
1/120
Plot[{soln1A[x] /. wmax -> 1 /. L -> 1, soln2A[x]}, {x, 0, 1}]
Question - why doesn't case 1 solution converge to case 2 solution when case
2 is simply a special case of case 1?
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Integrating a Piecewise function four times but different results "Rob Y. H. Chai" <yhchai@ucdavis.edu> - 2011-10-01 07:08 +0000 Re: Integrating a Piecewise function four times but different results Peter Pein <petsie@dordos.net> - 2011-10-02 06:41 +0000
csiph-web