Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I must thank @Scot Gould for having asked this question more than a year ago and thus, without meaning to, having been the driving force behind this post.

There is an enormous literature about Monte-Carlo integration (MCI for short) and you might legitimately ask "Why another one?".

A personal experience.
Maybe if I tell you about my experience you will better understand why I believe that something is missing in the traditional courses and textbooks, even the most renowned ones.

For several years, I led training seminars in statistics for engineers working in the field of numerical simulation.

At some point I always came to speak about MCI and (as anyone does today) I introduced the subject by presenting the estimation of the area of a disk by randomly picking points in its circumscribed square and assessing its area from the proportion of points it contained.



Once done I switched (still as anybody does) to the Monte-Carlo summation formula (see Wikipedia for instance).

One day an attendee asked me this question "Why do you say that this [1D] summation formula is the same thing that the [2D] counting of points in the [circle within a box] example you have just presented?"

I have to say I was surprised by this question for it seemed to me quite evident that these two ways of assessing the area were nothing but two different points of view of, roughly, the same thing.

So I gave a quick, mostly informal, explanation (that I am not proud of) and, because the clock was running, I kept teaching the class.

But this question really puzzled me and I thought for a simple but rigourous way to prove these two approaches were (were they?) equivalent, at least in some reasonable sense.

The thing is that trying to derive simple explanations based on couting is not enough, and that you have to resort to certain probabilistic arguments to get out of it. Indeed, sticking to the counting approach leads to the more reasonable position that these two approaches are not equivalent.

The end of the story is that I spent more time on these two approaches of MCI during the trainings that followed.

Saying that, yes, the summation formula seems to be the reference today, but that the old counting strategy still has some advantages and can even gives access to information that the summation formula cannot.

About this post.
This post focuses mainly on what I call the Historical viewpoint (counting points), and is aimed, in its first part, to answer the question "Is this point of view equivalent or not to the Modern (summation formula) one?" (And if it is, in what sense is it so?).

Let me illustrate this with the example @Scot Gould  presented in its question. The brown bold curve on the left figure is the graph of the function  func(x) (whose expression has no interest here) and the brown area represents the area we want to assess using MCI.

