Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 362 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Axel Vogt No, it's not at all clear, unless you mean that it's clear visually for this particular example. Such an analysis goes far beyond the scope of what was asked, and isn't necessary for most of the computational applications for which one would use the parametrization of a piecewise-linear curve.

@Christopher2222 You wrote:

the only way I think Mathematica could fix that image the way they show is if Mathematica itself blurred the image in the first place. 

At first I was inclined to agree totally with you; however, having now read the entire help page (including all 21 examples), I believe that there's something very powerful about this Mathematica command, and that Maple should strive for something similar. While the specific example of the Moon-landing photo may be the result of what you suggest, the license plate example seems genuine. 

Please post questions in the Questions section rather than the Posts section. (I've already moved this one.)

What is the variable with respect to which the integration is to be performed? What do you mean by "solve this for t"? Do you mean that t is the variable of integration? Can you make some assumptions about the parameters? real? positive?

9009134: Please don't post a new thread (a new Question) that is simply a reformulation of your own existing Question. It will be deleted. You can edit your original Question, or post a Reply to it. Either of these will put the Question back at the top of the Active Conversations stack, which has the essentially the same effect as posting a new Question without making people angry with you.

Markiyan: I do appreciate your spotting of duplicates. You have quite a talent for it. Instead of posting a Reply to the duplicate, please delete the duplicate and post a Reply to the original. Posting a Reply to the duplicate makes it more difficult for someone else to delete it. Failing to delete the duplicate increases the chance that someone will inadvertently post a legitimate Answer to it, at which point I'd feel that it's unethical to delete it (there being no way that I know of to move the legitimate Answer over to the original Question).

@Rouben Rostamian  

Please post your short and well-organized worksheets inline.

I generalized your procedure to an arbitrary number of dimensions. Often making such a generalization also shows one how to simplify.


restart:

Input: A list of n-dimensional points, where each point is a list of n real numbers. The list of points is regarded as defining a piecewise-linear curve.

 

Output: A sequence of always two items (regardless of dimension). The second is the total arclength T of the curve. The first is a procedure F(t) which returns a list of n real numbers that represents a point on the curve if t is between 0 and T.

 

#Parametrize a Piecewise-Linear Curve by Arclength in any number of Dimensions.
PPLCAnD:= proc(P::listlist(realcons))
local
     t, k, n:= nops(P),
     dist:= (u,v)-> sqrt(`+`(((u-~v)^~2)[])),
     L:= ListTools:-PartialSums([0, seq(dist(P[k+1],P[k]), k= 1..n-1)])
;
     unapply(
          piecewise(
               seq('t <= L[k+1], P[k]+~(t-L[k])/(L[k+1]-L[k])*~(P[k+1]-P[k])', k= 1..n-1)
          ), t
     ), L[-1]
end proc:

     

LL:= [[1.1, 2.04], [1.97, 4.04], [2.96, 2.97], [4.5, 6.4], [5.08, 7.21], [1.1, 4.04], [1.1, 2.04]]:

(F,T):= PPLCAnD(LL):

F(T/2);

[4.69962396245103, 6.67878518894023]

plot([F(t)[1], F(t)[2], t= 0..T], color="Green", thickness=4);

LLL:= [[1.1, 2.04, 0], [1.97, 4.04, 1], [2.96, 2.97, 2], [4.5, 6.4, 3], [5.08, 7.21, 4], [1.1, 4.04, 5], [1.1, 2.04, 0]]:

(F,T):= PPLCAnD(LLL):

F(T/2);

[4.65732005921038, 6.87334286123041, 4.10620099014815]

plots:-spacecurve([F(t)[1], F(t)[2], F(t)[3]], t= 0..T);

 


Download Piecewise_Linear_by_Arclength.mw

@Rouben Rostamian  Your Reply just reminded me of another way:

c:= a[i],b[i]:
seq(c, i= 1..3);

However---warning---an indirect reference to seq's (or add's or mul's) index variable through a local variable (as in a procedure) won't work without a forced eval. This applies to both the example that you gave in your Reply and the one that I gave immediately above. Here's an example:

This doesn't work:

proc() local c:= (a[i],b[i]); seq(c, i= 1..3) end();

It needs to be changed to this:

proc() local c:= (a[i],b[i]); seq(eval(c), i= 1..3) end();

This phenomenon is due to an unfortuitous combination of local variable's single-level evaluation (which I've discussed extensively in recent posts) and seq's, add's, and mul's special evaluation rules.

Regarding $: Yes, seq and $ are analogous to add and sum, respectively, in their semantic differences.

