Carl Love

## 20278 Reputation

8 years, 109 days
Mt Laurel, New Jersey, United States
My name was formerly Carl Devore.

## I wasn't correcting you...

@mmcdara I wasn't correcting you--I was only editing--although I have no compunction against correcting (or elaborating on subtle ambiguities in) our contributors' English usage when it seems worthwhile to do so. Anyway, perhaps you realize at this point that contributor usually refers to a person who contributes, whereas the most-common term for a nonperson entity that contributes is contributing factor (even in nontechnical contexts where factor has no special meaning).

## Your L1 doesn't depend on w...

@adel-00 You claim that you want to "integrate L1 w.r.t. w from -infinity to infinity numerically." Well, then show me an expression L1 that depends on w. The end result of the worksheet that you just posted is a sequence of numbers L1[-10] ... L1; that's not an expression that depends on w. Those numbers may be approximations to various parts of the integral; I can't tell for sure. So, I'm telling you again, for the time being, forget about integrating this expressionInstead, give me a worksheet that does nothing more than construct the expression L1(w) which is to be integrated. If you need to use loops to define that expression, that's totally fine. If the expression is too long to display, that's fine.

## Factor that contributes to the error...

@dnaviaux I'd guess that in mmcdara's final sentence, "contributor" could be replaced by "factor that contributes to the error".

## First, clean up the expression...

Before we can integrate the expression, we need to have the expression in Maple. So, forget about integrating for the time being. Concentrate on simply having this rather complicated expression entered into Maple such that it will display the expression in prettyprinted form. After that, we can discuss integrating it.

As it stands, it's difficult for me to distinguish the parts of your code that are for integrating from the parts that are for simply defining the integrand.

@mmcdara Okay, I now understand some things that were confusing you:

1. The categories of submissions to MaplePrimes: There are exactly five types of submissions to MaplePrimes---Posts, Comments, Questions, Answers, and Replies---organized like this:
(root)
Post
Comment
Question

When I use those words (or their inflected forms) capitalized, I am referring strictly to this MaplePrimes classification, not to what those words mean in English.

2. Definition of answer (note: lowercase): I checked several online English dictionaries, and I found to my great surprise that your translation software is correct: In every dictionary that I checked, the primary defintion of answer (noun) is synonymous with reply. So, under this defintion, anything at all said in response to a question is an answer (including nonsense, refusals, or requests for clarification). It was only in the fourth dictionary that I checked that I found a secondary definition akin to what I was thinking: "a solution to a problem". I think that this is the intended meaning of "answer" on the vast majority of the question-and-answer sites on the Internet.

3. What should be an Answer (note: uppercase): You wrote:

• You already said me something like  "an answer is the definitive and unique answer to a question while a reply is just one among many proposals to answer this problem". Is this right?

​​​​​​No, I didn't say anything like that, nor would I ever, because that statement is completely contrary to my way of thinking. Furthermore, I find the idea that the typical Maple question even has a "definitive and unique answer" ridiculous. So, I wonder where that statement comes from.

I believe that a contribution here should be classified as an Answer if its author's primary intent is to present a solution to a problem posed in a Question. Note the emphasis on intent: It makes no difference to me if the contribution fails to fulfill this intent; it still should be an Answer. Thus, all of the following should be Answers:

1. Items that intend to present a solution but are incorrect.
2. Items that intend to present a solution to only one of several questions posed in the Question.
3. Items that intend to present a solution to a question that is implied by the Question but wasn't directly asked.
4. Items that intend to present a solution to another question that should have been asked in the Question but wasn't asked due to the OP's lack of knowledge.
5. Responses in the form of rhetorical questions if the intent is to make the solution occur to the OP.
6. Items that present information that by itself is useless to the OP but could be combined with a future response provided by an expert such that the combination is usable to the OP (perhaps, after a followup Reply that integrates the responses).
7. Responses that for pedagogical reasons are incomplete, such as those that avoid directly solving homework problems but instead give hints or examples.

## Hex to symbol conversion...

@acer Expanding on your method, any Unicode "point" in "U+x" form (where x is a string of hex digits) can be converted to a symbol via

````convert/Unicode`:=
(U::And(
string,
Not({0,1,2}) &under length,
identical("U+") &under (index, ()..2),
satisfies(
U-> StringTools:-AndMap(StringTools:-IsHexDigit, U[3..])
)
))->
nprintf(`&#%ld;`, convert(U[3..], ':-decimal', 16))
:
convert("U+03A9", Unicode);

```

## Thanks, and corrected...

@acer Thanks for spotting that, and I have corrected the code above.

## It's still easy...

@dnaviaux By "style", I only meant with respect to word-processung features such as I mentioned. As shown in my other Answer, adding nonASCII characters to printf output is easy if you're content with fixed character width.

## Trivial with printf...

@dnaviaux If that style of report is "fine" with you, then it's trivial to do with printf, and I withdraw my statement about it being "nearly impossible". I was thinking of standard word-processing functionality: word wrapping, page breaks, bold and italics, sub- and superscripts, smoothing the right edges of paragraphs, and supporting non-fixed-width fonts.

I agree with acer: I've changed many of your Replies to Answers and usually given them a Vote Up in the process, all the while thinking "What was he thinking? This is obviously an Answer." But only the one who wrote the Question can select an Answer as Best.

So many of my good Answers don't get Voted Up. It does sadden me. Many users are completely unaware of those buttons.

## Why 5 exponents?...

In dismantle(a*x + b*y) (as shown by vv above), why are there 5 exponents per term, not 4, and why is the first one 2?

## The four equations for the first-order s...

@isabelmacpherson The procedure Kepler below shows how to formulate the system as a vector of four 1st-order ODEs. The rest of the code shows how to perform iterative IVP methods (such as 4th-order Runge-Kutta) using that procedure.

The output is in the downloadable worksheet above. Here's the plaintext form with most output removed:

```restart:
Digits:= 15:

#Input ODE IVP system the "normal" way:
xy:= [x,y]: xyt:= xy(t):
Kepler_sys:= {
(xy(0) =~ [1,0])[], (D(xy)(0) =~ [0,1])[]
};
/  2
| d                    x(t)
Kepler_sys :=  |---- x(t) = - --------------------,
<    2                         (3/2)
| dt           /    2       2\
|              \x(t)  + y(t) /
\

2
d                    y(t)
---- y(t) = - --------------------, x(0) = 1, y(0) = 0,
2                         (3/2)
dt           /    2       2\
\x(t)  + y(t) /

\
|
D(x)(0) = 0, D(y)(0) = 1|
>
|
|
/

#For the sake of comparison, obtain Maple's rk4 solution:
n:= 12:
dsol:= dsolve(
Kepler_sys, numeric, method= classical[rk4], stepsize= 2*Pi/n
):
#After we get our own solution, we'll compare with Maple's.

#Procedure that evaluates the 1st derivatives. Parameter t is only
#included for generality; it's not actually used in this ODE system.
Kepler:= proc(t, XY::Vector(4))
local x, y, `x'`, `y'`, d;
(x, y, `x'`, `y'`):= seq(XY); #Extract input vector.
d:= -(x^2+y^2)^(3/2);
#Return the four 1st derivatives (as a vector):
< `x'`, `y'`, x/d, y/d >
end proc
:
#Procedure that does one step of 4th-order Runge-Kutta:
RK4:= proc(t::complexcons, h::complexcons, Y::Vector, `Y'`::procedure)
local
h2:= h/2, t2:= t+h2,
#All remaining computations use vector arithmetic:
k1:= `Y'`(t, Y),
k2:= `Y'`(t2, Y+h2*k1),
k3:= `Y'`(t2, Y+h2*k2),
k4:= `Y'`(t+h, Y+h*k3)
;
Y + h/6*(k1+2*k2+2*k3+k4)
end proc
:
#This procedure can be used for any IVP method that extrapolates from
#the initial values (which is almost all of them). It defaults to
#using procedure RK4 from above.
IVP:= proc(
`Y'`::procedure, Y0::Vector[column],
T::range(complexcons), n::posint,
{method::procedure:= RK4}
)
local
i, #loop index
t:= lhs(T), #initial independent variable value
h:= (rhs(T)-t)/n,
Y:= Vector(Y0, datatype= float),
#matrix for output
#(1st row for t-values, 1st column for initial values):
R:= Matrix((upperbound(Y0)+1, n+1), <t, Y>,  datatype= float)
;
for i from 2 to n+1 do
Y:= evalf(method(t, h, Y, `Y'`));
t:= t+h;
R[.., i]:= <t, Y> #Store the ith column of output.
od;
R
end proc
:
Sol:= IVP(Kepler, <1, 0, 0, 1>, 0..2*Pi, n);

#Index [.., -1] is the last column of a matrix.
Sol[.., -1];
[     6.28318530717959      ]
[     0.991508429966570     ]
[    0.0430479365430936     ]
[    -0.0436637679707416    ]
[     1.00287851473040      ]

#Compare with dsolve's result:
eval(<t, x(t), y(t), diff(x(t),t), diff(y(t),t)>, dsol(2*Pi));
[     6.28318530717958      ]
[     0.991508429966570     ]
[    0.0430479365430934     ]
[    -0.0436637679707406    ]
[     1.00287851473040      ]

#You should redo with much larger n.

#The following will do a formatted print of every mth t, x, and y value,
#just like you were doing:
m:= 2:
printf("%10.4f\n", Sol[..3, [seq(m..upperbound(Sol), m), -1]]^+);
0.5236     0.8660     0.4996
1.5708    -0.0003     0.9981
2.6180    -0.8646     0.4935
3.6652    -0.8531    -0.5088
4.7124     0.0258    -0.9922
5.7596     0.8777    -0.4635
6.2832     0.9915     0.0430
```

## I agree with acer...

@AHSAN I agree with acer 100%. No useful purpose would be served by explicit symbolic representation of the parameterized roots.

## Quotes are a drawback to this method...

Yes, I do see the issue of quotes as a major drawback to this method that I didn't originally anticipate. Almost any Maple code of significant length will contain pairs of both single and double quotes, although quotes inside quotes are a rarity.

## Complex(a, b)...

@mmcdara What you showed regarding Complex(a, b) is interesting in its own right, but it sn't the point that I was trying to make in my last paragraph. I was referring to Complex(a, b) where a and are manifest real constants. For example:

```ToInert(Complex(3,7));
_Inert_COMPLEX(_Inert_INTPOS(3), _Inert_INTPOS(7))

```

So, we see that the result has nothing to do with either functions or names.

﻿