In the Historical approach I picked unifomly at random N=100 points within the gray box (of area 2.42), found 26 of them were in the brown region and said the area of this latter is 2.42 x 26/100 = 0.6292. The Modern approach consists in picking uniformly N random points in the range x= [0.8, 3],  and using the blue formula to get an estimation of this same area ((Lbox is the x-length of the gray box, here equal to 2.2).

The quesion is: Am I assessing the same thing when I apply either method? And, perhaps more importantly, do my estimators have the same properties?


And here apppears a first problem:

  • Whatever the number of times you repeat the Historical sampling method, even with different points, you will always get a number of points in the brown region between 0 and N included, meaning that if S is the area of the gray box, the estimation of the brown area is always one of these numbers {0, S/N, 2.S/N, ..., S}.
  • At the opposite repetitions of the Modern approach will lead to a continuum of values for this brown area.
  • So, saying the two approaches might be equivalent simply means that a discrete set is equivalent to a non countable one.

If we remain at the elementary counting level, Historical and Modern viewpoints then are not equivalent.

Towards a probabilistic model of the Historical Process:
This goes against everything you may have heard or read: so, are the authors of these statements all wrong?

Yes, from a strict Historical point of view, but happily not if we interpret the Historical approach in a more loose and probabilistic manner (although this still needs to be considered carefully as it is shown in the main worksheet).

This probabilistic manner relies upon a probabilistic model of the Historical process, where the event "K points out of N belong to the brown area" is to be interpreted as the realization of a very special random variable named Poisson-Binomial (do not worry if you never heard about it: a lot of statisticians did not neither).

In a few words, whereas a Binomial random variable is the sum of several independent and identically distributed Bernoulli random variables, a Poisson-Binomial random variable is the sum of several independent but not necessarily identically distributed Bernoulli random variables. Thus the Poisson-Binomial distribution generalizes the Binomial one.

Using the properties of Poisson-Binomial random variables we must prove in a rigorous way that the expectations of the area estimators for both the Historical and Modern approaches are identical.

So, given this "trick" the two methods are thus equivalent, are they not? And that settles it.

In fact, no, the matter of equivalence still remains.

When uncertainty enters the picture.
Generally one cannot satisfy ourselves with the sole estimation of the area and we would like to have information about the reliability of this estimation. For instance if I find this value is 0.6292, am I ready to bet my salary that I am right? Of course not, unless I am insane, but the things would change if I were capable of saying for instance that "I am 95% sure that the true value of the area is between 0.6 and 0.67".

For the Historical vewpoint the Poisson-Binomial model makes possible to assess an uncertainty (not the uncertainty!) of the area estimation. But things are subtle, because there are different ways to compute an uncertainty:

  • At the elementary level the height of the gray box is an essential parameter, but it does not necessarily gives a good estimation of this uncertainty (one can easily reduced this latter arbitrarily close to 0!).
  • To get reliable uncertainty estimation the call to a probability theory related to Extreme Value Theory (EVT for short) necessary (all of this is explained in the attached worksheet).


For the Modern point of view it is enough to observe that there is no concept of "box height" and that it is then impossible to assess any uncertainty. Question: "If it is so, how can (all the) MCI procedures return an uncertainty value?"
The answer is simple: they consider a virtual encapsulating box whose eight is the maximum of the 
func(xi). This trick enables providing an uncertainty, but this is a non-conservative estimation (an over-optimistic one if you prefer, in other terms an estimation we must regard very carefully).

So, at the end Historical and Modern approaches are equivalent only if we restrict to the estimation of the area, but no longer as soon as we are interested in the quality of this estimation.

What does the attached file contain?
The attached file speaks a lot to the estimation of the estimator uncertainty.
The core theory is named (Right) EndPoint Theory (I found nothing on Wikipedia nor any easy-to-read papers about this theory, so I more or less arbitrarilly decided to refer to this one). Basically it enables assessing the (usually right) end-point of a distribution known only through (right) censored data.
The simplest example is those of a New York pedestrian who looks to the taxi numbers and asks himself how to assess the highest number a taxi has. Here we know this number exists (meaning that some related distribution is bounded), but the situation can be more complex if one does not ever know if this distribution is bounded or not (in which cas one seeks for a right end-point whose probability to be overpassed is less than some small value).
A conservative, and thus reliable, uncertainty on the area estimator  can only be derived in the framework of the end-point theory.

Once the basis of this theory are understood it becomes relatively simple to enhance the Historical approach to get estimators with lessen uncertainties.
I present different ways to do this: one (even if derived otherwise) is named Importance Sampling, and the other leads in a straightforward way to algorithms which are quite close to some used in the CUBA library (partially accessible through evalf/Int).

The last important, if not fundamental, concept discussed in this article concerns the distinction between dispersion interval and confidence interval, concepts that are unfortunately not properly distinguished due to the imprecision of the English language (I apologize to native English speakers for these somewhat harsh words, but this is the reality here).

Some references are provided in attached (main) worksheet, but please, if you don't want to end up even more confused than you were before, avoid Wikipedia.

To sum up.
This note is a non-orthodox presentation of MCI centered arround the Historical viewpoint which, I am convinced of that, deserves a little more attention than the disk-in-the-square picture commonly displayed in MCI courses and textbooks.
An I am even more convinced of that then this old-fashion (antiquated?) approach is an open door to some high level probability theories such than the EndPoint and the EVT one.

Of course this post is not an advocacy agaist the Modern approach, and does not mean that you have to ignore classical texts or that the Law of Large Numbers (LLN) or the Central limit theorms are useless stuff in MCI.

Maple, but not just Maple.
A part of the attached worksheet is devoted base presents results I got with R  (a programming language for statistical computing and data visualization), simply because Maple 2015 (and it is still true for Maple 2025) did not contain the functions I needed.

For instance R implements the Cuba library in a far more complete way than Maple (I give a critical discussion about the way Maple does it), enabling for instance the change of the random seed.

Main worksheet (I apologize in advance for typos that could remain in the texts)
A_note_on_Monte-Carlo_Integration.mw

The main worksheet refers to this one
How_does_the_variance_of_f_impact_the_estimator_dispersion.mw

Extra worksheet: An introduction to Importance Sampling
Importance_Sampling.mw

How do I fully expand an expression a polynomial with a constant c and variable m ?

i did substitution but my result is so different from the author i think he just take the linear term of theta but i didn't do that so how take just linear term of that function and find unknwon , and how afeter replacing eq(12) inside eq(11) we can remove thus exponential and find w? also i think author did a mistake which the equation 12 is theta(x,t) not Q(x,t)

restart

with(PDEtools)

undeclare(prime, quiet)

declare(u(x, t), quiet); declare(U(xi), quiet); declare(V(xi), quiet); declare(theta(x, t), quiet)

pde := diff(u(x, t), `$`(t, 2))-s^2*(diff(u(x, t), `$`(x, 2)))+(2*I)*(diff(u(x, t)*U^2, t))-(2*I)*alpha*s*(diff(u(x, t)*U^2, t))+I*(diff(u(x, t), `$`(x, 2), t))-I*beta*s*(diff(u(x, t), `$`(x, 3)))

diff(diff(u(x, t), t), t)-s^2*(diff(diff(u(x, t), x), x))+(2*I)*(diff(u(x, t), t))*U^2-(2*I)*alpha*s*(diff(u(x, t), t))*U^2+I*(diff(diff(diff(u(x, t), t), x), x))-I*beta*s*(diff(diff(diff(u(x, t), x), x), x))

(1)

T := u(x, t) = (sqrt(Q)+theta(x, t))*exp(I*(Q^2*epsilon*gamma+Q*q)*t); T1 := U = sqrt(Q)+theta(x, t)

u(x, t) = (Q^(1/2)+theta(x, t))*exp(I*(Q^2*epsilon*gamma+Q*q)*t)

 

U = Q^(1/2)+theta(x, t)

(2)

P := collect(eval(subs({T, T1}, pde)), exp)/exp(I*(Q^2*gamma*`ε`+Q*q)*t)

diff(diff(theta(x, t), t), t)+(2*I)*(diff(theta(x, t), t))*(Q^2*epsilon*gamma+Q*q)-(Q^(1/2)+theta(x, t))*(Q^2*epsilon*gamma+Q*q)^2-s^2*(diff(diff(theta(x, t), x), x))+(2*I)*(diff(theta(x, t), t)+I*(Q^(1/2)+theta(x, t))*(Q^2*epsilon*gamma+Q*q))*(Q^(1/2)+theta(x, t))^2-(2*I)*alpha*s*(diff(theta(x, t), t)+I*(Q^(1/2)+theta(x, t))*(Q^2*epsilon*gamma+Q*q))*(Q^(1/2)+theta(x, t))^2+I*(diff(diff(diff(theta(x, t), t), x), x)+I*(diff(diff(theta(x, t), x), x))*(Q^2*epsilon*gamma+Q*q))-I*beta*s*(diff(diff(diff(theta(x, t), x), x), x))

(3)

 

TT := Q = alpha[1]*exp(I*(k*x-t*w))+alpha[2]*exp(-I*(k*x-t*w))

Q = alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w))

