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

  •  

    WE20 Oceanography Historical Perspective

     

    Maple is a trademark of Waterloo Maple Inc.

     

    Adapted from Introductory Oceanography 10th ed. by Harold V. Thurman and Alan P. Trujillo

     

    1.  How did the view of the ocean by early Mediterranean cultures influence the naming of planet Earth?

     

    Early cultures envisioned the world as composed of large landmasses surrounded by marginal bodies of water.

     

    2.  What is the difference between an ocean and a sea?  Which ones are the seven seas?

     

    A sea is

       •  Smaller and shallower than an ocean (this is why the Arctic Ocean might be more appropriately considered a sea)

       •  Composed of salt water (many "seas" such as the Caspian Sea in Asia, are actually large fresh water lakes)

       •  Somewhat enclosed by land (but some seas, such as the Sargasso Sea in the Atlantic Ocean, are defined by strong ocean currents rather than land.

     

    The seven seas:  the North Pacifiic, the South Pacific, the North Atlantic, the South Atlantic, the Indian, the Arctic, and the Southern or Antarctic.

     

    3.  Describe the development of navigation techniques that have enabled sailors to navigate the open ocean far from land.

     

    Initially, navigators in the Northern Hemisphere measured the angle between the horizon and the North Star (Polaris), which is directly above the North Pole.  Latitude could be determined by noting the angular difference between the horizon and the North Star.  In the Southern Hemisphere, the angle between the horizon and the Southern Cross was used because the Southern Cross is directly overhead at the South Pole.

     

    There was no method of determining longitude until one based on time was developed at the end of the 18th century.  Pendulum-driven clocks in use in the early 1700s would not work for long on a rocking ship at sea.  In 1728 a cabinetmaker in Lincolnshire, England, named John Harrison, began working on a new type of time peace.  The "chronometer" was driven by a helical balance spring that remained horizontal and independent of ship motion.

     

    As Earth turns on its rotational axis it moves through 2Pi radian every 24 hours (one complete rotation).  Earth, therefore, rotates through (1/12)*Pi radian of longitude per hour.  As a result, a navigator need only know the time at the prime or Greenwich at the exact same time the sun is at its highest point (local noon) at the ship's location.

     

    Suppose a ship sets sail west across the Atlantic Ocean from Europe, checking its longitude each day when the sun is at its highest point (solar noon) at the ship's location.  On one day the chronometer reads 16:18 hours.  What is the location of the ship?

     

    The ship is 4 hours and 18 minutes behind (west of) Greenwich time.  To determine the longitude we must convert time into longitude.  

     

    (1/12)*Pi radian of longitude per hour

    (1/12)*Pi*(1/60) = (1/720)*Piradian of longitude per minute

    (1/720)*Pi*(1/60) = (1/43200)*Piradian of longitude per second

     

    4*((1/12)*Pi)+18*((1/720)*Pi) = 43*Pi*(1/120)

     

    180*(43*Pi*(1/120))/Pi = 7740*(1/120) and 7740*(1/120) = 129/2 and 129/2 = 64.5degree west of the Greenwich meridian.

     

    In Maple:

    dg := proc (hr, mn, sc) local r, d, d_dec; r := (1/12)*hr*Pi+(1/720)*mn*Pi+(1/4320)*sc*Pi; d := 180*r/Pi; d_dec := evalf[5](d); print(d, d_dec) end proc

    dg(4, 18, 0)

    129/2, 64.500

    (1)

    4.  Construct a time line that includes the major events of human history that have resulted in greater understanding of our planet in general and the oceans in particular.

     

     

     

     

     

     

    5.  Using a diagram, illustrate the method used by Eratosthenes to calculate the circumference of Earth.

     

    Eratoshenes (276–192 BCE) had heard that at noon on the longest day of the year the Sun shone directly into the waters of a deep,vertical well in Syene (Aswan), which was 800 kilometers (500 miles) to the south.  At the same time in Alexandria, he noticed a vertical pole cast a slight shadow when the Sun was at its apex in the sky over Alexandria.  He accurately measured the shadow the pole cast, which was 7.2 degree.

     

    Convert 7.2 ° to radian  alpha^R = ((1/180)*Pi*`#msup(mi("α",fontstyle = "normal"),mo("∘"))`*Pi)*`#msup(mn("7.2"),mo("∘"))` and ((1/180)*Pi*`#msup(mi("α",fontstyle = "normal"),mo("∘"))`*Pi)*`#msup(mn("7.2"),mo("∘"))` = (1/25)*Pi

    7.2*(1/180)

    0.4000000000e-1

    (2)

    convert(0.4000000000e-1, 'rational', 'exact')

    1/25

    (3)

    (2*Pi*800)*km/((1/25)*Pi) = 40000*km

    (2*Pi*800)/((1/25)*Pi)

    40000

    (4)

     The equatorial circumference of Earth is about 24,901 miles (40,075 km). However, from pole-to-pole — the meridional circumference — Earth is only 24,860 miles (40,008 km) around. This shape, caused by the flattening at the poles, is called an oblate spheroid.  Since Eratoshenes was calculating the meridional circumference, his calculation was only 8 km different from the accepted modern measurement.

     

    The following calculations are for the diagram.

      

    NULLNULL`implies`(40000/(2*Pi) = 20000*alpha/Pi and 20000*alpha/Pi = (1/25)*Pi*sin(alpha) and (1/25)*Pi*sin(alpha) = y/c, c*sin(alpha) = y)

    `≈`(20000*sin((1/25)*Pi)/Pi, 798*kg)NULLNULL

    20000*sin((1/25)*Pi)/Pi

    20000*sin((1/25)*Pi)/Pi

    (5)

    evalf[10](20000*sin((1/25)*Pi)/Pi)

    797.8961462

    (6)

    `implies`(tan(alpha) = y/x implies tan(alpha)/y = 1/x, y/tan(alpha) = 20000*x*sin((1/25)*Pi)/(Pi*tan((1/25)*Pi)) and `≈`(20000*x*sin((1/25)*Pi)/(Pi*tan((1/25)*Pi)), 6316*km))

    20000*sin((1/25)*Pi)/(Pi*tan((1/25)*Pi))

    20000*sin((1/25)*Pi)/(Pi*tan((1/25)*Pi))

    (7)

    evalf[10](20000*sin((1/25)*Pi)/(Pi*tan((1/25)*Pi)))

    6315.998350

    (8)

    NULL

     

    with(plottools); with(plots)

    p1 := circle([0, 0], 20000/Pi)

    p2 := line([0, 0], [6316, 798])

    p3 := line([0, 0], [6316, 0])

    p4 := pointplot([[6316, 0], [6316, 798]], color = yellow, symbol = solidcircle, symbolsize = 25, transparency = .3)

    p5 := textplot({[4400, -600, "Syene (Aswan)"], [4400, 1300, "Alexandria"]}, font = [Perpetua, bold, 18])

    display(p1, p2, p3, p4, p5, scaling = constrained, size = [350, 350], axes = none)

     

     

    6.  While the Arabs dominated the Mediterranean region during the Middle Ages, what were the most significant ocean-related events taking place in Europe?

     

    Between 831 and 1071, the Emirate of Sicily was one of the major centers of Islamic culture in the Mediterranean. After its conquest by the Christian Normans, the island developed its own distinct culture with the fusion of Latin and Byzantine influences. Palermo remained a leading artistic and commercial center of the Mediterranean well into the Middle Ages.

     

    Europe was reviving, however, as more organized and centralized states began to form in the later Middle Ages after the Renaissance of the 12th century. Motivated by religion and dreams of conquest, the kings of Europe launched a number of Crusades to try to roll back Muslim power and retake the holy land. The Crusades were unsuccessful in this goal, but they were far more effective in weakening the already tottering Byzantine Empire that began to lose increasing amounts of territory to the Seljuk Turks and later to the Ottoman Turks. They also rearranged the balance of power in the Muslim world as Egypt once again emerged as a major power in the eastern Mediterranean.

     

    7.  Describe the important events in oceanography that occurred during the Age of Discovery in Europe.

     

    One of the most famous voyages during the Age of Discovery began in 1768 when the HMS Endeavour left Portsmouth, England, under the command of Captain James Cook. Over 10 years Cook led three world-encircling expeditions and mapped many countries, including Australia, New Zealand and the Hawaiian Islands. He was an expert seaman, navigator and scientist who made keen observations wherever he went. He was also one of the first ship captains to recognize that a lack of Vitamin C in sailors’ diets (due mostly to a lack of fresh fruit) caused scurvy, a serious disease that killed many sailors in those times. Cook always sailed with lots of pickled cabbage, which he insisted that the sailors eat. Scurvy was never a problem on his ships because the cabbage contained lots of Vitamin C.

     

    8.  List some of the major achievements of Captain James Cook.

    .com

    Three important voyages commanded by Captain Cook:  

    1771–1768  Endeavor observes the transit of Venus in Tahiti; charts New Zealand; charts the eastern coastline of Australia and continues on to New Guinea and Java.

     

    1772–1776 Resolution crosses the Anartic circle for the first time in history.  On returning to England Cook writes about preventing scurvy on long voyages.

     

    1776–1779 Resolution and Discovery visit New Zealand, Tonga, Tahiti, and Christmas Island; Hawaiian islands discovered; expedition crosses the Pacific eastwards to make landfall off the coast of Oregon.  Cook sails into the Bering Straits but foiled by ice he returns to Hawaii where he is killed by natives on 14 Feb 1779.

     

    9.  Describe, in general, the voyages of  HMS Challenger and HMS Beagle.

     

    The Beagle sailed from Plymouth Sound on 27 December 1831 under the command of Captain Robert FitzRoy. While the expedition was originally planned to last two years, it lasted almost five—the Beagle did not return until 2 October 1836. Darwin spent most of this time exploring on land (three years and three months on land; 18 months at sea). The book he wrote is a vivid travel memoir as well as a detailed scientific field journal covering biology, geology, and anthropology that demonstrates Darwin's keen powers of observation, written at a time when Western Europeans were exploring and charting the whole world.

     

    Darwin's notes made during the voyage include comments hinting at his changing views on the inflexibility of species. On his return to England, he wrote the book based on these notes, at a time when he was first developing his theories of evolution through common descent and natural selection. The book includes some suggestions of his ideas, particularly in the second edition of 1845 (Thurman and Trujillo, p. 23).

     

    On December 21, 1872 the HMS. Challenger sailed from Portsmouth, England, for an epic voyage which would last almost three and a half years. It  was the first expedition organized and funded for a specific scientific purpose: to examine the deep-sea floor and answer questions about the ocean environment.  Although the mission was scientific, another purpose was to collect information that could be used in the laying of communication cables along the sea floor.

     

    The expedition covered 69,000 miles (about 130,000 km) and gathered data on currents, water chemistry, temperature, bottom deposits and marine life at 362 oceanographic stations. More than 4700 new species of marine animals were discovered during the course of the voyage, many of which were found on the seafloor – an environment that scientists originally believed to be too inhospitable to support life (https://paleonerdish.wordpress.com/2013/07/01/the-challenger-expedition-and-the-beginning-of-oceanography/).

     

    10.  Describe the voyages of the Fram and how it helped prove there was no continent beneath the Arctic ice pack.

     

    The Fram was the first ship specially built (in Norway) for polar research. She was used on three important expeditions: with Fridtjof Nansen on a drift over the Arctic Ocean 1893-96, with Otto Sverdrup to the arctic archipelago west of Greenland - now the Nunavut region of Canada - 1898-1902, and with Roald Amundsen to Antarctica for his South Pole expedition 1910-12. The Fram is now housed and exhibited in the Fram Museum at Bygdøynes, Oslo

    (https://frammuseum.no/polar_history/vessels/the_polar_ship_fram/).

     

    11.  Why did Benjamin Franklin want to know about the surface current pattern in the North Atlantic Ocean?

     

    As Deputy Postmaster General of the American colonies, Franklin promoted using the Gulf Stream to speed up delivery of mail from America to Europe, as well as to improve other commercial shipping (https://divediscover.whoi.edu/history-of-oceanography/benjamin-franklin-discovering-the-gulf-stream/).

     

    12.  What was Alexander Agassiz's major contribution to an increased knowledge of the oceans?

     

    Agassiz is widely acknowledged as the driving force that brought oceanography recognition as a science.  His training as a mining engineer led him to develop ingenious oceanographic sampling devices—the prototypes for many devices in use on research vessels today—that improved the quantitative value of biological sampling (Thurman and Trujillo, p. 27).

     

    13.  What important oceanographic inventions and data came out of Word Wars I and II?

    The need to detect submarines led the navies of the world to greatly expand their studies of the sea. This led to the founding of oceanography departments at state universities, including Oregon State, Texas A&M University, University of Miami, and University of Rhode Island,

    and the founding of national ocean laboratories such as the various Institutes of Oceanographic Science (https://earthweb.ess.washington.edu/booker/ESS514/stewart/ stewart_ocean_book.pdf).

     

    14.  List features of the oceans that can be studied remotely by use of satellites.

     

    • phytoplankton concentrations

    • heat storage and aerosol formation and other ocean influences on climate processes

    • cycles of carbon, sulfur, and nitrogen concentrations

    (https://www.nrcan.gc.ca/earth-sciences/geomatics/satellite-imagery-air-photos/satellite-imagery-products/educational-resources/9359).

    • Bathymetry/Seafloor (Bathymetry is the measurement of depth of water in oceans seas, or lakes)

    • Topography

    • Costal Process

    • Marine Geophysics

    • Ocean Acoustics

    • Ocean Chemistry

    • Ocean Circulation

    • Ocean Heat Budget

    • Ocean Optics

    • Ocean Pressure

    • Ocean Temperature

    • Ocean Waves

    • Ocean Winds

    • Salinity/Density

    • Sea ice

    • Sea Surface Topography

    (https://earthdata.nasa.gov/learn/discipline/ocean)

     

    15.  Discuss what problems the human body can experience as a result of diving underwater.

     

    Nitrogen narcosis (also referred to as inert gas narcosis, raptures of the deep, and the Martini effect) :  While scuba diving does sometimes involve breathing air that’s mixed with nitrogen, this condition is caused when the diver goes deeper into the water, where the partial pressure of nitrogen increases and more nitrogen ends up getting absorbed into the bloodstream. The higher the nitrogen concentration in the bloodstream, the slower the nervous system will be, and the more likely the diver will experience intoxicating effects that can seriously impair their judgment underwater—possibly enough to lead them into dangerous situations (https://www.leisurepro.com/blog/scuba-guides/dealing-nitrogen-narcosis-2/).

     

    Barotrauma: Trauma caused by rapid or extreme changes in air pressure, especially affecting enclosed cavities within the body such as the middle ear (otic barotrauma), the sinuses (sinus barotrauma), and the lungs (pulmonary barotrauma) (https://www.medicinenet.com/script/main/art.asp?articlekey=31722).

     

    Decompression illness is caused by intravascular or extravascular bubbles that are formed as a result of reduction in environmental pressure (decompression). The term covers both arterial gas embolism, in which alveolar gas or venous gas emboli (via cardiac shunts or via pulmonary vessels) are introduced into the arterial circulation, and decompression sickness, which is caused by in-situ bubble formation from dissolved inert gas. Both syndromes can occur in divers, compressed air workers, aviators, and astronauts, but arterial gas embolism also arises from iatrogenic causes unrelated to decompression. Risk of decompression illness is affected by immersion, exercise, and heat or cold. Manifestations range from itching and minor pain to neurological symptoms, cardiac collapse, and death. First-aid treatment is 100% oxygen and definitive treatment is recompression to increased pressure, breathing 100% oxygen. Adjunctive treatment, including fluid administration and prophylaxis against venous thromboembolism in paralysed patients, is also recommended. Treatment is, in most cases, effective although residual deficits can remain in serious cases, even after several recompressions (https://www.thelancet.com/journals/lancet/article/PIIS0140-6736(10)61085-9/fulltext).


     

    Download WE20_Oceanography_Historical_Persepceive.mw

    We are currently in the process of updating the support FAQs at https://faq.maplesoft.com. We’ve been working on updating the existing content for clarity, and have added several new articles already.

     

    The majority of our FAQs are from questions people ask us in Technical Support at support@maplesoft.com, but we’d also like to like to add content from other sources.

    Since we have such a great community here at MaplePrimes, we wanted to reach out and ask if there are any articles or questions that you'd like to see added to our FAQ.

     

    We look forward to hearing your feedback!

    I experienced a significant obstacle while trying to generate independent random samples with Statistics:-Sample on different nodes of a Grid multi-processing environment. After many hours of trial-and-error, I discovered an astonishing workaround, and I achieved excellent time and memory performance. Since this seems like a generally useful computation, I thought that it was worthy of a Post.

    This Post is also worth reading to learn how to use Grid when you need to initialize a substantial environment on each node before using Grid:-Map or Grid:-Seq.

    All remaining details are in the following worksheet.
     

    How to use Statistics:-Sample in the `Grid` environment

    Author: Carl Love <carl.j.love@gmail.com> 1 August 2019

     

    I experienced a significant obstacle while trying to generate indenpendent random samples with Statistics:-Sample on the nodes of a multi-processor Grid (on a single computer). After several hours of trial-and-error, I discovered that two things are necessary to do this:

    1. 

    The random number generator needs to be seeded differently in each node. (The reason for this is easy to understand.)

    2. 

    The random variables generated by Statistics:-RandomVariable need to have different names in each node. This one is mind-boggling to me. Afterall, each node has its own kernel and so its own memory It's as if the names of random variables are stored in a disk file which all kernels access. And also the generator has been seeded differently in each node.

     

    Once these things were done, the time and memory performance of the computation were excellent.

    restart
    :

    Digits:= 15
    :

    #Specify the size of the computation:
    (n1,n2,n3):= (100, 100, 1000):
    # n1 = size of each random sample;
    # n2 = number of samples in a batch;
    # n3 = number of batches.

    #
    #Procedure to initialize needed globals on each node:
    Init:= proc(n::posint)
    local node:= Grid:-MyNode();
       #This is wrapped in parse so that it'll act globally. Otherwise, an environment
       #variable would be reset when this procedure ends.
       parse("Digits:= 15;", 'statement');

       randomize(randomize()+node); #Initialize independent RNG for this node.
       #If repeatability of results is desired, remove the inner randomize().

       (:-X,:-Y):= Array(1..n, 'datatype'= 'hfloat') $ 2;

       #Perhaps due to some oversight in the design of Statistics, it seems necessary that
       #r.v.s in different nodes **need different names** in order to be independent:
       N||node:= Statistics:-RandomVariable('Normal'(0,1));
       :-TRS:= (X::rtable)-> Statistics:-Sample(N||node, X);
       #To verify that different names are needed, change N||node to N in both lines.
       #Doing so, each node will generate identical samples!

       #Perform some computation. For the pedagogical purpose of this worksheet, all that
       #matters is that it's some numeric computation on some Arrays of random Samples.
       :-GG:= (X::Array, Y::Array)->
          evalhf(
             proc(X::Array, Y::Array, n::posint)
             local s, k, S:= 0, p:= 2*Pi;
                for k to n do
                   s:= sin(p*X[k]);  
                   S:= S + X[k]^2*cos(p*Y[k])/sqrt(2-sin(s)) + Y[k]^2*s
                od
             end proc
             (X, Y, n)
          )      
       ;
       #Perform a batch of the above computations, and somehow numerically consolidate the
       #results. Once again, pedagogically it doesn't matter how they're consolidated.  
       :-TRX1:= (n::posint)-> add(GG(TRS(X), TRS(Y)), 1..n);
       
       #It doesn't matter much what's returned. Returning `node` lets us verify that we're
       #actually running this on a grid.
       return node
    end proc
    :

    The procedure Init above uses the :- syntax to set variables globally for each node. The variables set are X, Y, N||node, TRS, GG, and TRX1. Names constructed by concatenation, such as N||node, are always global, so :- isn't needed for those.

    #
    #Time the initialization:
    st:= time[real]():
       #Send Init to each node, but don't run it yet:
       Grid:-Set(Init)
       ;
       #Run Init on each node:
       Nodes:= Grid:-Run(Init, [n1], 'wait');
    time__init_Grid:= time[real]() - st;

    Array(%id = 18446745861500764518)

    1.109

    The only purpose of array Nodes is that it lets us count the nodes, and it lets us verify that Grid:-MyNode() returned a different value on each node.

    num_nodes:= numelems(Nodes);

    8

    #Time the actual execution:
    st:= time[real]():
       R1:= [Grid:-Seq['tasksize'= iquo(n3, num_nodes)](TRX1(k), k= [n2 $ n3])]:
    time__run_Grid:= time[real]() - st

    4.440

    #Just for comparison, run it sequentially:
    st:= time[real]():
       Init(n1):
    time__init_noGrid:= time[real]() - st;

    st:= time[real]():
       R2:= [seq(TRX1(k), k= [n2 $ n3])]:
    time__run_noGrid:= time[real]() - st;

    0.16e-1

    24.483

    R1 and R2 will be different because different random numbers were used, but they should have similar histograms.

    plots:-display(
       Statistics:-Histogram~(
          <R1 | R2>, #side-by-side plots
          'title'=~ <<"With Grid\n"> | <"Without Grid\n">>,
          'gridlines'= false
       )
    );

    (Plot output deleted because MaplePrimes cannot handle side-by-side plots!)

    They look similar enough to me!

     

    Let's try to quantify the benefit of using Grid:

    speedup_factor:= time__run_noGrid / time__run_Grid;

    5.36319824753560

    Express that as a fraction of the theoretical maximum speedup:

    efficiency:= speedup_factor / num_nodes;

    .670399780941950

    I think that that's really good!

     

    The memory usage of this code is insignificant, which can be verified from an external memory monitor such as Winodws Task Manager. It's just a little bit more than that needed to start a kernel on each node. It's also possible to measure the memory usage programmatically. Doing so for a Grid:-Seq computation is a little bit beyond the scope of this worksheet.

     


     

    Download GridRandSample.mw

    Here are the histograms:

    In this post, the Numbrix Puzzle is solved by the branch and bound method (see the details of this puzzle in  https://www.mapleprimes.com/posts/210643-Solving-A-Numbrix-Puzzle-With-Logic). The main difference from the solution using the  Logic  package is that here we get not one but all possible solutions. In the case of a unique solution, the  NumbrixPuzzle procedure is faster than the  Numbrix  one (for convenience, I inserted the code for Numbrix procedure into the worksheet below). In the case of many solutions, the  Numbrix  procedure is usually faster (see all the examples below).

     

    restart;

    NumbrixPuzzle:=proc(A::Matrix)
    local A1, L, N, S, MS, OneStepLeft, OneStepRight, F1, F2, m, L1, p, q, a, b, T, k, s1, s, H, n, L2, i, j, i1, j1, R;
    uses ListTools;
    S:=upperbound(A); N:=nops(op(A)[3]); MS:=`*`(S);
    A1:=convert(A, listlist);
    for i from 1 to S[1] do
    for j from 1 to S[2] do
    for i1 from i to S[1] do
    for j1 from 1 to S[2] do
    if A1[i,j]<>0 and A1[i1,j1]<>0 and abs(A1[i,j]-A1[i1,j1])<abs(i-i1)+abs(j-j1) then return `no solutions` fi;
    od; od; od; od;
    L:=sort(select(e->e<>0, Flatten(A1)));
    L1:=[`if`(L[1]>1,seq(L[1]-k, k=0..L[1]-2),NULL)];
    L2:=[seq(seq(`if`(L[i+1]-L[i]>1,L[i]+k,NULL),k=0..L[i+1]-L[i]-2), i=1..nops(L)-1), `if`(L[-1]<MS,seq(L[-1]+k,k=0..MS-L[-1]-1),NULL)];
      

    OneStepLeft:=proc(A1::listlist)
    local s, M, m, k, T;
    uses ListTools;
    s:=Search(a, Matrix(A1));   
    M:=[[s[1]-1,s[2]],[s[1]+1,s[2]],[s[1],s[2]-1],[s[1],s[2]+1]];
    T:=table(); k:=0;
    for m in M do
    if m[1]>=1 and m[1]<=S[1] and m[2]>=1 and m[2]<=S[2] and A1[op(m)]=0 then k:=k+1; T[k]:=subsop(m=a-1,A1);
    fi;
    od;
    convert(T, list);
    end proc;

     
    OneStepRight:=proc(A1::listlist)
    local s, M, m, k, T, s1;
    uses ListTools;
    s:=Search(a, Matrix(A1));  s1:=Search(a+2, Matrix(A1));  
    M:=[[s[1]-1,s[2]],[s[1]+1,s[2]],[s[1],s[2]-1],[s[1],s[2]+1]];
    T:=table(); k:=0;
    for m in M do
    if m[1]>=1 and m[1]<=S[1] and m[2]>=1 and m[2]<=S[2] and A1[op(m)]=0 and `if`(a+2 in L, `if`(is(abs(s1[1]-m[1])+abs(s1[2]-m[2])>1),false,true),true) then k:=k+1; T[k]:=subsop(m=a+1,A1);
    fi;
    od;
    convert(T, list);   
    end proc;

    F1:=LM->ListTools:-FlattenOnce(map(OneStepLeft, LM));
    F2:=LM->ListTools:-FlattenOnce(map(OneStepRight, LM));

    T:=[A1];
    for a in L1 do
    T:=F1(T);
    od;

    for a in L2 do
    T:=F2(T);
    od;

    R:=map(t->convert(t,Matrix), T);
    if nops(R)=0 then return `no solutions` else R[] fi;

    end proc:

    Numbrix := proc( M :: ~Matrix, { inline :: truefalse := false } )

    local S, adjacent, eq, i, initial, j, k, kk, m, n, one, single, sol, unique, val, var, x;

        (m,n) := upperbound(M);

        initial := &and(seq(seq(ifelse(M[i,j] = 0
                                       , NULL
                                       , x[i,j,M[i,j]]
                                      )
                                , i = 1..m)
                            , j = 1..n));

        adjacent := &and(seq(seq(seq(x[i,j,k] &implies &or(NULL
                                                           , ifelse(i>1, x[i-1, j, k+1], NULL)
                                                           , ifelse(i<m, x[i+1, j, k+1], NULL)
                                                           , ifelse(j>1, x[i, j-1, k+1], NULL)
                                                           , ifelse(j<n, x[i, j+1, k+1], NULL)
                                                          )
                                     , i = 1..m)
                                 , j = 1..n)
                             , k = 1 .. m*n-1));

        one := &or(seq(seq(x[i,j,1], i=1..m), j=1..n));   


        single := &not(&or(seq(seq(seq(seq(x[i,j,k] &and x[i,j,kk], kk = k+1..m*n), k = 1..m*n-1)
                                    , i = 1..m), j = 1..n)));

        sol := Logic:-Satisfy(&and(initial, adjacent, one, single));
        
        if sol = NULL then
            error "no solution";
        end if;
    if inline then
            S := M;
         else
            S := Matrix(m,n);
        end if;

        for eq in sol do
            (var, val) := op(eq);
            if val then
                S[op(1..2, var)] := op(3,var);
            end if;
        end do;
        S;
    end proc:

               Two simple examples

    A:=<0,0,5; 0,0,0; 0,0,9>;
    # The unique solution
    NumbrixPuzzle(A);

    A:=<0,0,5; 0,0,0; 0,8,0>;
    # 4 solutions
    NumbrixPuzzle(A);

    Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 5, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 9})

     

    Matrix(3, 3, {(1, 1) = 3, (1, 2) = 4, (1, 3) = 5, (2, 1) = 2, (2, 2) = 7, (2, 3) = 6, (3, 1) = 1, (3, 2) = 8, (3, 3) = 9})

     

    Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 5, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 8, (3, 3) = 0})

     

    Matrix(%id = 18446746210121682686), Matrix(%id = 18446746210121682806), Matrix(%id = 18446746210121674750), Matrix(%id = 18446746210121674870)

    (1)


    Comparison with Numbrix procedure. The example is taken from
    http://rosettacode.org/wiki/Solve_a_Numbrix_puzzle 

     A:=<0, 0, 0, 0, 0, 0, 0, 0, 0;
     0, 0, 46, 45, 0, 55, 74, 0, 0;
     0, 38, 0, 0, 43, 0, 0, 78, 0;
     0, 35, 0, 0, 0, 0, 0, 71, 0;
     0, 0, 33, 0, 0, 0, 59, 0, 0;
     0, 17, 0, 0, 0, 0, 0, 67, 0;
     0, 18, 0, 0, 11, 0, 0, 64, 0;
     0, 0, 24, 21, 0, 1, 2, 0, 0;
     0, 0, 0, 0, 0, 0, 0, 0, 0>;
    CodeTools:-Usage(NumbrixPuzzle(A));
    CodeTools:-Usage(Numbrix(A));

    Matrix(9, 9, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (1, 9) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 46, (2, 4) = 45, (2, 5) = 0, (2, 6) = 55, (2, 7) = 74, (2, 8) = 0, (2, 9) = 0, (3, 1) = 0, (3, 2) = 38, (3, 3) = 0, (3, 4) = 0, (3, 5) = 43, (3, 6) = 0, (3, 7) = 0, (3, 8) = 78, (3, 9) = 0, (4, 1) = 0, (4, 2) = 35, (4, 3) = 0, (4, 4) = 0, (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = 71, (4, 9) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 33, (5, 4) = 0, (5, 5) = 0, (5, 6) = 0, (5, 7) = 59, (5, 8) = 0, (5, 9) = 0, (6, 1) = 0, (6, 2) = 17, (6, 3) = 0, (6, 4) = 0, (6, 5) = 0, (6, 6) = 0, (6, 7) = 0, (6, 8) = 67, (6, 9) = 0, (7, 1) = 0, (7, 2) = 18, (7, 3) = 0, (7, 4) = 0, (7, 5) = 11, (7, 6) = 0, (7, 7) = 0, (7, 8) = 64, (7, 9) = 0, (8, 1) = 0, (8, 2) = 0, (8, 3) = 24, (8, 4) = 21, (8, 5) = 0, (8, 6) = 1, (8, 7) = 2, (8, 8) = 0, (8, 9) = 0, (9, 1) = 0, (9, 2) = 0, (9, 3) = 0, (9, 4) = 0, (9, 5) = 0, (9, 6) = 0, (9, 7) = 0, (9, 8) = 0, (9, 9) = 0})

     

    memory used=7.85MiB, alloc change=-3.01MiB, cpu time=172.00ms, real time=212.00ms, gc time=93.75ms

     

    Matrix(9, 9, {(1, 1) = 49, (1, 2) = 50, (1, 3) = 51, (1, 4) = 52, (1, 5) = 53, (1, 6) = 54, (1, 7) = 75, (1, 8) = 76, (1, 9) = 81, (2, 1) = 48, (2, 2) = 47, (2, 3) = 46, (2, 4) = 45, (2, 5) = 44, (2, 6) = 55, (2, 7) = 74, (2, 8) = 77, (2, 9) = 80, (3, 1) = 37, (3, 2) = 38, (3, 3) = 39, (3, 4) = 40, (3, 5) = 43, (3, 6) = 56, (3, 7) = 73, (3, 8) = 78, (3, 9) = 79, (4, 1) = 36, (4, 2) = 35, (4, 3) = 34, (4, 4) = 41, (4, 5) = 42, (4, 6) = 57, (4, 7) = 72, (4, 8) = 71, (4, 9) = 70, (5, 1) = 31, (5, 2) = 32, (5, 3) = 33, (5, 4) = 14, (5, 5) = 13, (5, 6) = 58, (5, 7) = 59, (5, 8) = 68, (5, 9) = 69, (6, 1) = 30, (6, 2) = 17, (6, 3) = 16, (6, 4) = 15, (6, 5) = 12, (6, 6) = 61, (6, 7) = 60, (6, 8) = 67, (6, 9) = 66, (7, 1) = 29, (7, 2) = 18, (7, 3) = 19, (7, 4) = 20, (7, 5) = 11, (7, 6) = 62, (7, 7) = 63, (7, 8) = 64, (7, 9) = 65, (8, 1) = 28, (8, 2) = 25, (8, 3) = 24, (8, 4) = 21, (8, 5) = 10, (8, 6) = 1, (8, 7) = 2, (8, 8) = 3, (8, 9) = 4, (9, 1) = 27, (9, 2) = 26, (9, 3) = 23, (9, 4) = 22, (9, 5) = 9, (9, 6) = 8, (9, 7) = 7, (9, 8) = 6, (9, 9) = 5})

     

    memory used=1.21GiB, alloc change=307.02MiB, cpu time=37.00s, real time=31.88s, gc time=9.30s

     

    Matrix(%id = 18446746210094669942)

    (2)


    In the example below, which has 104 solutions, the  Numbrix  procedure is faster.

    C:=Matrix(5,{(1,1)=1,(5,5)=25});
    CodeTools:-Usage(NumbrixPuzzle(C)):
    nops([%]);
    CodeTools:-Usage(Numbrix(C)):

    Matrix(5, 5, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0, (4, 5) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 25})

     

    memory used=0.94GiB, alloc change=-22.96MiB, cpu time=12.72s, real time=11.42s, gc time=2.28s

     

    104

     

    memory used=34.74MiB, alloc change=0 bytes, cpu time=781.00ms, real time=783.00ms, gc time=0ns

     

     


     

    Download NumbrixPuzzle.mw

    For no particular reason at all, these are parametric equations that print "Maplesoft" in handwritten cursive script when plotted

    restart:
    X := -2.05*sin(-2.70 + 2.45*t) - 3.36*sin(1.12 + 1.43*t) - 4.82*sin(-2.19 + 2.03*t) - 2.02*sin(1.36 + 2.31*t) - 2.41*sin(1.08 + 2.59*t) - 14.2*sin(1.51 + 0.185*t) - 5.25*sin(-2.04 + 1.85*t) - 2.81*sin(0.984 + 2.36*t) - 3.01*sin(-2.04 + 1.80*t) - 1.80*sin(-2.61 + 2.73*t) - 0.712*sin(-3.94 + 1.89*t) - 6.90*sin(-1.90 + 1.52*t) - 0.600*sin(-3.39 + 2.26*t) - 0.631*sin(-4.65 + 2.68*t) - 3.10*sin(-2.22 + 2.17*t) - 2.95*sin(1.38 + 1.25*t) - 1.43*sin(0.383 + 2.40*t) - 8.25*sin(-1.66 + 0.323*t) - 1.39*sin(-3.08 + 2.63*t) - 0.743*sin(-2.43 + 0.647*t) - 6.25*sin(-1.73 + 0.832*t) - 273.*sin(-1.58 + 0.0462*t) - 4.58*sin(-2.00 + 1.48*t) - 5.70*sin(-1.80 + 1.20*t) - 2.30*sin(1.42 + 0.462*t) - 3.24*sin(1.51 + 0.277*t) - 16.0*sin(-1.64 + 0.231*t) - 1.58*sin(0.779 + 1.71*t) - 0.571*sin(-2.08 + 0.970*t) - 8.85*sin(-1.88 + 1.34*t) - 1.10*sin(-2.24 + 2.08*t) - 1.49*sin(-2.27 + 1.02*t) - 2.19*sin(-1.70 + 1.94*t) - 4.47*sin(-2.06 + 1.57*t) - 2.08*sin(-2.02 + 1.06*t) - 5.70*sin(-1.86 + 1.62*t) - 2.26*sin(-1.66 + 1.16*t) - 3.95*sin(-1.98 + 1.29*t) - 0.928*sin(-2.08 + 1.76*t) - 2.98*sin(1.36 + 1.11*t) - 0.390*sin(-2.33 + 2.22*t) - 3.81*sin(1.01 + 2.54*t) - 0.613*sin(-1.43 + 1.66*t) - 19.7*sin(-1.60 + 0.138*t) - 0.524*sin(-2.87 + 0.414*t) - 2.15*sin(-4.63 + 0.694*t) - 0.782*sin(-1.56 + 2.49*t) - 5.27*sin(-1.81 + 1.38*t) - 5.18*sin(1.51 + 0.0923*t) - 6.83*sin(1.37 + 0.923*t) - 0.814*sin(-1.72 + 0.600*t) - 2.98*sin(-1.82 + 0.738*t) - 5.49*sin(1.44 + 0.509*t) - 3.90*sin(-1.76 + 0.785*t) - 0.546*sin(-2.18 + 0.876*t) - 1.92*sin(0.755 + 1.98*t) - 8.16*sin(1.38 + 0.553*t) - 0.504*sin(-1.56 + 0.371*t) - 3.43*sin(1.14 + 2.12*t):
    Y := -1.05*sin(-3.81 + 2.68*t) - 7.72*sin(-4.59 + 0.231*t) - 6.38*sin(1.37 + 1.11*t) - 4.24*sin(-2.36 + 2.31*t) - 7.06*sin(1.18 + 1.80*t) - 4.60*sin(1.28 + 2.03*t) - 0.626*sin(-0.285 + 2.45*t) - 0.738*sin(-1.89 + 2.26*t) - 1.45*sin(-1.73 + 1.57*t) - 2.30*sin(-4.51 + 2.59*t) - 9.58*sin(-2.07 + 1.71*t) - 0.792*sin(-0.578 + 0.647*t) - 4.55*sin(1.49 + 1.25*t) - 14.0*sin(-2.13 + 1.62*t) - 1.02*sin(0.410 + 0.277*t) - 19.2*sin(-1.54 + 0.0462*t) - 17.3*sin(-1.86 + 1.20*t) - 1.96*sin(-0.845 + 2.63*t) - 0.754*sin(-0.0904 + 2.73*t) - 4.74*sin(1.11 + 1.48*t) - 1.79*sin(0.860 + 2.17*t) - 25.2*sin(-1.77 + 0.832*t) - 3.88*sin(1.30 + 0.462*t) - 20.8*sin(-1.66 + 0.323*t) - 17.6*sin(1.20 + 1.29*t) - 4.83*sin(0.169 + 2.36*t) - 10.8*sin(-2.01 + 1.85*t) - 8.69*sin(-2.17 + 2.22*t) - 5.48*sin(-1.69 + 1.34*t) - 18.1*sin(1.18 + 1.43*t) - 4.71*sin(0.728 + 2.08*t) - 1.15*sin(-3.44 + 1.52*t) - 2.53*sin(-2.61 + 2.54*t) - 5.48*sin(-2.02 + 1.94*t) - 4.67*sin(1.30 + 1.66*t) - 9.10*sin(1.37 + 0.970*t) - 6.45*sin(1.31 + 1.02*t) - 5.18*sin(-2.09 + 1.76*t) - 18.3*sin(-1.77 + 1.06*t) - 27.3*sin(1.31 + 1.16*t) - 2.83*sin(-3.01 + 2.40*t) - 2.93*sin(-1.70 + 0.138*t) - 4.17*sin(-2.06 + 2.12*t) - 1.60*sin(-4.25 + 1.38*t) - 2.69*sin(-1.89 + 0.371*t) - 7.92*sin(-1.78 + 0.600*t) - 19.6*sin(-1.79 + 0.738*t) - 22.6*sin(1.48 + 0.509*t) - 13.5*sin(1.21 + 0.923*t) - 5.53*sin(-1.64 + 0.0923*t) - 1.20*sin(0.145 + 2.49*t) - 3.15*sin(-1.57 + 0.414*t) - 1.74*sin(0.655 + 1.98*t) - 3.98*sin(-2.14 + 0.876*t) - 11.3*sin(-1.82 + 0.694*t) - 10.4*sin(0.987 + 1.89*t) - 8.39*sin(-1.53 + 0.185*t) - 27.8*sin(-1.76 + 0.785*t) - 9.39*sin(1.38 + 0.553*t):
    plot([X, Y, t = 0 .. 68], scaling = constrained, axes = boxed);

    Hare in the forest

    The rocket flies

      

    Быльнов_raketa_letit.mws

     

    Plotting the function of a complex variable

    Plotting_the_function_of_a_complex_variable.mws

     

    Animated 3-D cascade of dolls

     

    3d_matryoshkas_en.mws

     

    With this application developed entirely in Maple using native syntax and embedded components for science and engineering students. Just replace your data and you're done.

    Pearson_Coeficient.mw

    Lenin Araujo Castillo

    Ambassador of Maple

     

    Foucault’s Pendulum Exploration Using MAPLE18

    https://www.ias.ac.in/describe/article/reso/024/06/0653-0659

    In this article, we develop the traditional differential equation for Foucault’s pendulum from physical situation and solve it from
    standard form. The sublimation of boundary condition eliminates the constants and choice of the local parameters (latitude, pendulum specifications) offers an equation that can be used for a plot followed by animation using MAPLE. The fundamental conceptual components involved in preparing differential equation viz; (i) rotating coordinate system, (ii) rotation of the plane of oscillation and its dependence on the latitude, (iii) effective gravity with latitude, etc., are discussed in detail. The accurate calculations offer quantities up to the sixth decimal point which are used for plotting and animation. This study offers a hands-on experience. Present article offers a know-how to devise a Foucault’s pendulum just by plugging in the latitude of reader’s choice. Students can develop a miniature working model/project of the pendulum.

    Exercises solved online with Maple exclusively in space. I attach the explanation links on my YouTube channel.

    Part # 01

    https://www.youtube.com/watch?v=8Aa2xzU8LwQ

    Part # 02

    https://www.youtube.com/watch?v=qyGT28CeSz4

    Part # 03

    https://www.youtube.com/watch?v=yf8rjSPbv5g

    Part # 04

    https://www.youtube.com/watch?v=FwHPW7ncZTg

    Part # 05

    https://www.youtube.com/watch?v=bm3frpukb0I

    Link for download the file:

    Vector_Exercises-Force_in_space.mw

    Lenin AC

    Ambassador of Maple

     

     

     

    @chandrashekhar 

    There are no efficient algorithms for this.
    How would you simplify by hand the expression

    512*b^9 + (2303*a + 2304)*b^8 + (4616*a^2 + 9216*a + 4608)*b^7 + (5348*a^3 + 16128*a^2 + 16128*a + 5376)*b^6
     + (4088*a^4 + 16128*a^3 + 24192*a^2 + 16128*a + 4032)*b^5 + (1946*a^5 + 10080*a^4 + 20160*a^3 + 20160*a^2 
    + 10080*a + 2016)*b^4 + (728*a^6 + 4032*a^5 + 10080*a^4 + 13440*a^3 + 10080*a^2 + 4032*a + 672)*b^3 
    + (116*a^7 + 1008*a^6 + 3024*a^5 + 5040*a^4 + 5040*a^3 + 3024*a^2 + 1008*a + 144)*b^2 
    + (26*a^8 + 144*a^7 + 504*a^6 + 1008*a^5 + 1260*a^4 + 1008*a^3 + 504*a^2 + 144*a + 18)*b + 9*a^8 
    + 36*a^7 + 84*a^6 + 126*a^5 + 126*a^4 + 84*a^3 + 36*a^2 + 9*a + 1

    to  (a+2*b+1)^9 - a*(a-b)^8   ?

     

    We occasionally get asked questions about methods of Perturbation Theory in Maple, including the Lindstedt-Poincaré Method. Presented here is the most famous application of this method.

    Introduction

    During the dawn of the 20th Century, one problem that bothered astronomers and astrophysicists was the precession of the perihelion of Mercury. Even when considering the gravity from other planets and objects in the solar system, the equations from Newtonian Mechanics could not account for the discrepancy between the observed and predicted precession.

    One of the early successes of Einstein's General Theory of Relativity was that the new model was able to capture the precession of Mercury, in addition to the orbits of all the other planets. The Einsteinian model, when applied to the orbit of Mercury, was in fact a non-negligible perturbation of the old model. In this post, we show how to use Maple to compute the perturbation, and derive the formula for calculating the precession.

    In polar coordinates, the Einsteinian model can be written in the following form, where u(theta)=a(1-e^2)/r(theta), with theta being the polar angle, r(theta) being the radial distance, a being the semi-major axis length, and e being the eccentricity of the orbit:
     

    # Original system.
    f := (u,epsilon) -> -1 - epsilon * u^2;
    omega := 1;
    u0, du0 := 1 + e, 0;
    de1 := diff( u(theta), theta, theta ) + omega^2 * u(theta) + f( u(theta), epsilon );
    ic1 := u(0) = u0, D(u)(0) = du0;
    


    The small parameter epsilon (along with the amount of precession) can be found in terms of the physical constants, but for now we leave it arbitrary:
     

    # Parameters.
    P := [
        a = 5.7909050e10 * Unit(m),
        c = 2.99792458e8 * Unit(m/s),
        e = 0.205630,
        G = 6.6740831e-11 * Unit(N*m^2/kg^2), 
        M = 1.9885e30 * Unit(kg), 
        alpha = 206264.8062, 
        beta = 415.2030758 
    ];
    epsilon = simplify( eval( 3 * G * M / a / ( 1 - e^2 ) / c^2, P ) ); # approximately 7.987552635e-8


    Note that c is the speed of light, G is the gravitational constant, M is the mass of the sun, alpha is the number of arcseconds per radian, and beta is the number of revolutions per century for Mercury.

    We will show that the radial distance, predicted by Einstein's model, is close to that for an ellipse, as predicted by Newton's model, but the perturbation accounts for the precession (42.98 arcseconds/century). During one revolution, the precession can be determined to be approximately
     

    sigma = simplify( eval( 6 * Pi * G * M / a / ( 1 - e^2 ) / c^2, P ) ); # approximately 5.018727337e-7


    and so, per century, it is alpha*beta*sigma, which is approximately 42.98 arcseconds/century.
    It is worth checking out this question on Stack Exchange, which includes an animation generated numerically using Maple for a similar problem that has a more pronounced precession.

    Lindstedt-Poincaré Method in Maple

    In order to obtain a perturbation solution to the perturbed differential equation u'+omega^2*u=1+epsilon*u^2 which is periodic, we need to write both u and omega as a series in the small parameter epsilon. This is because otherwise, the solution would have unbounded oscillatory terms ("secular terms"). Using this Lindstedt-Poincaré Method, we substitute arbitrary series in epsilon for u and omega into the initial value problem, and then choose the coefficient constants/functions so that both the initial value problem is satisfied and there are no secular terms. Note that a first-order approximation provides plenty of agreement with the measured precession, but higher-order approximations can be obtained.

    To perform this in Maple, we can do the following:
     

    # Transformed system, with the new independent variable being the original times a series in epsilon.
    de2 := op( PDEtools:-dchange( { theta = phi/b }, { de1 }, { phi }, params = { b, epsilon }, simplify = true ) );
    ic2 := ic1;
    
    # Order and series for the perturbation solutions of u(phi) and b. Here, n = 1 is sufficient.
    n := 1;
    U := unapply( add( p[k](phi) * epsilon^k, k = 0 .. n ), phi );
    B := omega + add( q[k] * epsilon^k, k = 1 .. n );
    
    # DE in terms of the series.
    de3 := series( eval( de2, [ u = U, b = B ] ), epsilon = 0, n + 1 );
    
    # Successively determine the coefficients p[k](phi) and q[k].
    for k from 0 to n do
    
        # Specify the initial conditions for the kth DE, which involves p[k](phi).
        # The original initial conditions appear only in the coefficient functions with index k = 0,
        # and those for k > 1 are all zero.
        if k = 0 then
            ic3 := op( expand( eval[recurse]( [ ic2 ], [ u = U, epsilon = 0 ] ) ) );
        else
            ic3 := p[k](0), D(p[k])(0);
        end if:
    
        # Solve kth DE, which can be found from the coefficients of the powers of epsilon in de3, for p[k](phi).
        # Then, update de3 with the new information.
        soln := dsolve( { simplify( coeff( de3, epsilon, k ) ), ic3 } );
        p[k] := unapply( rhs( soln ), phi );
        de3 := eval( de3 );
    
        # Choose q[k] to eliminate secular terms. To do this, use the frontend() command to keep only the terms in p[k](phi)
        # which have powers of t, and then solve for the value of q[k] which makes the expression zero. 
        # Note that frontend() masks the t-dependence within the sine and cosine terms.
        # Note also that this method may need to be amended, based on the form of the terms in p[k](phi).
        if k > 0 then
            q[1] := solve( frontend( select, [ has, p[k](phi), phi ] ) = 0, q[1] );
            de3 := eval( de3 );
        end if;
    
    end do:
    
    # Final perturbation solution.
    'u(theta)' = eval( eval( U(phi), phi = B * theta ) ) + O( epsilon^(n+1) );
    
    # Angular precession in one revolution.
    sigma := convert( series( 2 * Pi * (1/B-1), epsilon = 0, n + 1 ), polynom ):
    epsilon := 3 * G * M / a / ( 1 - e^2 ) / c^2;
    'sigma' = sigma;
    
    # Precession per century.
    xi := simplify( eval( sigma * alpha * beta, P ) ); # returns approximately 42.98


    Maple Worksheet: Lindstedt-Poincare_Method.mw

    First 30 31 32 33 34 35 36 Last Page 32 of 297