MaplePrimes Posts

MaplePrimes Posts are for sharing your experiences, techniques and opinions about Maple, MapleSim and related products, as well as general interests in math and computing.

Latest Post
  • Latest Posts Feed
  • In our recent project, we're diving deep into understanding the SIR model—a fundamental framework in epidemiology that helps us analyze how diseases spread through populations. The SIR model categorizes individuals into three groups: Susceptible (S), Infected (I), and Recovered (R). By tracking how people move through these categories, we can predict disease dynamics and evaluate interventions.

    Key Points of the SIR Model:

    • Susceptible (S): Individuals who can catch the disease.
    • Infected (I): Those currently infected and capable of spreading the disease.
    • Recovered (R): Individuals who have recovered and developed immunity.

    Vaccination Impact: One of the critical interventions in disease control is vaccination, which moves individuals directly from the susceptible to the recovered group. This simple action reduces the number of people at risk, thereby lowering the overall spread of the disease.

    We're experimenting with a simple model to understand how different vaccination rates can significantly alter the dynamics of an outbreak. By simulating scenarios with varying vaccination coverage, students can observe how herd immunity plays a crucial role in controlling diseases. Our goal is to make these abstract concepts clear and relatable through practical modeling exercises.


     

    In this exercise, we are going back to the simple SIR model, without births or deaths, to look at the effect of vaccination. The aim of this activity is to represent vaccination in a very simple way - we are assuming it already happened before we run our model! By changing the initial conditions, we can prepare the population so that it has received a certain coverage of vaccination.

    We are starting with the transmission and recovery parameters  b = .4/daysand c = .1/days . To incorporate immunity from vaccination in the model, we assume that a proportion p of the total population starts in the recovered compartment, representing the vaccine coverage and assuming the vaccine is perfectly effective. Again, we assume the epidemic starts with a single infected case introduced into the population.​
    We are going to model this scenario for a duration of 2 years, assuming that the vaccine coverage is 50%, and plot the prevalence in each compartment over time.

     

    restart
    with(plots)

    b := .4; c := .1; n := 10^6; p := .5

    deS := diff(S(t), t) = -b*S(t)*I0(t); deI := diff(I0(t), t) = b*S(t)*I0(t)-c*I0(t); deR := diff(R(t), t) = c*I0(t)

    diff(R(t), t) = .1*I0(t)

    (1)

    F := dsolve([deS, deI, deR, S(0) = 1-p, I0(0) = 1/n, R(0) = p], [S(t), I0(t), R(t)], numeric, method = rkf45, maxfun = 100000)

    odeplot(F, [[t, S(t)], [t, I0(t)], [t, R(t)]], t = 0 .. 730, colour = [blue, red, green], legend = ["S(t)", "I0(t)", "R(t)"], labels = ["Time (days)", "  Proportion\nof Population "], title = "SIR Model with vaccine coverage 50 %", size = [500, 300])

     

    F(100)

    [t = 100., S(t) = HFloat(0.46146837378273076), I0(t) = HFloat(0.018483974421123688), R(t) = HFloat(0.5200486517961457)]

    (2)

    eval(S(:-t), F(100))

    HFloat(0.46146837378273076)

    (3)

    Reff := proc (s) options operator, arrow; b*(eval(S(:-t), F(s)))/(c*n) end proc; Reff(100)

    HFloat(1.845873495130923e-6)

    (4)

    plot(Reff, 0 .. 730, size = [500, 300])

     

    Increasing the vaccine coverage to 75%

    NULL

    restart
    with(plots)

    b := .4; c := .1; n := 10^6; p := .75

    deS := diff(S(t), t) = -b*S(t)*I0(t); deI := diff(I0(t), t) = b*S(t)*I0(t)-c*I0(t); deR := diff(R(t), t) = c*I0(t)

    diff(R(t), t) = .1*I0(t)

    (5)

    NULL

    F1 := dsolve([deS, deI, deR, S(0) = 1-p, I0(0) = 1/n, R(0) = p], [S(t), I0(t), R(t)], numeric, method = rkf45, maxfun = 100000)

    odeplot(F1, [[t, S(t)], [t, I0(t)], [t, R(t)]], t = 0 .. 730, colour = [blue, red, green], legend = ["S(t)", "I0(t)", "R(t)"], labels = ["Time (days)", "  Proportion\nof Population "], title = "SIR Model with vaccine coverage 75%", size = [500, 300])

     

    F(1100)

    eval(S(:-t), F1(100))

    HFloat(0.249990000844159)

    (6)

    Reff := proc (s) options operator, arrow; b*(eval(S(:-t), F1(s)))/(c*n) end proc; Reff(100)

    HFloat(9.99960003376636e-7)

    (7)

    plot(Reff, 0 .. 730, size = [500, 300])

     

    Does everyone in the population need to be vaccinated in order to prevent an epidemic?What do you observe if you model the infection dynamics with different values for p?

    No, not everyone in the population needs to be vaccinated in order to prevent an epidemic . In this scenario, if p equals 0.75 or higher, no epidemic occurs - 75 % is the critical vaccination/herd immunity threshold . Remember,, herd immunity describes the phenomenon in which there is sufficient immunity in a population to interrupt transmission . Because of this, not everyone needs to be vaccinated to prevent an outbreak .

    What proportion of the population needs to be vaccinated in order to prevent an epidemic if b = .4and c = .2/days? What if b = .6 and "c=0.1 days^(-1)?"

    In the context of the SIR model, the critical proportion of the population that needs to be vaccinated in order to prevent an epidemic is often referred to as the "herd immunity threshold" or "critical vaccination coverage."

    • 

    Scenario 1: b = .4and c = .2/days

    ``

    restart
    with(plots)

    b := .4; c := .2; n := 10^6; p := .5``

    deS := diff(S(t), t) = -b*S(t)*I0(t); deI := diff(I0(t), t) = b*S(t)*I0(t)-c*I0(t); deR := diff(R(t), t) = c*I0(t)

    diff(R(t), t) = .2*I0(t)

    (8)

    F1 := dsolve([deS, deI, deR, S(0) = 1-p, I0(0) = 1/n, R(0) = p], [S(t), I0(t), R(t)], numeric, method = rkf45, maxfun = 100000)

    odeplot(F1, [[t, S(t)], [t, I0(t)], [t, R(t)]], t = 0 .. 730, colour = [blue, red, green], legend = ["S(t)", "I0(t)", "R(t)"], labels = ["Time (days)", "  Proportion\nof Population "], title = "SIR Model with vaccine coverage 50 %", size = [500, 300])

     


    The required vaccination coverage is around 50% .

    • 

    Scenario 1: b = .6and c = .1/days

    restart
    with(plots)

    b := .6; c := .1; n := 10^6; p := .83NULL

    deS := diff(S(t), t) = -b*S(t)*I0(t); deI := diff(I0(t), t) = b*S(t)*I0(t)-c*I0(t); deR := diff(R(t), t) = c*I0(t)

    diff(R(t), t) = .1*I0(t)

    (9)

    NULL

    F1 := dsolve([deS, deI, deR, S(0) = 1-p, I0(0) = 1/n, R(0) = p], [S(t), I0(t), R(t)], numeric, method = rkf45, maxfun = 100000)

    odeplot(F1, [[t, S(t)], [t, I0(t)], [t, R(t)]], t = 0 .. 730, colour = [blue, red, green], legend = ["S(t)", "I0(t)", "R(t)"], labels = ["Time (days)", "  Proportion\nof Population "], title = "SIR Model with vaccine coverage 83% ", size = [500, 300])

     

    "The required vaccination coverage is around 83 `%` ."


    Download SIR_simple_vaccination_example.mw

    It can happen when an operation is interrupted by  that Maple does not return to  and still shows .

    This can give the false impression that the Maple server in charge of the evaluation did not get the message to stop whatever it was doing.

    By giving Maple an impossible task to solve analytically

    f1 := x1 - x1*sin(x1 + 5*x2) - x2*cos(5*x1 - x2);
    f2 := x2 - x2*sin(5*x1 - 3*x2) + x1*cos(3*x1 + 5*x2);
    solve({f1, f2});

    I have noticed in the Windows Task Manager that freeing allocated memory can take much longer than one might think.

    In one case it took 30 minutes to free 24 Gb of total allocated memory (21 Gb of it in RAM/physical memory). In this case the interrupt button became active (turned from grey to red ) two times and memory continued piling up  again.

    Lessons learned for me:

    • The task manager is not only a valuable indicator for task activity but also for the interruption/memory freeing process.
    • Before killing a whole Maple session and potentially losing the last state of a worksheet it can pay off to wait and repeatedly interrupt an operation.

     

    Suggestion: When the maple server gets an interrupt request, it could report to the GUI that it is in an interruption state and is no longer evaluating input. For example changing the message in the status bar from Evaluating... to Interrupting...


     

    When a derivative can be written as a function of the independent variable only for example

    y'=f(x)

    y''=f(x)

    y'''(x)=f(x)

    etc.

     

    We call that a directly integrable equation.

     

    Example 1:

     

    Find the general solution for the following directly integrable equation

    diff(y, x) = 6*x^2+4*y(1) and 6*x^2+4*y(1) = 0

    That means

    int(6*x^2+4, x)

    y = 2*x^3+c+4*x", where" c is an arbitary solution

    ``

     

     
    equation1 := diff(y(x), x) = 6*x^2+4

    diff(y(x), x) = 6*x^2+4

    (1)

    NULL

    NULL

    sol1 := dsolve(equation1, y(x))

    y(x) = 2*x^3+c__1+4*x

    (2)

    And  if we have the initial condition
    y(1) = 0
    particular_sol1 := dsolve({equation1, y(1) = 0}, y(x))

    y(x) = 2*x^3+4*x-6

    (3)

    "(->)"

     

     

     

     

     

    "Example 2:"NULL

    NULL

    "  Find the particular solution for the following equation with condition"

     

    x^2*(diff(y(x), x)) = -1

    y(1)=3

    So we will need to get the y' by itself

    int(-1/x^2, x)

    so,

    y = 1/x+c , where c is an arbitary constant

    And this is our general solution. Now we plug in the initial condition when x = 1, y = 3.

     

    That means c = 2.

     

    Thus, the particular solution is

     

    y = 1/x+2``

    eq := x^2*(diff(y(x), x)) = -1

    x^2*(diff(y(x), x)) = -1

    (4)

    NULL

    NULL

    sol := dsolve(eq, y(x))

    y(x) = 1/x+c__1

    (5)

    NULL

    particular_sol := dsolve({eq, y(1) = 3}, y(x))

    y(x) = 1/x+2

    (6)

    NULL

    NULL

    plot(1/x+2, x = -20 .. 20, color = "Red", axes = normal, legend = [typeset(1/x+2)])

     

    NULL

    NULL

    NULL

    NULL

    " Example 3:"

     

    " Find the particular solution for the following equation with condition"

     

    diff(y, t, t) = cost, (D(y))(0) = 0, y(0) = 1

    eq1 := diff(y(t), t, t) = cos(t)

    diff(diff(y(t), t), t) = cos(t)

    (7)

    particular_sol := dsolve({eq1, y(0) = 1, (D(y))(0) = 0}, y(t))

    y(t) = -cos(t)+2

    (8)

    "(->)"

     

     

     

     

    NULL


     

    Download integral.mw

     

    Hello,

    Attached I am sending several procedures for curves in 3D space. They were written without using Maple's built-in DiffGeo procedures and functions. As an example of their use, I made several animations - Maple worksheets are attached. I hope that maybe they will be useful to someone.

    Regards.

    ClsDGproc-Curves.zip

    restart;

    torus:= (x^2+y^2+z^2 + R^2-r^2)^2 - 4*R^2*(x^2+y^2):

    torus1:=eval(torus,[r=1,R=4]);

    (x^2+y^2+z^2+15)^2-64*x^2-64*y^2

    (1)

    plots:-implicitplot3d(torus1=0, x=-6..6,y=-6..6,z=-6..6, numpoints=5000, scaling=constrained, view=-2..2);

     

    sol1:=solve(torus1<0, [x,y,z]); # It should be easy for Maple

    [[x = 0, y < -3, -5 < y, z < (-y^2-8*y-15)^(1/2), -(-y^2-8*y-15)^(1/2) < z], [x = 0, y < 5, 3 < y, z < (-y^2+8*y-15)^(1/2), -(-y^2+8*y-15)^(1/2) < z]]

    (2)

    eval(torus1, [x=3,y=2,z=0]); # in the interior

    -48

    (3)

    eval(sol1, [x=3,y=2,z=0]);   # ???

    [[3 = 0, 2 < -3, -5 < 2, 0 < (-35)^(1/2), -(-35)^(1/2) < 0], [3 = 0, 2 < 5, 3 < 2, 0 < (-3)^(1/2), -(-3)^(1/2) < 0]]

    (4)

     

     

    Download Bug-solve_ineqs.mw

    This Maplesoft guest blog post is from Prof. Dr. Johannes Blümlein from Deutsches Elektronen-Synchrotron (DESY), one of the world’s leading particle accelerator centres used by thousands of researchers from around the world to advance our knowledge of the microcosm. Prof. Dr. Blümlein is a senior researcher in the Theory Group at DESY, where he and his team make significant use of Maple in their investigations of high energy physics, as do other groups working in Quantum Field Theory. In addition, he has been involved in EU programs that give PhD students opportunities to develop their Maple programming skills to support their own research and even expand Maple’s support for theoretical physics.


     

    The use of Maple in solving frontier problems in theoretical high energy physics

    For several decades, progress in theoretical high energy physics relies on the use of efficient computer-algebra calculations. This applies both to so-called perturbative calculations, but also to non-perturbative computations in lattice field theory. In the former case, large classes of Feynman diagrams are calculated analytically and are represented in terms of classes of special functions. In early approaches started during the 1960s, packages like Reduce [1] and Schoonship [2] were used. In the late 1980s FORM [3] followed and later on more general packages like Maple and Mathematica became more and more important in the solution of these problems. Various of these problems are related to data amounts in computer-algebra of O(Tbyte) and computation times of several CPU years currently, cf. [4].

    Initially one has to deal with huge amounts of integrals. An overwhelming part of them is related by Gauss’ divergence theorem up to a much smaller set of the so-called master integrals (MIs). One performs first the reduction to the MIs which are special multiple integrals. No general analytic integration procedures for these integrals exist. There are, however, several specific function spaces, which span these integrals. These are harmonic polylogarithms, generalized harmonic polylogarithms, root-valued iterated integrals and others. For physics problems having solutions in these function spaces codes were designed to compute the corresponding integrals. For generalized harmonic polylogarithms there is a Maple code HyperInt [5] and other codes [6], which have been applied in the solution of several large problems requiring storage of up to 30 Gbyte and running times of several days. In the systematic calculation of special numbers occurring in quantum field theory such as the so-called β-functions and anomalous dimensions to higher loop order, e.g. 7–loop order in Φ4 theory, the Maple package HyperLogProcedures [7] has been designed. Here the largest problems solved require storage of O(1 Tbyte) and run times of up to 8 months. Both these packages are available in Maple only.

    A very central method to evaluate master integrals is the method of ordinary differential equations. In the case of first-order differential operators leading up to root-valued iterative integrals their solution is implemented in Maple in [8] taking advantage of the very efficient differential equation solvers provided by Maple. Furthermore, the Maple methods to deal with generating functions as e.g. gfun, has been most useful here. For non-first order factorizing differential equation systems one first would like to factorize the corresponding differential operators [9]. Here the most efficient algorithms are implemented in Maple only. A rather wide class of solutions is related to 2nd order differential equations with more than three singularities. Also here Maple is the only software package which provides to compute the so-called 2F1 solutions, cf. [10], which play a central role in many massive 3-loop calculations

    The Maple-package is intensely used also in other branches of particle physics, such as in the computation of next-to-next-to leading order jet cross sections at the Large Hadron Collider (LHC) with the package NNLOJET and double-parton distribution functions. NNLOJET uses Maple extensively to build the numerical code. There are several routines to first build the driver with automatic links to the matrix elements and subtraction terms, generating all of the partonic subprocesses with the correct factors. To build the antenna subtraction terms, a meta-language has been developed that is read by Maple and converted into calls to numerical routines for the momentum mappings, calls to antenna and to routines with experimental cuts and plotting routines, cf. [11].

    In lattice gauge calculations there is a wide use of Maple too. An important example concerns the perturbative predictions in the renormalization of different quantities. Within different European training networks, PhD students out of theoretical high energy physics and mathematics took the opportunity to take internships at Maplesoft for several months to work on parts of the Maple package and to improve their programming skills. In some cases also new software solutions could be obtained. Here Maplesoft acted as industrial partner in these academic networks.

    References

    [1] A.C. Hearn, Applications of Symbol Manipulation in Theoretical Physics, Commun. ACM 14 No. 8, 1971.

    [2] M. Veltman, Schoonship (1963), a program for symbolic handling, documentation, 1991, edited by D.N. Williams.

    [3] J.A.M. Vermaseren, New features of FORM, math-ph/0010025.

    [4] J. Blümlein and C. Schneider, Analytic computing methods for precision calculations in quantum field theory, Int. J. Mod. Phys. A 33 (2018) no.17, 1830015 [arXiv:1809.02889 [hep-ph]].

    [5] E. Panzer, Algorithms for the symbolic integration of hyperlogarithms with applications to Feynman integrals, Comput. Phys. Commun. 188 (2015) 148–166 [arXiv:1403.3385 [hep-th]].

    [6] J. Ablinger, J. Blümlein, C .Raab, C. Schneider and F. Wissbrock, Calculating Massive 3-loop Graphs for Operator Matrix Elements by the Method of Hyperlogarithms, Nucl. Phys. 885 (2014) 409-447 [arXiv:1403.1137 [hep-ph]].

    [7] O. Schnetz, φ4 theory at seven loops, Phys. Rev. D 107 (2023) no.3, 036002 [arXiv: 2212.03663 [hep-th]].

    [8] J. Ablinger, J. Blümlein, C. G. Raab and C. Schneider, Iterated Binomial Sums and their Associated Iterated Integrals, J. Math. Phys. 55 (2014) 112301 [arXiv:1407.1822 [hep-th]].

    [9] M. van Hoeij, Factorization of Differential Operators with Rational Functions Coefficients, Journal of Symbolic Computation, 24 (1997) 537–561.

    [10] J. Ablinger, J. Blümlein, A. De Freitas, M. van Hoeij, E. Imamoglu, C. G. Raab, C. S. Radu and C. Schneider, Iterated Elliptic and Hypergeometric Integrals for Feynman Diagrams, J. Math. Phys. 59 (2018) no.6, 062305 [arXiv:1706.01299 [hep-th]].

    [11] A. Gehrmann-De Ridder, T. Gehrmann, E.W.N. Glover, A. Huss and T.A. Morgan, Precise QCD predictions for the production of a Z boson in association with a hadronic jet, Phys. Rev. Lett. 117 (2016) no.2, 022001 [arXiv:1507.02850 [hep-ph]].

         Happy Easter to all those who celebrate! One common tradition this time of year is decorating Easter eggs. So, we’ve decided to take this opportunity to create some egg-related math content in Maple Learn. This year, a blog post by Tony Finch inspired us to create a walkthrough exploring the four-point egg. The four-point egg is a method to construct an egg-shaped graph using just a compass and a ruler, or in this case, Maple Learn. Here's the final product: 

         The Maple Learn document, found here, walks through the steps. In general, each part of the egg is an arc corresponding to part of a circle centred around one of the points generated in this construction. 

         For instance, starting with the unit circle and the three red points in the image below, the blue circle is centred at the bottom point such that it intersects with the top of the unit circle, at (0,1). The perpendicular lines were constructed using the three red points, such that they intersect at the bottom point and pass through opposite side points, either (-1,0) or (1,0). Then, the base of the egg is constructed by tracing an arc along the bottom of the blue circle, between the perpendicular lines, shown in red below.

     

         Check out the rest of the steps in the Maple Learn Document. Also, be sure to check out other egg-related Maple Learn documents including John May’s Egg Formulas, illustrating other ways to represent egg-shaped curves with mathematics, and Paige Stone’s Easter Egg Art, to design your own Easter egg in Maple Learn. So, if you’ve had your fill of chocolate eggs, consider exploring some egg-related geometry - Happy Easter!  

    Here are the Maple sources for the paper "Maximum Gap among Integers Having a Common Divisor with an Odd semi-prime" published on Journal of Advances in Mathematics and Computer Science 39 (10):51-61, at :https://doi.org/10.9734/jamcs/2024/v39i101934.

     

    gap := proc(a, b) return abs(a - b) - 1; end proc

    HostsNdivisors := proc(N)

    local i, j, g, d, L, s, t, m, p, q, P, Q, np, nq;

    m := floor(1/2*N - 1/2);

    L := evalf(sqrt(N));

    P := Array();

    Q := Array();

    s := 1; t := 1;

    for i from 3 to m do

       d := gcd(i, N);

        if 1 < d and d < L then P(s) := i; s++;

        elif L < d then Q(t) := i; t++; end if;

    end do;

      np := s - 1;

      nq := t - 1;

     for i to np do printf("%3d,", P(i)); end do;

      printf("\n");

      for i to nq do printf("%3d,", Q(i)); end do;

      printf("\n gaps: \n");

      for i to np do

         for j to nq do

          p := P(i); q := Q(j);

          g := gap(p, q);

          printf("%4d,", g);

      end do;

        printf("\n");

    end do;

    end proc

     

    HostOfpq := proc(p, q)

    local alpha, s, t, g, r, S, T, i, j;

       S := 1/2*q - 1/2;

       T := 1/2*p - 1/2;

       alpha := floor(q/p);

        r := q - alpha*p;

       for s to S do

         for t to T do

           g := abs((t*alpha - s)*p + t*r) - 1;

            printf("%4d,", g);

          end do;

         printf("\n");

     end do;

    end proc

    MapleSource.pdf

    MapleSource.mw

     

    To celebrate this day of mathematics, I want to share my favourite equation involving Pi, the Bailey–Borwein–Plouffe (BBP) formula:

    This is my favourite for a number of reasons. Firstly, Simon Plouffe and the late Peter Borwein (two of the authors that this formula is named after) are Canadian! While I personally have nothing to do with this formula, the fact that fellow Canadians contributed to such an elegant equation is something that I like to brag about.

    Secondly, I find it fascinating how Plouffe first discovered this formula using a computer program. It can often be debated whether mathematics is discovered or invented, but there’s no doubt here since Plouffe found this formula by doing an extensive search with the PSLQ integer relation algorithm (interfaced with Maple). This is an example of how, with ingenuity and creativity, one can effectively use algorithms and programs as powerful tools to obtain mathematical results.

    And finally (most importantly), with some clever rearranging, it can be used to compute arbitrary digits of Pi!

    Digit 2024 is 8
    Digit 31415 is 5
    Digit 123456 is 4
    Digit 314159 is also 4
    Digit 355556 is… F?

    That last digit might look strange… and that’s because they’re all in hexadecimal (base-16, where A-F represent 10-15). As it turns out, this type of formula only exists for Pi in bases that are powers of 2. Nevertheless, with the help of a Maple script and an implementation of the BBP formula by Carl Love, you can check out this Learn document to calculate some arbitrary digits of Pi in base-16 and learn a little bit about how it works.

    After further developments, this formula led to project PiHex, a combined effort to calculate as many digits of Pi in binary as possible; it turns out that the quadrillionth bit of Pi is zero! This also led to a class of BBP-type formulas that can calculate the digits of other constants like (log2)*(π^2) and (log2)^5.

    Part of what makes this formula so interesting is human curiosity: it’s fun to know these random digits. Another part is what makes mathematics so beautiful: you never know what discoveries this might lead to in the future. Now if you’ll excuse me, I have a slice of lemon meringue pie with my name on it 😋

     

    References
    BBP Formula (Wikipedia)
    A Compendium of BBP-Type Formulas
    The BBP Algorithm for Pi

    This post is to help anyone who is just as frustrated about typesetting in plots
    as I was before I solved my problem. (Note: the technique works with the version

    2020 and newer and may work with earlier versions.)

     

    Why? Because there is no obvious help in Maple showing what works. (And if folks

    can improve what I have posted,  please do so. At least when someone executes

    a search for this type of problem, they might see the best approach.)

    Goal: typeset a name of a function in any text of a plot.

    Approach: According to help, '?plot, typesetting',  one should use the
    option(procedure?) typeset.   For example:

    "restart;   plots:-setoptions(size = [400, 200]):    `f__1`(x) :=cos(x)*(e)^(-(x^(2))/(4)) :    p1 := plot(`f__1`(x), x = -5..5,                         legend = typeset("function ", `f__1`(x) )  );"

     

     

    However, what I want in the legend is the expression "`f__1`(x),"not the evaluated

    expression. Entering the name with single quotes around the expression leads to this:

     

    p1 := plot(f__1(x), x = -5 .. 5, legend = typeset("function ", 'f__1(x)'))

     

     

    which is great, except that when I wish to redisplay the plot

     

    plots:-display(p1)

     

    the expression f__1(x)is evaluated.

     

    According to the code completion capability of Maple, the procedure

    "Typesetting:-Typeset" exists, and it does not evaluate the function:

     

    p1 := plot(f__1(x), x = -5 .. 5, legend = Typesetting:-Typeset(f__1(x))); plots:-display(p1)

     

     

    except there is no help regarding this procedure.

     

    It appears that the procedure operates only on one item.

     

    Solution: Hence, the ultimate solution for my problem is to still use the typeset 

    option, but Typeset any expression.

     

    p1 := plot(f__1(x), x = -5 .. 5, legend = typeset("function ", Typesetting:-Typeset(f__1(x)))); plots:-display(p1)

     

     

    Again, if you can contribute to this post, I would appreciate it.


     

    Download MaplePrimies_-_Typesetting_in_plots.mw



    (EDITED 2024/03/11  GMT 17H)

    In a recent Question@cq mentionned in its last reply "In fact, I wanted to do parameter sensitivity analysis and get the functional relationship between the [...] function and [parameters]. Later, i will study how the uncertainty of [the parameters] affects the [...] function".
    I did not keep exchanging further on with @cq, simply replying that I could provide it more help if needed.

    In a few words the initial problem was this one:

    • Let X_1 and X_2 two random variables and G the random variable defined by  G = 1 - (X_1 - 1)^2/9 - (X_2 - 1)^3/16.
       
    •  X_1 and X_2 are assumed to be gaussian random variables with respective mean and standard deviation equal to (theta_1, theta_3) and (theta_2, theta_4).
       
    • The four theta parameters are themselves assumed to be realizations of four mutually independent uniform random variables Theta_1, ..., Theta_4 whose parameters are constants.
       
    • Let QOI  (Quantity Of Interest) denote some scalar statistic of G (for instance its Mean, Variance, Skweness, ...).
      For instance, if QOI = Mean(G), then  QOI expresses itself as a function of the four parameters theta_1, ..., theta_4.
      The goal of @cq is to understand which of those parameters have the greatest influence on QOI.


    For a quick survey of Sensitivity Analysys (SA) and a presentation of some of the most common strategies see Wiki-Overview


    The simplest SA is the Local SA (LSA) we are all taught at school: having chosen some reference point P in the [theta_1, ..., theta_4] space the 1st order partial derivatives d[n] = diff(QOI, theta_n) expressed at point P give a "measure" (maybe after some normalization) of the sensitivity, at point P, of QOI regardibg each parameter theta_n.


    A more interesting situation occurs when the parameters can take values in a neighorhood of  P which is not infinitesimal, or more generally in some domain without reference to any specific point P.
    That is where Global SA (GSA) comes into the picture.
    While the notion of local variation at some point P is well established, GSA raises the fundamental question of how to define how to measure the variation of a function over an arbitrary domain?
    Let us take a very simple example while trying to answer this question "What is the variation of sin(x) over [0, 2*Pi]?"

    1. If we focus on the global trend of sin(x)  mean there is no variation at all.
    2. If we consider peak-to-peak amplitude the variation is equal to 2.
    3. At last, if we consider L2 norm the variation is equal to Pi.
      (but the constant function x -> A/sqrt(2) has the same L2 norm but it is flat, and in some sense les fluctuating). 


    Statisticians are accustomed to use the concept of variance as a measure to quantify the dispersion of a random variable. At the end of the sixties  one of them, Ilya Meyerovich Sobol’,  introduced the notion of Variance-Based GSA as the key tool to define the global variation of a function. This notion naturally led to that of Sobol' indices as a measure of the sensitivity of a funcion regarding one of its parameters or, which most important, regarding any combination (on says interaction) of its parameters.

    The aim of this post is to show how Sobol' indices can be computed when the function under study has an analytic expression.
     

    The Sobol' analysis is based on an additive decomposition of this function in terms of 2^P mutually orthogonal fiunctions where P is the number of its random parameters.
    This decomposition and the ensuing integrations whose values will represent the Sobol' indices can be done analytically in some situation. When it is no longer the case specific numerical estimation methods have to be used;


    The attached file contains a quite generic procedure to compute exact Sobol' indices and total Sobol' indices for a function whose parameters have any arbitrary statistical distribution.
    Let's immediately put this into perspective by saying that these calculations are only possible if Maple is capable to find closed form expressions of some integrals, which is of course not always the case.

    A few examples are also provided, including the one corresponding to @cq's original question.
    At last two numerical estimation methods are presented.

    SOBOL.mw

     

         On International Women’s Day we celebrate the achievements of women around the world. One inspiring story of women in STEM is that of Sophie Germain (1776-1831), a French mathematician and physicist who made groundbreaking strides in elasticity theory and number theory. She learned mathematics from reading books in her father’s library, and while she was not permitted to study at the École Polytechnique, due to prejudice against her gender, she was able to obtain lecture notes and decided to submit work under the name Monsieur LeBlanc. Some prominent mathematicians at the time, including Joseph-Louis Lagrange and Carl Friedrich Gauss, with whom Germain wrote, recognized her intellect and were supportive of her work in mathematics. 

         Sophie Germain is remembered as a brilliant and determined trailblazer in mathematics. She was the first woman to win a prize from the Paris Academy of Sciences for her contributions in elasticity theory and was among the first to make significant contributions toward proving Fermat’s Last Theorem. Among her many accomplishments, one special case of Fermat’s Last Theorem she was able to prove is when the exponent takes the form of what is now known as a Sophie Germain prime: a prime, p, such that 2p+1 is also a prime. The associated prime, 2p+1, is called a safe prime. 

         To mark International Women’s Day, I’ve created a document exploring the Ulam spiral highlighting Sophie Germain primes and safe primes, as an adaptation of Lazar Paroski’s Ulam spiral document. The image below displays part of the Ulam spiral with Sophie Germain primes highlighted in red, safe primes highlighted in blue, primes that are both a Sophie Germain prime and safe prime highlighted in purple, and primes that are neither in grey. 

      

         The document also contains small explorations of these types of prime numbers. For instance, one interesting property of safe primes is that they must either be 5, 7 or take the form 12k-1 for some k≥1. This can be shown from the fact a safe prime q must equal 2p+1 for some prime, p (a Sophie Germain prime), by definition. Then, since q and p are prime, for q > 7 we can determine through contradiction that q ≡ 3 (mod 4) and q ≡ 5 (mod 6), to conclude q ≡ 11 (mod 12) ≡ -1 (mod 12). And so, q = 12k-1 for some k≥1. The Maple Learn document can be found here along with its Maple script. The document also includes a group where you can test whether some positive integer of your choice, n, is a Sophie Germain prime or a safe prime. Alternatively, given n, a button press will display the next Sophie Germain prime greater than n, using Maple’s NextSafePrime command in the number theory package.  

         In mathematics, there is no shortage of interesting rabbit holes to dive into; many of which are the result of past and present women in mathematics, like Sophie Germain, who have persevered despite their hardships. 

    A checkered figure is a connected flat figure consisting of unit squares. The problem is to cut this figure into several equal parts (in area and shape). Cuts can only be made on the sides of the cells. In mathematics, such figures are called polyominoes, and the problem is called the tiling of a certain polyomino with copies of a single polyomino. See https://en.wikipedia.org/wiki/Polyomino

    Below are 3 examples of such figures:

    We will define such figures by the coordinates of the centers of the squares of which it consists. These points must lie in the first quarter, and points of this figure must lie on each of the coordinate axes.

    Below are the codes for two procedures named  CutEqualParts  and  Picture . Required formal parameters of the first procedure: set  S  specifies the initial figure, r is the initial cell for generating subfigures, m is the number of parts into which the original figure needs to be divided. The optional parameter  s  equals (by default onesolution) or allsolutions. The starting cell  r  should be the corner cell of the figure. Then the set of possible subshapes for partitioning will be smaller. If there are no solutions, then the empty set will be returned. The second procedure  Picture  returns a picture of the obtained result as one partition (for a single solution) or in the form of a matrix if there are several solutions. In the second case, the optional parameter  d  specifies the number of rows and columns of this matrix.

    restart;
    CutEqualParts:=proc(S::set(list),r::list,m::posint, s:=onesolution)
    local OneStep, n, i1, i2, j1, j2, R, v0, Tran, Rot, Ref, OneStep1, M, MM, MM1, T, T0, h, N, L;
    n:=nops(S)/m;
    if irem(nops(S), m)<>0 then error "Should be (nops(S)/m)::integer" fi;
    if not (r in S) then error "Should be r in S" fi;
    if m=1 then return {S} fi;
    if m=nops(S) then return map(t->{t}, S) fi;
    i1:=min(map(t->t[1],select(t->t[2]=0,S)));
    i2:=max(map(t->t[1],select(t->t[2]=0,S)));
    j1:=min(map(t->t[2],select(t->t[1]=0,S)));
    j2:=max(map(t->t[2],select(t->t[1]=0,S)));
    OneStep:=proc(R)
    local n1, R1, P, NoHoles;
    R1:=R;
    n1:=nops(R1);
    R1:={seq(seq(seq(`if`(r1 in S and not (r1 in R1[i]) , subsop(i={R1[i][],r1}, R1)[],NULL),r1=[[R1[i,j][1],R1[i,j][2]-1],[R1[i,j][1]+1,R1[i,j][2]],[R1[i,j][1],R1[i,j][2]+1],[R1[i,j][1]-1,R1[i,j][2]]]), j=1..nops(R1[i])), i=1..n1)};
    NoHoles:=proc(s)
    local m1, m2, M1, M2, M;
    m1:=map(t->t[1],s)[1]; M1:=map(t->t[1],s)[-1];
    m2:=map(t->t[2],s)[1]; M2:=map(t->t[2],s)[-1];
    M:={seq(seq([i,j],i=m1..M1),j=m2..M2)}; 
    if ormap(s1->not (s1 in s) and `and`(seq(s1+t in s, t=[[1,0],[-1,0],[0,1],[0,-1]])), M) then return false fi;
    true;
    end proc:
    P:=proc(t)
    if `and`(seq(seq(seq(([i,0] in t) and ([j,0] in t) and not ([k,0] in t) implies not ([k,0] in S), k=i+1..j-1), j=i+2..i2-1), i=i1..i2-2)) and `and`(seq(seq(seq(([0,i] in t) and ([0,j] in t) and not ([0,k] in t) implies not ([0,k] in S), k=i+1..j-1), j=i+2..j2-1), i=j1..j2-2))  then true else false fi;
    end proc:
    select(t->nops(t)=nops(R[1])+1 and NoHoles(t) and P(t) , R1);
    end proc:
    R:={{r}}:
    R:=(OneStep@@(n-1))(R):
    v0:=[floor(max(map(t->t[1], S))/2),floor(max(map(t->t[2], S))/2)]:
    h:=max(v0);
    Tran:=proc(L,v) L+v; end proc:
    Rot:=proc(L, alpha,v0) <cos(alpha),-sin(alpha); sin(alpha),cos(alpha)>.convert(L-v0,Vector)+convert(v0,Vector); convert(%,list); end proc:
    Ref:=proc(T) map(t->[t[2],t[1]], T); end proc:
    OneStep1:=proc(T)
    local T1, n2, R1;
    T1:=T; n2:=nops(T1);
    T1:={seq(seq(`if`(r1 intersect `union`(T1[i][])={}, subsop(i={T1[i][],r1}, T1), NULL)[], r1=MM1 minus T1[i]), i=1..n2)};
    end proc:
    N:=0; 
    for M in R do
    MM:={seq(seq(seq(map(t->Tran(Rot(t,Pi*k/2,v0),[i,j]),M),i=-h-1..h+1),j=-h-1..h+1),k=0..3),seq(seq(seq(map(t->Tran(Rot(t,Pi*k/2,v0),[i,j]),Ref(M)),i=-h-1..h+1),j=-h-1..h+1), k=0..3)}:
    MM1:=select(t->(t intersect S)=t, MM):
    T:={{M}}:
    T:=(OneStep1@@(m-1))(T):
    T0:=select(t->nops(t)=m, T):
    if T0<>{} then if s=onesolution then return T0[1] else N:=N+1;
     L[N]:=T0[] fi; fi; 
    od:
    L:=convert(L,list);
    if L[]::symbol then return {} else L fi;
    end proc:
    
    Picture:=proc(L::{list,set},Colors::list,d:=NULL)
    local r;
    uses plots, plottools;
    if L::set or (L::list and nops(L)=1) or d=NULL then return
    display( seq(polygon~(map(t->[[t[1]-1/2,t[2]-1/2],[t[1]+1/2,t[2]-1/2],[t[1]+1/2,t[2]+1/2],[t[1]-1/2,t[2]+1/2]] ,`if`(L::set,L[j],L[1][j])), color=Colors[j]),j=1..nops(Colors)) , scaling=constrained, size=[800,600]) fi;
    if d::list then r:=irem(nops(L),d[2]);
    if r=0 then return
    display(Matrix(d[],[seq(display(seq(polygon~(map(t->[[t[1]-1/2,t[2]-1/2],[t[1]+1/2,t[2]-1/2],[t[1]+1/2,t[2]+1/2],[t[1]-1/2,t[2]+1/2]]  ,L[i,j]), color=Colors[j]),j=1..nops(Colors)), scaling=constrained, size=[400,300], axes=none), i=1..nops(L))])) else
    display(Matrix(d[],[seq(display(seq(polygon~(map(t->[[t[1]-1/2,t[2]-1/2],[t[1]+1/2,t[2]-1/2],[t[1]+1/2,t[2]+1/2],[t[1]-1/2,t[2]+1/2]]  ,L[i,j]), color=Colors[j]),j=1..nops(Colors)), scaling=constrained, size=[400,300], axes=none), i=1..nops(L)), seq(plot([[0,0]], axes=none, size=[10,10]),k=1..d[2]-r)]))  fi; fi; 
    end proc:
    

    Examples of use for figures 1, 2, 3
    In the first example for Fig.1 we get 4 solutions for m=4:

    S:=({seq(seq([i,j], i=0..4), j=0..2)} union {[2,3],[3,3],[3,4]}) minus {[0,0],[0,1]}:
    L:=CutEqualParts(S,[0,2],4,allsolutions);
    C:=["Cyan","Red","Yellow","Green"]:
    nops(L);
    Picture(L,C,[2,2]);
    

    In the second example for Fig.2 for m=2, we get 60 solutions (the first 16 are shown in the figure):

    S:={seq(seq([i,j], i=0..4), j=0..4)} minus {[2,2]}:
    L:=CutEqualParts(S,[0,0],2,allsolutions):
    nops(L);
     C:=["Cyan","Red"]:
    Picture(L[1..16],C,[4,4]);
    


    In the third example for Fig.3 and  m=2  there will be a unique solution:

    S:={seq(seq([i,j], i=0..5), j=0..3)}  minus {[5,0],[4,2]} union {[1,4],[2,4]}:
    L:=CutEqualParts(S,[0,0],2):
     C:=["Cyan","Red"]:
    Picture(L,C);
    


    Addition. It is proven that the problem of tiling a certain polyomino with several copies of a single polyomino is NP-complete. Therefore, it is recommended to use the CutEqualParts procedure when the numbers  nops(S)  and  nops(S)/m  are relatively small (nops(S)<=24  and nops(S)/m<=12), otherwise the execution time may be unacceptably long.

    Cutting_equal_parts.mw

    A blue triangle with white text

Description automatically generated

     

    Attention Maple enthusiasts! It gives me great pleasure to announce Maple 2024! Maple 2024 brings together a collection of new features and enhancements carefully designed to enrich your mathematical explorations. Maple 2024 is the result of a lot of hard work by a lot of people, and there is far more in it than I can cover here. But I’d like to share with you some of my favorite features in this release.

     

    AI Formula Assistant

    The AI Formula Assistant in Maple 2024 is undoubtedly the feature that excites me the most, especially considering how often I’m asked the question: 'When will Maple include AI features?' This assistant serves as your new mathematical companion and will change the way you look up and enter formulas and equations. Driven by advanced AI technology, it presents a range of relevant options based on your search query. Alongside suggestions, you'll also receive detailed explanations for each formula and its parameters so you can select the one you need, and then you can insert the formula into your document at a click of a button, as a proper Maple expression.

    A screenshot of a computer

Description automatically generated

     

     

    NaturalLanguage Package

    The Formula Assistant is built on top of the new NaturalLanguage package, which integrates powerful language models like GPT-4 and ChatGPT from OpenAI into Maple. With this feature, you can leverage large language models to process natural language within Maple. Ask the AI to explain concepts, provide additional details, find specific Maple commands, and more. Of course, since this is a Maple package, you can also use it as a basis to build your own AI-powered applications inside Maple. We’re really looking forward to seeing what you will do with it!

     

    A close-up of a document

Description automatically generated

     

     

    Argument Completion
    We’ve had a lot of requests from people who wanted Maple’s command completion features to do even more, and I’m happy to say that Maple 2024 delivers. The new argument completion feature in Maple 2024 is poised to significantly enhance your experience with commands. For many users, including myself, not being aware of all the options a command takes is a challenge, often leading me to refer to help pages for clarification. With argument completion, that's no longer a concern. Just enter the command with the help of the existing command completion feature, then automatic argument completion takes over to guide you through the rest. Give it a try with the 'plot' command!

    A screenshot of a computer

Description automatically generated

     

    Check My Work

    A personal favorite feature that's gotten even better in Maple 2024 is Check My Work. As someone who has tutored students, I vividly recall their stress before exams, often receiving emails and text messages from them seeking last-minute help. At the time, I found myself wishing the students had a way to check their work themselves, so we would all be less stressed! So I was super excited when we added the first Check My Work feature a couple of years ago, and am very happy that it gets better ever year. In Maple 2024, we’ve expanded its capabilities to support problems involving factoring, simplification, and limits.

    A screenshot of a computer

Description automatically generated

    Scrollable Matrices:
    This feature will definitely resonate with many of the engineers in the Maple Primes community. If you're someone who works with worksheets containing large matrices, you've likely wished that you could scroll the matrices inside your document instead of having to launch a separate matrix browser. With Maple 2024, your wish has come true.

     

    A white sheet with numbers and lines

Description automatically generated with medium confidence

     

    Color Bars

    And finally, for those of you who appreciated the addition of color bars in Maple 2023 but wanted to see them extended to more 2D and 3D plots, you'll be delighted to know that this is exactly what we’ve done. We’ve also added new customization options, providing you with greater control over appearance.

     

    A close-up of a graph

Description automatically generated

     

    This is just a partial glimpse of what's new in Maple 2024. For a comprehensive overview, visit What’s New in Maple 2024.

    Maple Transactions frequently gets submissions that contain Maple code.  The papers (or videos, or Maple documents, or Jupyter notebooks) that we get are, if the author wants a refereed submission, sent to referees by a fairly usual academic process.  We look for well-written papers on topics of interest to the Maple community.

    But we could use some help in reviewing code, for some of the submissions.  Usually the snippets are short, but sometimes the packages involved are more substantial.

    If you would be interested in having your name on the list of potential code reviewers, please email me (or Paulina Chin, or Jürgen Gerhard) and we will gratefully add you.  You might not get called on immediately---it depends on what we have in the queue.

    Thank you very much, in advance, for sharing your expertise.

    Rob

    First 10 11 12 13 14 15 16 Last Page 12 of 308