The text does say that the command is being used (in this example) to "restore a blurred image," which implies that the blurred image was created from some original higher-quality image.

To make the post be about Maple, ask whether the same can be done with Maple. We have the ImageTools:-Convolution command. 

@Kitonum Yes, surely I'd choose plots:-spacecurve over geom3d:-line and geom3d:-draw, unless I was already working within geom3d for some other reason. I may have misinterpretted the OP's title to mean that he was already working within geom3d.

@ 

If you were intending to receive a function of t as a result, what was your purpose in using evalf?

The two potential issues that you raised---the disappearence of sin and the disappearence of x---are unrelated. Regarding the sin: Maple's integration has a strong preference for re-expressing products of sines and cosines in terms of cosine alone. The forms are mathematically identical. We can do it for arbitrary m. The following two procedures are equivalent to your curva and fun except that I have removed the evalf.


curva:= proc(m::algebraic, t::algebraic)
local a:= 2*Pi*t;
     2*(cos(a), sin(a)*~(cos,sin)(a*m))
end proc:

fun:= proc(C::seq(algebraic))
local k, a:= k*Pi;
     int(sum(a*C[k]*cos(a*x), k= 1..nargs)^2, x= 0..1)
end proc:

fun(curva(m,t));

2*Pi^2+160*Pi^2*cos(Pi*t*m)^4*cos(Pi*t)^4-160*Pi^2*cos(Pi*t)^2*cos(Pi*t*m)^4-160*Pi^2*cos(Pi*t*m)^2*cos(Pi*t)^4+160*Pi^2*cos(Pi*t)^2*cos(Pi*t*m)^2-24*Pi^2*cos(Pi*t)^4+24*Pi^2*cos(Pi*t)^2

combine(%);

(15/2)*Pi^2+(5/4)*Pi^2*cos(4*Pi*m*t-4*Pi*t)+(5/4)*Pi^2*cos(4*Pi*m*t+4*Pi*t)-(11/2)*Pi^2*cos(4*Pi*t)-(5/2)*Pi^2*cos(4*Pi*t*m)

Regarding the disappearence of x: If you've integrated with respect to x, how can x possibly appear in the result? Thus I think that you intend for x to be a local variable of fun. Change fun to this:


fun:= proc(C::seq(algebraic))
local x, k, a:= k*Pi;
     int(sum(a*C[k]*cos(a*x), k= 1..nargs)^2, x= 0..1)
end proc:

fun(x,y,z);

(1/2)*Pi^2*x^2+2*Pi^2*y^2+(9/2)*Pi^2*z^2


Download sincos.mw

 

 

@Axel Vogt I doubt that. Maple's syntax is far more precise than mathematical notation! (And it's this syntax that promotes clarity of mathematical thinking---which is why I'm so opposed to the "syntax-free" "clickable" "solutions" that Maplesoft now promotes.)  I misinterpretted what the OP wanted: Since he used evalf, I assumed that he wanted a numerical result. But his followup makes it clear what his intention was.

@Kitonum  The warning means that it's safe to solve for names or functions; diff(a(t), t) is a function; x^2 isn't. Unfortunately, the English language is ambiguous between the expressions "(not A) or  B" and "not (A or B)". In this case, the latter is meant.

@Kitonum 

There's no need to use subssolve is happy to solve for derivatives or other functions:

Sys:= allvalues(solve({ode||(1..3)}, diff~({a,b,c}(t), t)))[1];

@tkeith022 

Sorry, but I need a complete executable worksheet to work with, not just a code fragment. In other words, I need a worksheet beginning with a restart command such that when you yourself click the !!! button in the toolbar, it executes.

@kippendorf 

Copy-and-paste of non-plaintext worksheet output into MaplePrimes doesn't work correctly in all web browsers. What browser are you using? I find that the best browser for MaplePrimes is Firefox, the worst is Internet Explorer, and Chrome is about midway between those two. Anyway, you can simply copy-and-paste the plaintext input that defines g. Like I said before, usually the (plaintext!) input is all that's required on MaplePrimes. (I don't mean to imply that you can't improve the quality of your posts by also including some properly formatted output.) You can also use the green up arrow on the toolbar to upload a worksheet.

@kippendorf 

Considering that g depends on omega, did you want a separate g curve for each of your three omegas? That'd be six curves on the plot. Isn't that a bit too much, visually? Nonetheless, if that's what you want, I can easily show you how to code it.

First 462 463 464 465 466 467 468 Last Page 464 of 709