Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 34 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Abdoulaye Your F is an expression, not a procedure, so F(t-2*Pi) and F(t) are nonsense. Unfortunately, Maple allows this nonsense without any complaint. Also, you forgot to add 2*Pi to the lower bounds of integration. Here's a corrected worksheet,

restart:

Digits:= 15:

F:= t-> piecewise(
     5.442116637 <= t and t <= 8.035505284,
          -20.20246287+6.560150625*t-.5000000000*t^2-1.500000000*cos(t),
     8.035505284 <= t and t <= 8.583709290, .4977821578,
     8.583709290 <= t and t <= 11.17709794,
          45.93469349-9.701743279*t+.5000000000*t^2-1.500000000*cos(t),
     11.17709794 <= t and t <= 11.72530194, -.3096747114,
     11.72530194 <= t and t <= 14.31869059,
          -81.16031365+12.84333593*t-.5000000000*t^2-1.500000000*cos(t),
     14.31869059 <= t and t <= 14.86689460, .4977820960,
     14.86689460 <= t and t <= 17.46028325,
          126.6317531-15.98492859*t+.5000000000*t^2-1.500000000*cos(t)
):

F(t);

piecewise(5.442116637 <= t and t <= 8.035505284, -20.20246287+6.560150625*t-.5000000000*t^2-1.500000000*cos(t), 8.035505284 <= t and t <= 8.583709290, .4977821578, 8.583709290 <= t and t <= 11.17709794, 45.93469349-9.701743279*t+.5000000000*t^2-1.500000000*cos(t), 11.17709794 <= t and t <= 11.72530194, -.3096747114, 11.72530194 <= t and t <= 14.31869059, -81.16031365+12.84333593*t-.5000000000*t^2-1.500000000*cos(t), 14.31869059 <= t and t <= 14.86689460, .4977820960, 14.86689460 <= t and t <= 17.46028325, 126.6317531-15.98492859*t+.5000000000*t^2-1.500000000*cos(t))

ab:= t= op([1,1,1],F(t))+2*Pi..op([-2,-1,-1],F(t));

t = 11.7253019441796 .. 17.46028325

pNorm:= (p::{positive, identical(infinity)}, F::algebraic, ab::(name=range(realcons)))->
     `if`(p=infinity, numapprox:-infnorm(F, ab), evalf(Int(abs(F)^p, ab, _rest)^(1/p)))
:

for p in [1, 2, infinity] do pNorm(p, F(t-2*Pi) - F(t), ab, epsilon= 1e-8) end do;

0.273125234416635e-6

0.136445621979369e-6

0.121380938300497e-6

 

Download infnorm.mw

@Christian Wolinski There is no command OperandsTable. Is that something that you wrote but forgot to include above?

@Traruh Synred Sorry if I'm being repetitive about this, but I think that once you understand what a statement is, then this colon/semicolon stuff makes sense. Your code test:= proc() is not a statement---any proc() without a matching end is not syntactically correct. Other points that promote understanding of this ("semicolon" is interchangeable with "colon" throughout):

  1. Semicolons do not terminate statements; just like in English, they separate statements. Also, they separate certain parts of a proc or module definition, like separating the local declarations from the body.
  2. The empty statement is a statement.
  3. Every proc and module has at least one statement, possibly empty.
  4. A semicolon is allowed, but never required, at the end of a statement before end, else, elif, catch, od, or fi---there is no statement that it needs to be separated from.

@Traruh Synred wrote:

It seems an odd syntacs as I would have expected a dlimiter after the proc statement is defined and maple 15 puts them in in most cases even if you forget. [Emphasis added.]

Ah, but proc(...) is not a statement, nor is P:= proc(...) a statement. They are only the beginnings of statements; P:= proc(...) ... end proc is a statement. The fact that one usually begins a new line after a certain piece of code does not make it a statement.

@Markiyan Hirnyk Why did you choose the values for numpoints that you chose: 7 and 10? Is it just to make the computation faster? The left plot ends up using 39 points, and the right 23.

@tomleslie Vote up. The square brackets is the issue. If you'd gone further, you'd've seen that the plot works correctly with its five legends, but is, as you say, boring.

@Mac Dude What difference does that make?

@  Dr Venkat Subramanian

The issue is getting a good-looking (and, of course, accurate) plot. It is not necessary to know or to extract the points used internally by dsolve to do this. Yes, plot will by default use 201 points, unless its adaptive scheme decides that more are necessary. Each value of the independent variable chosen by plot is passed to the solution procedure(s) returned by dsolve. Those procedures may (and very likely do) use intermediate values of the independent variable to generate intermediate points. There is no need for those points to appear in the final output. Indeed, there are cases where using fewer points produces a smoother-looking plot. (Using plots:-implicitplot with the resolution option is a good way to generate an example of this.)

@Markiyan Hirnyk The issue is that the OP wants to generate a good-looking plot (no inaccurate sharp turns) without needing to select the points in an ad hoc way. To use the output= Array option, one needs to know a priori which values of the independent variable to use.

@shakuntala This back-and-forth with you not understanding is getting very frustrating, so you need to "come clean" about what exactly you're trying to do. Are you working on a course assignment? Are you working from a book? Please present the assignment or book problem in full.

What is your primary spoken language? If this question is part of a course, what is the language of instruction? If you're working from a book, what language is it written in?

@shakuntala In your originally posted code, you have the line blt:= 10. I assumed that this was still in effect. If it's not, then you must be solving a different ODE problem, in which case X21 and X11 wouldn't make sense either.

@acer If the OP is performing the NLPSolve inside a loop, as claimed, I'd more strongly recommend against using assign. It's still possible to use assign combined with some method of unassigning (either command unassign or assignments such as th:= 'th'), but that quickly turns into a mess. (Of course, I know that you know all the above; I just think that you may have missed the OP's "in a loop" issue.)

@shakuntala Yes, it's easy to combine any number of plots into one. One way is

plot([X11, X21], 0..blt);

The command plots:-display can be used in more-complicated cases:

plots:-display(
     plot(X11, 0..blt),
     plot(X21, 0..blt)

);

The inner plot commands can be any, as long as they all have the same dimension (two or three).

@Abdoulaye No, it doesn't help. There's a discontinuity in the link up of the two pieces at t = 11.72530194.

@jojokaila You can simplify the input of column vectors by using angle brackets:

A:= < 1/sqrt(2), 0, 0, 1/sqrt(2) >;

First 383 384 385 386 387 388 389 Last Page 385 of 709