(4)

S := eval(subs(TT, P))

diff(diff(theta(x, t), t), t)+(2*I)*(diff(theta(x, t), t))*(gamma*epsilon*(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^2+(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))*q)-((alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^(1/2)+theta(x, t))*(gamma*epsilon*(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^2+(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))*q)^2-s^2*(diff(diff(theta(x, t), x), x))+(2*I)*(diff(theta(x, t), t)+I*((alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^(1/2)+theta(x, t))*(gamma*epsilon*(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^2+(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))*q))*((alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^(1/2)+theta(x, t))^2-(2*I)*alpha*s*(diff(theta(x, t), t)+I*((alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^(1/2)+theta(x, t))*(gamma*epsilon*(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^2+(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))*q))*((alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^(1/2)+theta(x, t))^2+I*(diff(diff(diff(theta(x, t), t), x), x)+I*(diff(diff(theta(x, t), x), x))*(gamma*epsilon*(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))^2+(alpha[1]*exp((k*x-t*w)*I)+alpha[2]*exp(-I*(k*x-t*w)))*q))-I*beta*s*(diff(diff(diff(theta(x, t), x), x), x))

(5)

Download steps.mw

or for this equation 

steps-2.mw

Prove:
If a is an irrational number, then the function
y(x) = cos(a*x) + cosx is not periodic.

Further question:
Since every irrational number can be represented as the limit of a sequence of rational numbers and all software "only" works with finite representations of numbers, it would be interesting to know at what number length for a this becomes in examples apparent in the plot for y(x).

I'm not sure exactly when this started but maple on one of my linux machines won't print more than one row of a matrix. I get dots like this:

Note that interface(rtablesize) is [10,10]. This happens with both maple2024 and maple2025. 

On any of my other machines, maple works just fine. I have also tried deleting ~/.maple and ~/.maplesoft

Hi again all,

Was trying to be helpful at

mathforums.com

and made these two Maple files.  

simple_square_root_loop.mw

simple_square_root_loop.pdf

Hope that helps.

Maple is the best :-)

goodbye for now.

 

Matthew

Any idea why Maple dsolve can't find solution to this ode? From textbook

The strange thing, it solves if it asked for implicit solution. But the default, will give no solution.

Is this a defect? Should it not have returned the book solution automatically?   How is a user supposed to know the ode has a solution or not, if default call returns no solution?

restart;

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 29 and is the same as the version installed in this computer, created June 23, 2025, 10:25 hours Eastern Time.`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1877 and is the same as the version installed in this computer, created 2025, July 11, 19:24 hours Pacific Time.`

restart;

ode:=v(x)*diff(v(x),x) = g;
ic:=v(x__0) = v__0;
sol:=dsolve([ode,ic]);

v(x)*(diff(v(x), x)) = g

v(x__0) = v__0

restart;

ode:=v(x)*diff(v(x),x) = g;
ic:=v(x__0) = v__0;
sol:=dsolve([ode,ic],'implicit');

v(x)*(diff(v(x), x)) = g

v(x__0) = v__0

-2*g*x+v(x)^2+2*g*x__0-v__0^2 = 0

#why did not default call return this?
PDEtools:-Solve(sol,v(x))

v(x) = (2*g*x-2*g*x__0+v__0^2)^(1/2), v(x) = -(2*g*x-2*g*x__0+v__0^2)^(1/2)

Download dsolve_gives_no_solution_sept_2_2025.mw


Under the name of mmcdara (unfortunately inaccessible since the major July 2025 Mapleprimes outage, and probably lost forever, God rest his soul.) I published two years ago a post about Multivariate Normal Distribution.

The current post continues in the same vein and presents the construction of a few new Multivariate Random Variables (MRV for short) named Multinomial (see for instance this recent question), Dirichlet, Categorical and related compound distributions.
I advice the interested readers to give a quick look to these names on Wikipedia (more specific references are given at the top of the wotksheet).

As I explained (in fact as my alter ego did) in Multivariate Normal Distribution, the Statistics package is limited to univariate random variabled  and thus implementing MRVs requires a little cunning.
Here is a list of a few problems you face:

  • Whereas the expectation (sometimes named "mean") of a univariate random variable is a number or an expression, the expectation of a MRV is a vector (or a list, a n-uple, ...) of numbers or expressions.

So far, so good, except that the Mean attribute of Distribution can only be a scalar quantity. So if you want to assign a vector to Mean you have to code it some way and do something like Decode(Mean(My_MRV)) to get the expectation in a vector form.
 

  • The Variance case is even more tricky because MRV variance are matrices.
     
  • Beyond this some very useful attributes like ParentName and Parameters cannot be instanciated in the definition of user random variables (whether there are MRV or not), implying here again some bit of gymnastics to, if not reaslly instantiate these attributes, be able at least to retrieve them when needed.
     
  • Finally, last but not least, the RandomSample is not appropriated to sample MRVs for reasons which are explained in the attached worksheet.


The file below contains more than 20 procedures enabling the definition of the studied MRVs, the decoding of the coded attributes, the visualization (which is not that immediate because the supports of the MRVs I foccus on are simplexes), the parameter estimations against empirical observations (frequentist and bayesian points of view), and so on.

Multinomial_Dirichlet_and_so_on.mw

Nevertheless, there is still a lot missing, but at some point I believe we need to decide that the work is over.

 

On the very first day of class, a student once told math educator Sam Densley: “Your class feels safe.”

Open classroom door with students inside

Honestly, I can’t think of a better compliment for a teacher. I reflected on this in a LinkedIn post, and I want to share those thoughts here too.

A Story of Struggle

I rarely admit this, because it still carries a sting of shame. In my role at Maplesoft, people often assume I was naturally good at math. The truth is, I wasn’t. I had to work hard, and I failed along the way.

In fact, I failed my very first engineering course, Fundamentals of Electrical Engineering. Not once, but twice. The third time, I finally earned an A.

That second failure nearly crushed me. The first time, I told myself I was just adjusting to university life. But failing again, while my friends all passed easily, left me feeling stupid, ashamed, and like I didn’t belong.

When I got the news, I called my father. He left work to meet me, and instead of offering empty reassurances, he did something unexpected: he told me about his own struggles in school, the courses he failed, the moments he nearly gave up. Here was someone I admired, a successful engineer, admitting that he had stumbled too.

In that moment, the weight lifted. I wasn’t dumb. I wasn’t alone.

That experience has stayed with me ever since: the shame, the anxiety, the voice in my head whispering “I’m not cut out for this.” But also the relief of realizing I wasn’t the only one. And that’s why I believe vulnerability is key.

When teachers open up, something powerful happens:

  • Students stop thinking they’re the only ones who feel lost.
  • They see that failure isn’t the end; it’s part of the process.
  • It gives students permission to be honest about their own struggles.

That’s how you chip away at math anxiety and help students believe: “I can do this too.”

Why Vulnerability Matters

Abstract metallic mask with mathematical symbols

I can’t recall a single teacher in my own schooling who openly acknowledged their academic struggles. Why is that?

We tell students that “struggle is normal,” but simply saying the words isn’t enough. Students need to see it in us.

When teachers hide their struggles, students assume they’re the only ones who falter. That’s when math anxiety takes root. But when teachers are vulnerable, the cycle breaks. Students realize that struggle doesn’t mean they’re “bad at math.” It means they’re learning. Vulnerability builds trust, and trust is the foundation of a safe classroom.

What I Hear from Instructors

In my work at Maplesoft, I often hear instructors say: “Students don’t come to office hours — I wish they did.”

And I get it. Sometimes students are too anxious or hesitant to ask for help, even when a teacher makes it clear they’re available. That’s one of the reasons we built the Student Success Platform. It gives instructors a way to see where students are struggling without calling anyone out. Even if students stay silent, their struggles don’t stay invisible.

But tools can only go so far. They can reveal where students need support and even help illuminate concepts in new ways. What they can’t do is replace a teacher. Real learning happens when students feel safe, and that safety comes from trust. Trust isn’t built on flawless lectures or perfect answers. It grows when teachers are willing to be human, willing to admit they’ve struggled too.

That’s when students believe you mean it. And that’s when they’re more likely to walk through the door and ask for help.

The Real Lesson

Ultimately, what matters most in the classroom, whether in mathematics or any other subject, isn’t perfection. It’s effort.

As a new school year begins, it’s worth remembering:

  • Students don’t just need formulas.
  • They need to know struggle is normal.
  • They need to know questions are welcome.
  • They need to know the classroom is safe enough to try.

Because long after they move on, that’s what they’ll remember: not just what they learned, but how they felt.

I test a lot of them but some of them make a problem i  don't know i am do it in wrong way or the author did wrong i need verifying thus solution of odes specially in case 4 when we have not equal sign how use that?

and case 5 is Weierstrass elliptic function which i don't know how set up and use i think is a on kinf of odes but why they use that sign for this function?

ode-17.mw


I'm struggling to construct a statistical Distribution involving Product.
This is likely a question of delayed evaluation but I'm not capable to fix it.
Can you please look to this  Product_error.mw  worksheet  and help me fixing the issue?

Thanks in advance

Hi,

I’m having fun animating a beautiful geometric shape starting from a few trigonometric functions. I’m wondering if there’s a way to link each curve in the animation to its name.

restart

plots:-animatecurve([sin(x), sin(x)^2, sin(x)^3, sin(x)^4, sin(x)^5, sin(x)^6, surd(sin(x), 2), surd(sin(x), 3), surd(sin(x), 4), surd(sin(x), 5), surd(sin(x), 6)], x = 0 .. Pi, thickness = 2.5, background = "AliceBlue", labels = ["", ""], size = [800, 800])

 

plot([sin(x), sin(x)^2, sin(x)^3, sin(x)^4, sin(x)^5, sin(x)^6, surd(sin(x), 2), surd(sin(x), 3), surd(sin(x), 4), surd(sin(x), 5), surd(sin(x), 6)], x = 0 .. Pi, thickness = 2.5)

 

NULL

Download Animation_Trigo.mw

How to get amultiple line plots in one graph for differnt values of E1 := .1,0.2,0.3,and 0.4 with differnt color line red,blue,black and green and how to get numerical values for the all E1 value in one matrix form 

at E1=0.1 value of diff(g(x), x, x), diff(f(x), x, x),diff(f(x), x) and diff(g(x),  x).

AGM_method_single_line_plot.mw

I recently upgraded from Maple 23 to Maple 24. While many display issues have been resolved, I’ve encountered a new real problem: when entering operations or a factorial in a denominator or exponent, the cursor unexpectedly jumps to the inline position. This forces me to manually reposition the cursor using backspace plus left-arrow keys, and forgetting to do so can lead to errors. I have a perpetual Maple license through my university and haven’t purchased maintenance this time. Is there any way to fix or work around this cursor-jumping issue in Maple 24 without purchasing a new license?

The_Bohrs_Model_-_MaplePrimes.mw

Look at the equation (11) in the Maple's document. I would like to force Maple to let the variable "r" inside the squared root so to get the equation (12). Any idea of doing that?  Thank you in advance for your help.

1 2 3 4 5 6 7 Last Page 1 of 2219