Maple 2018 Questions and Posts

These are Posts and Questions associated with the product, Maple 2018

This is probably a silly question, but...

given 

GST := AE+AI-ANB-AR-CP

how do i append [i] to each element of the list so I get

AE[i]+AI[i]-ANB[i]-AR[i]-CP[i]

this nearly gets it

(GST@`[]`)~(i);
 

I an unable to get a numerical result out of this triple integral.  Maple runs forever.  I stopped it after about half an hour:

Int(exp(-a^2-b^2-c^2),
    a=b^2/(4*c)..infinity, b=-infinity..infinity, c=0..infinity);
value(%);
evalf(%);

Is there a trick to make it work?

I am working on a project in dynamical system and I am to apply Pontryagins maximum principle of control. i have coded the control equations but it shows an error message "Error, (in dsolve/numeric/bvp/convertsys) too few boundary conditions: expected 7, got 6". What could be the possible problem?

Not sure why I need to invoke the simplify command here, shouldn't the immediate simplification occur?


                  

simplify(%)
                   

However, it does work algebraically


                 

                    

 

hi.

According to the fhgure attaceh how i can gain the equation (2-27) . I write the equation (2-26) in maple but I couldnot to gain that result.

If possible to reach equation via maple?

Thanks

diff.mw
 

restart

FC := (1/2)*W_m^2*(c1*x^2+c2*y^2)+(E.(h^2))*W_m^2*(sum(An*((sinh(n*Pi/lambda)+n*Pi*cosh(n*Pi/lambda)/lambda)*cosh(2*n*Pi*y/a)-2*n*Pi*y*sinh(n*Pi/lambda)*sinh(2*n*Pi*y/a)/a)*cos(2*n*Pi*x/a)/(n^2*(sinh(n*Pi/lambda)*cosh(n*Pi/lambda)+n*Pi/lambda))+Bn*((sinh(n*Pi*lambda)+n*Pi*lambda*cosh(n*Pi*lambda))*cosh(2*n*Pi*x/b)-2*n*Pi*x*sinh(n*Pi*lambda)*sinh(2*n*Pi*x/b)/b)*cos(2*n*Pi*y/b)/(lambda^2*n^2*(sinh(n*Pi*lambda)*cosh(n*Pi*lambda)+n*Pi*lambda)), n = 1 .. n))

Warning,  computation interrupted

 

S := diff(FC, x); SS := diff(S, x)

g := subs(x = (1/2)*a, SS)

0

(1)

coeff(g, sinh(n*Pi/lambda))

0

(2)

``


 

Download diff.mw

The procedure presented here does independence tests of a contingency table by four methods:

  1. Pearson's chi-squared (equivalent to Statistics:-ChiSquareIndependenceTest),
  2. Yates's continuity correction to Pearson's,
  3. G-chi-squared,
  4. Fisher's exact.

(All of these have Wikipedia pages. Links are given in the code below.) All computations are done in exact arithmetic. The coup de grace is Fisher's. The first three tests are relatively easy computations and give approximations to the p-value (the probability that the categories are independent), but Fisher's exact test, as its name says, computes it exactly. This requires the generation of all matrices of nonnegative integers that have the same row and column sums as the input matrix, and for each of these matrices computing the product of the factorials of its entries. So, there are relatively few implementations of it, and perhaps none that do it exactly. (Could some with access check Mathematica please?)

Our own Joe Riel's amazing and fast Iterator package makes this computation considerably easier and faster than it otherwise would've been, and I also found inspiration in his example of recursively counting contingency tables found at ?Iterator,BoundedComposition

ContingencyTableTests:= proc(
   O::Matrix(nonnegint), #contingency table of observed counts 
   {method::identical(Pearson, Yates, G, Fisher):= 'Pearson'}
)
description 
   "Returns p-value for Pearson's (w/ or w/o Yates's continuity correction)" 
   " or G chi-squared or Fisher's exact test."
   " All computations are done in exact arithmetic."
;
option
   author= "Carl Love <carl.j.love@gmail.com>, 27-Oct-2018",
   references= (                                                           #Ref #s:
      "https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test",         #*1
      "https://en.wikipedia.org/wiki/Yates%27s_correction_for_continuity",  #*2
      "https://en.wikipedia.org/wiki/G-test",                               #*3
      "https://en.wikipedia.org/wiki/Fisher%27s_exact_test",                #*4
      "Eric W Weisstein \"Fisher's Exact Test\" _MathWorld_--A Wolfram web resource:"
      " http://mathworld.wolfram.com/FishersExactTest.html"                 #*5
   )
;
uses AT= ArrayTools, St= Statistics, It= Iterator;
local
   #column & row sums: 
   C:= AT:-AddAlongDimension(O,1), R:= AT:-AddAlongDimension(O,2),
   r:= numelems(R), c:= numelems(C), #counts of rows & columns
   n:= add(R), #number of observations
   #matrix of expected values under null hypothesis (independence):
   #(A 0 entry would mean a 0 row or column in the original, which is not allowed.)
   E:= Matrix((r,c), (i,j)-> R[i]*C[j], datatype= 'positive') / n,
   #Pearson's, Yates's, and G all use a chi-sq statistic, each computed by 
   #slightly different formulae.
   Chi2:= add@~table([
       'Pearson'= (O-> (O-E)^~2 /~ E),                     #see *1
       'Yates'= (O-> (abs~(O - E) -~ 1/2)^~2 /~ E),        #see *2
       'G'= (O-> 2*O*~map(x-> `if`(x=0, 0, ln(x)), O/~E))  #see *3
   ]), 
   row, #alternative rows generated for Fisher's
   Cutoff:= mul(O!~), #cut-off value for less likely matrices
   #Generate recursively all contingency tables whose row and column sums match O.
   #Compute their probabilities under independence. Sum probabilities of all those
   #at most as probable as O. (see *5, *4)
   #Parameters: 
   #   C = column sums remaining to be filled; 
   #   F = product of factorials of entries of contingency table being built;
   #   i = row to be chosen this iteration
   AllCTs:= (C, F, i)->
      if i = r then #Recursion ends; last row is C, the unused portion of column sums. 
         (P-> `if`(P >= Cutoff, 1/P, 0))(F*mul(C!~))
      else
         add(
            thisproc(C - row[], F*mul(row[]!~), i+1), 
            row= It:-BoundedComposition(C, R[i])
         )
      fi      
;
   userinfo(1, ContingencyTableTests, "Table of expected values:", print(E));
   if method = 'Fisher' then AllCTs(C, 1, 1)*mul(R!~)*mul(C!~)/n!
   else 1 - St:-CDF(ChiSquare((r-1)*(c-1)), Chi2[method](O)) 
   fi   
end proc:

The worksheet below contains the code above and one problem solved by the 4 methods


 

 

DrugTrial:= <
   20, 11, 19;
   4,  4,  17
>:

infolevel[ContingencyTableTests]:= 1:

ContingencyTableTests(DrugTrial, method= Pearson):  % = evalf(%);

ContingencyTableTests: Table of expected values:

Matrix(2, 3, {(1, 1) = 16, (1, 2) = 10, (1, 3) = 24, (2, 1) = 8, (2, 2) = 5, (2, 3) = 12})

exp(-257/80) = 0.4025584775e-1

#Compare with:
Statistics:-ChiSquareIndependenceTest(DrugTrial);

hypothesis = false, criticalvalue = HFloat(5.991464547107979), distribution = ChiSquare(2), pvalue = HFloat(0.04025584774823787), statistic = 6.425000000

infolevel[ContingencyTableTests]:= 0:
ContingencyTableTests(DrugTrial, method= Yates):  % = evalf(%);

exp(-1569/640) = 0.8615885805e-1

ContingencyTableTests(DrugTrial, method= G):  % = evalf(%);

exp(-20*ln(5/4)+4*ln(2)-11*ln(11/10)-4*ln(4/5)-19*ln(19/24)-17*ln(17/12)) = 0.3584139703e-1

CodeTools:-Usage(ContingencyTableTests(DrugTrial, method= Fisher)):  % = evalf(%);

memory used=0.82MiB, alloc change=0 bytes, cpu time=0ns, real time=5.00ms, gc time=0ns

747139720973921/15707451356376611 = 0.4756594205e-1

 


 

Download FishersExact.mw

Here's a slightly reduced form of a little module from some code that I posted recently:

KandR:= module()
local
   a, b, c, e, #parameters

   #procedure that lets user set parameter values:
   ModuleApply:= proc({
       a::algebraic:= KandR:-a, b::algebraic:= KandR:-b, 
       c::algebraic:= KandR:-c, e::algebraic:= KandR:-e
   })
   local k;
      for k to _noptions do thismodule[lhs(_options[k])]:= rhs(_options[k]) od;
      return
   end proc
;
end module:

The purpose of the module is simply to be a container for the four parameters and to provide a simple ModuleApply interface by which they can be set, reset, and/or unset. 

I very often use a procedure parameter of a ModuleApply to set a local variable of same name in the module. Because of the name conflict, thismodule needs to be used in these situations. I see this as the primary use of thismodule. In the module above, the purpose of the line 

for k to _noptions do thismodule[lhs(_options[k])]:= rhs(_options[k]) od;

is to avoid the need to explictly use the parameters yet a third time. First off, I am amazed that this works! I've had many disappointments with thismodule (which is essentially undocumented---its miniscule help page is nearly worthless). I am using Maple 2018, release 1. Another Maple 2018 user (not sure which release) reports that the above line gives an error (when executed) that thismodule's index must be a name.

Question 1: What's up with that?

[Edit: It's been determined that the problem was due to an unfortunate global assignment in that user's initialization file rather than different behavior of thismodule. So, I consider Question 1 to be completely answered, and it should be ignored.]

Question 2: The for loop is not entirely satisfying to me. Is there a better way?

[Status: Answered, see below.]

Question 3: Ideally, I'd like to explicity use the four parameters once, not two or three times. Is there a way? If I need to use a container for the parameters (such as a Record), to achieve that, I'd be happy to do that, and I wouldn't mind needing to invoke that container's name any number of times.

[Status: Answered, see below.]

Note that op and exports can be applied to thismodule to extract the module's operands. I have found this occasionally useful.

Question 4: What are some other good uses for thismodule? The one and only example given on its help page seems ridiculous to me.

The docs say that you can assign initial values to a record as shown in this screenshot:

I would expect the last two lines of output to be 1, 2. The slighly more complicated example in the docs does not work as expected either. This is the worksheet: queery.mw

I can assign to a record subsequently, but that makes for very prolix code,

Thanks for any help.

Hello,

I am trying to get Maple to recognize and reverse the product rule in more than one dimension. In one dimension, this works:

Int((Diff(f(x), x))*g(x)+(Diff(g(x), x))*f(x), x) = int((diff(f(x), x))*g(x)+f(x)*(diff(g(x), x)), x);

Int((Diff(f(x), x))*g(x)+(Diff(g(x), x))*f(x), x) = int((diff(f(x), x))*g(x)+f(x)*(diff(g(x), x)), x).

But in two dimensions, it no longer evaluates:

Int((Diff(f(x, y), x))*g(x, y)+(Diff(g(x, y), x))*f(x, y), x) = int((diff(f(x, y), x))*g(x, y)+f(x, y)*(diff(g(x, y), x)), x)

Int((Diff(f(x, y), x))*g(x, y)+(Diff(g(x, y), x))*f(x, y), x) = int((diff(f(x, y), x))*g(x, y)+f(x, y)*(diff(g(x, y), x)), x)

As far as I can tell, mathematically these should be identical (except for the antiderivatives being defined up to a constant in the first case and a function of y in the second). Is there a way to get Maple to reverse the product rule to integrate in more than one dimension? Or am I missing something mathematically that makes this incorrect?

Thanks for your help,

Johnathan

I have asked this before but am still confused. I have a half-dozen procedures I want to save. Don't want them in a module/package. I am using windows 10.

I just can't get the syntax correct on this.

Obviously after saving restart and load to test.

libname;
       "C:\Program Files\Maple 2018\lib", 

         "C:\Users\Ronan\maple\toolbox\CodeBuilder\lib", 

         "C:\Users\Ronan\maple\toolbox\OEIS\lib", 

         "C:\Users\Ronan\maple\toolbox\personal\lib", 

         "C:\Users\Ronan\maple\toolbox\UTF8\lib"
libdir := "C:/Users/Ronan/maple/toolbox/personal/lib";
     libdir := "C:/Users/Ronan/maple/toolbox/personal/lib"
NULL;

LibraryTools:-Save(Pedal, cat(kernelopts(homedir), "/maple/toolbox/personal/lib/Pedal.mpl"));
Error, (in LibraryTools:-Save) could not open `C:\Users\Ronan/maple/toolbox/personal/lib/Pedal.mpl\Pedal.m` for writing

 


I trying to get a proc to work. In the 1st half of the document, I derive four sections for a pedal curve and plot them fine. In the second I try doing it with a procedure called Pedal. Am having problems. I think it might be something to do with the for.. do loop. 

restart

NULLNULL

Typesetting:-mrow(Typesetting:-mi("Trunc", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo("&coloneq;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("proc", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("F", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo("&Proportion;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("procedure", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo(",", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("`+`", italic = "true", font_style_name = "2D Input", mathvariant = "italic")), font_style_name = "2D Input", mathvariant = "normal", open = "{", close = "}"), Typesetting:-mo(",", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("odr", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo("&Proportion;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("posint", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo("&coloneq;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mn("2", font_style_name = "2D Input", mathvariant = "normal"), Typesetting:-mo(",", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("v", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo("&Proportion;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("list", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("name", italic = "true", font_style_name = "2D Input", mathvariant = "italic")), font_style_name = "2D Input", mathvariant = "normal"), Typesetting:-mo("&coloneq;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("x", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo(",", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mi("y", italic = "true", font_style_name = "2D Input", mathvariant = "italic")), font_style_name = "2D Input", mathvariant = "normal", open = "[", close = "]")), font_style_name = "2D Input", mathvariant = "normal"), Typesetting:-mi(""), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("description", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-ms(" Truncates an algebraic equation to required degree"), Typesetting:-mo(";", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo("local", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("f", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo("&coloneq;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("`if`", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("F", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo("&Proportion;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("procedure", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo(",", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("F", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("v", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("")), font_style_name = "2D Input", mathvariant = "normal", open = "[", close = "]")), font_style_name = "2D Input", mathvariant = "normal"), Typesetting:-mo(",", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("F", italic = "true", font_style_name = "2D Input", mathvariant = "italic")), font_style_name = "2D Input", mathvariant = "normal"), Typesetting:-mo(";", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mi("print", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("F", italic = "true", font_style_name = "2D Input", mathvariant = "italic")), font_style_name = "2D Input", mathvariant = "normal"), Typesetting:-mo(";", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("if", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("not", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("f", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo("&Proportion;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("`+`", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("then", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("error", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-ms("Can't truncate 1-term expression"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("else", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("select", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("q", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo("&srarr;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("degree", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("q", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo(",", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mi("v", italic = "true", font_style_name = "2D Input", mathvariant = "italic")), font_style_name = "2D Input", mathvariant = "normal"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("&leq;", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("odr", italic = "true", font_style_name = "2D Input", mathvariant = "italic"), Typesetting:-mo(",", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("f", italic = "true", font_style_name = "2D Input", mathvariant = "italic")), font_style_name = "2D Input", mathvariant = "normal"), Typesetting:-mi(""), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("fi", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("end", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("proc", bold = "true", font_style_name = "2D Input", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(":", font_style_name = "2D Input", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"))

NULLNULLNULL

NULL

a := 3; b := -1; c := -1

C := (x^2+y^2+12*x+9)^2-4*(2*x+3)^3

(x^2+y^2+12*x+9)^2-4*(2*x+3)^3

(1)

p21 := plots:-implicitplot(C, x = -3 .. 3, y = -5 .. 5, colour = "Salmon", gridrefine = 2, size = [300, 300])

 

sol1 := [solve(C, y)]

[(-x^2-12*x-9+2*(8*x^3+36*x^2+54*x+27)^(1/2))^(1/2), -(-x^2-12*x-9+2*(8*x^3+36*x^2+54*x+27)^(1/2))^(1/2), (-x^2-12*x-9-2*(8*x^3+36*x^2+54*x+27)^(1/2))^(1/2), -(-x^2-12*x-9-2*(8*x^3+36*x^2+54*x+27)^(1/2))^(1/2)]

(2)

NULL

f1 := expand(eval(C, [x = X+r, y = Y+s]))

X^4+4*X^3*r+2*X^2*Y^2+4*X^2*Y*s+6*X^2*r^2+2*X^2*s^2+4*X*Y^2*r+8*X*Y*r*s+4*X*r^3+4*X*r*s^2+Y^4+4*Y^3*s+2*Y^2*r^2+6*Y^2*s^2+4*Y*r^2*s+4*Y*s^3+r^4+2*r^2*s^2+s^4-8*X^3-24*X^2*r+24*X*Y^2+48*X*Y*s-24*X*r^2+24*X*s^2+24*Y^2*r+48*Y*r*s-8*r^3+24*r*s^2+18*X^2+36*X*r+18*Y^2+36*Y*s+18*r^2+18*s^2-27

(3)

ltg1 := simplify(expand(eval(Trunc(f1, 1, [Y, X]), [X = x-r, Y = y-s])))

-3*r^4+(4*x+16)*r^3+(-6*s^2+4*s*y-24*x-18)*r^2+((4*x-48)*s^2+48*s*y+36*x)*r-27-3*s^4+4*s^3*y+(24*x-18)*s^2+36*s*y

(4)

NULLThis*section*works*out*the*pedal*curve

This*section*works*out*the*pedal*curve

(5)

xp1 := 1; yp1 := 2; lprp1 := -coeff(ltg1, y)*x+coeff(ltg1, x)*y+K1; for i to nops(sol1) do s := eval(sol1[i], x = r); print("s  ", s); K1 := solve(eval(lprp1, [x = xp1, y = yp1]), K1); print("K1  ", K1); sol2 := solve([ltg1, lprp1], [x, y]); Pedal || i := [rhs(sol2[1, 1]), rhs(sol2[1, 2])]; p9 || i := plot([op(Pedal || i), r = -20 .. 20], colour = "MediumSeaGreen"); unassign('K1', 'sol2') end do

"K1  ", -4*(-r^2-12*r-9-2*(8*r^3+36*r^2+54*r+27)^(1/2))^(3/2)-4*r^2*(-r^2-12*r-9-2*(8*r^3+36*r^2+54*r+27)^(1/2))^(1/2)+16*(8*r^3+36*r^2+54*r+27)^(1/2)*r-48*r*(-r^2-12*r-9-2*(8*r^3+36*r^2+54*r+27)^(1/2))^(1/2)+192*r^2+96*(8*r^3+36*r^2+54*r+27)^(1/2)-36*(-r^2-12*r-9-2*(8*r^3+36*r^2+54*r+27)^(1/2))^(1/2)+576*r+432

(6)

seq(simplify(Pedal || i), i = 1 .. nops(sol1))

[((((2*r+3)^3)^(1/2)+6*r+9)*(-r^2-12*r-9+2*((2*r+3)^3)^(1/2))^(1/2)-2*(r-3)*(r^2+(5/2)*r-((2*r+3)^3)^(1/2)+3/2))/(4*r^2-6*r-18), ((-2*r^2-3*r-((2*r+3)^3)^(1/2))*(-r^2-12*r-9+2*((2*r+3)^3)^(1/2))^(1/2)+6*(r-3)*(r-(1/6)*((2*r+3)^3)^(1/2)+3/2))/(4*r^2-6*r-18)], [((-((2*r+3)^3)^(1/2)-6*r-9)*(-r^2-12*r-9+2*((2*r+3)^3)^(1/2))^(1/2)-2*(r-3)*(r^2+(5/2)*r-((2*r+3)^3)^(1/2)+3/2))/(4*r^2-6*r-18), ((2*r^2+((2*r+3)^3)^(1/2)+3*r)*(-r^2-12*r-9+2*((2*r+3)^3)^(1/2))^(1/2)+6*(r-3)*(r-(1/6)*((2*r+3)^3)^(1/2)+3/2))/(4*r^2-6*r-18)], [((6*r-((2*r+3)^3)^(1/2)+9)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)-2*(r-3)*(r^2+(5/2)*r+((2*r+3)^3)^(1/2)+3/2))/(4*r^2-6*r-18), ((-2*r^2+((2*r+3)^3)^(1/2)-3*r)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+6*(r-3)*(r+(1/6)*((2*r+3)^3)^(1/2)+3/2))/(4*r^2-6*r-18)], [((((2*r+3)^3)^(1/2)-6*r-9)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)-2*(r-3)*(r^2+(5/2)*r+((2*r+3)^3)^(1/2)+3/2))/(4*r^2-6*r-18), ((2*r^2-((2*r+3)^3)^(1/2)+3*r)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+6*(r-3)*(r+(1/6)*((2*r+3)^3)^(1/2)+3/2))/(4*r^2-6*r-18)]

(7)

plots:-display(p21, seq(p9 || i, i = 1 .. nops(sol1)), size = [600, 600], scaling = constrained, caption = " Curve and it's Pedal curve")

 

This I can't get to work. All 4 sections of the pedal curve are the same and should not be.

Parse:-ConvertTo1D, "`%1` is not a module or member", RonanRoutines

Pedal2 := Pedal(C, xp1, yp1)

"K||i", -8*r^3+(-4*(-r^2-12*r-9-2*(8*r^3+36*r^2+54*r+27)^(1/2))^(1/2)+48)*r^2-8*(-(-r^2-12*r-9-2*(8*r^3+36*r^2+54*r+27)^(1/2))^(1/2)-3)^2*r-4*(-r^2-12*r-9-2*(8*r^3+36*r^2+54*r+27)^(1/2))^(3/2)+48*r^2+576*r+432+96*(8*r^3+36*r^2+54*r+27)^(1/2)-36*(-r^2-12*r-9-2*(8*r^3+36*r^2+54*r+27)^(1/2))^(1/2)

(8)

seq(simplify(Pedal2[i]), i = 1 .. nops(sol1))

[((4*r^2+6*((2*r+3)^3)^(1/2)+30*r+36)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+(-r^2-34*r-69)*((2*r+3)^3)^(1/2)-26*r^3-243*r^2-540*r-351)/((2*r+30)*((2*r+3)^3)^(1/2)+36*r^2+162*r+162), (((r+9)*((2*r+3)^3)^(1/2)+14*r^2+51*r+45)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+(12*r+72)*((2*r+3)^3)^(1/2)+4*r^3+126*r^2+432*r+378)/((2*r+30)*((2*r+3)^3)^(1/2)+36*r^2+162*r+162)], [((4*r^2+6*((2*r+3)^3)^(1/2)+30*r+36)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+(-r^2-34*r-69)*((2*r+3)^3)^(1/2)-26*r^3-243*r^2-540*r-351)/((2*r+30)*((2*r+3)^3)^(1/2)+36*r^2+162*r+162), (((r+9)*((2*r+3)^3)^(1/2)+14*r^2+51*r+45)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+(12*r+72)*((2*r+3)^3)^(1/2)+4*r^3+126*r^2+432*r+378)/((2*r+30)*((2*r+3)^3)^(1/2)+36*r^2+162*r+162)], [((4*r^2+6*((2*r+3)^3)^(1/2)+30*r+36)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+(-r^2-34*r-69)*((2*r+3)^3)^(1/2)-26*r^3-243*r^2-540*r-351)/((2*r+30)*((2*r+3)^3)^(1/2)+36*r^2+162*r+162), (((r+9)*((2*r+3)^3)^(1/2)+14*r^2+51*r+45)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+(12*r+72)*((2*r+3)^3)^(1/2)+4*r^3+126*r^2+432*r+378)/((2*r+30)*((2*r+3)^3)^(1/2)+36*r^2+162*r+162)], [((4*r^2+6*((2*r+3)^3)^(1/2)+30*r+36)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+(-r^2-34*r-69)*((2*r+3)^3)^(1/2)-26*r^3-243*r^2-540*r-351)/((2*r+30)*((2*r+3)^3)^(1/2)+36*r^2+162*r+162), (((r+9)*((2*r+3)^3)^(1/2)+14*r^2+51*r+45)*(-r^2-2*((2*r+3)^3)^(1/2)-12*r-9)^(1/2)+(12*r+72)*((2*r+3)^3)^(1/2)+4*r^3+126*r^2+432*r+378)/((2*r+30)*((2*r+3)^3)^(1/2)+36*r^2+162*r+162)]

(9)

for i to nops(sol1) do p9 || i := plot([op(Pedal2[i]), r = -20 .. 20], colour = "MediumSeaGreen") end do

 

``

NULL

NULL

``


 

Download Proc_for_Pedal_not_working.mw

Hi

I am trying to evaluate a function that contains an infinite sum. I need to evaluate the integral to determine a CDF, and from that hopefully the inverse CDF in order to sample the corresponding PDF.

The sum comes from a 2F1 hypergeometric function, which I have written manually in the attached file.

Can anyone tell me if and how it is possible to evaluate this integral, with respect to x?

I have inserted an image below, but also the entire file :) Marginal2.mw

Thanks in advance.

 

Maple 2018 starts but block and hangs after the first imput.

Even after a clean install on a clean disk where there are no old files of maple.

My specs are: WIN10 pr 64/ I7 /16 GB/ SSD

Who has the same problem and a sollution?

The attached worksheet shows how to evaluate and graphically analyze an autonomous first-order nonlinear recurrence with two dependent variables and multiple symbolic parameters. 

This worksheet shows how a small module that simply encapsulates the given information of a problem combined with some use statements can greatly facilitate the organization of one's work, can encapsulate the setting of parameter values, and can allow one to work with symbolic parameters.

Edit: In the first version of this Post, I forgot to include the qualifier "autonomous".  The system being autonomous substantially simplifies its treatment.
 

Autonomous first-order nonlinear recurrences with parameters and multiple dependent variables

Author: Carl Love <carl.j.love@gmail.com> 20-Oct-2018

 

The techniques used in this worksheet can be applied to most autonomous first-order nonlinear recurrences with multiple dependent variables and parameters.

 

This worksheet shows how a small module that simply encapsulates the given information of a problem combined with some use statements

• 

can greatly facilitate the organization of one's work,

• 

can encapsulate the setting of parameter values,

• 

can allow one to work with symbolic parameters.

 

A Problem from MaplePrimes: A discrete Lottka-Volterra population model is applied to an isolated island with a population of predators (foxes), R, and prey (rabbits), K. [Note that R is the foxes, not the rabbits! Perhaps this problem statement originated in another language.] The change over one time period is given by

K[n+1]:= K[n]*(-b*R[n]+a+1);  R[n+1]:= R[n]*(b*e*K[n]-c+1),

where a, b, c, e are parameters of the model. In this problem we will use a= 0.15, b= 0.01, c= 0.02, e= 0.01, when numeric values are needed.

 

a) Show that there exists an equilibrium (values of K[n] and R[n] such that K[n+1] = K[n] and R[n+1] = R[n]).

 

b) Write Maple code that solves the recurrence numerically. Assume that if any population is less than 0.5 then it has gone extinct and set the value to 0. Check that your program is idempotent at the equilibrium.

 

restart:

We begin by collecting all the given information (except for specific numeric values) into a module. The ModuleApply lets the user set the numeric values later.

 

For all two-element vectors used in this worksheet, K is the first value and R is the second value.

KandR:= module()
local
   a, b, c, e, #parameters

   #procedure that lets user set parameter values:
   ModuleApply:= proc({
       a::algebraic:= KandR:-a, b::algebraic:= KandR:-b,
       c::algebraic:= KandR:-c, e::algebraic:= KandR:-e
   })
   local k;
      for k to _noptions do thismodule[lhs(_options[k])]:= rhs(_options[k]) od;
      return
   end proc,

   Extinct:= (x::realcons)-> `if`(x < 0.5, 0, x) #force small, insignificant values to 0
;
export
   #Procedure that does one symbolic iteration
   #(Note that this procedure uses Vector input and output.)
   iter_symb:= KR-> KR *~ <-b*KR[2]+a+1, b*e*KR[1]-c+1>, 

   #Such simple treatment as above is only possible for autonomous
   #recurrences.

  
   iter_num:= Extinct~@iter_symb #one numeric iteration
;
end module:

#The following expression is the discrete equivalent of the derivative (or gradient).
#It represents the change over one time period.
P:= <K,R>:  
OneStep:= KandR:-iter_symb(P) - P

Vector(2, {(1) = K*(-R*b+a+1)-K, (2) = R*(K*b*e-c+1)-R})

#An equilibrium occurs when the gradient is 0.
Eq:= <K__e, R__e>:
Eqs:= solve({seq(eval(OneStep=~ 0, [seq(P=~ Eq)]))}, [seq(Eq)]);

[[K__e = 0, R__e = 0], [K__e = c/(b*e), R__e = a/b]]

#We're only interested here in nonzero solutions.
EqSol:= remove(S-> 0 in rhs~(S), Eqs)[];

[K__e = c/(b*e), R__e = a/b]

#Set parameters:
KandR(a= 0.15, b= 0.01, c= 0.02, e= 0.01);

#Show idempotency at equilibrium:
use KandR in Eq0:= eval(Eq, EqSol); print(Eq0 = iter_num(Eq0)) end use:

(Vector(2, {(1) = 200.0000000, (2) = 15.00000000})) = (Vector(2, {(1) = 200.0000000, (2) = 15.00000000}))

#procedure that fills a Matrix with computed values of a 1st-order recurrence.
#(A more-efficient method than this can be used for linear recurrences.)
#This procedure has no dependence on the module.
Iterate:= proc(n::nonnegint, iter, init::Vector[column])
local M:= Matrix((n+1, numelems(init)), init^+, datatype= hfloat), i;
   for i to n do M[i+1,..]:= iter(M[i,..]) od;
   M
end proc:

We want to see what happens if the initial conditions deviate slightly from the equilibrium. It turns out that any deviation (as long as the
initial values are still nonnegative!) will cause the same effect. I simply chose the deviation <7,2> because it was the smallest for which

the plot clearly showed what happens using the scale that I wanted to show the plot at. By using a finer scale, it is possible to see the

"outward spiral" efffect from even the tiniest deviation.

dev:= <7,2>:
use KandR in KR:= Iterate(1000, iter_num, Eq0 + dev) end use:

plot(
   [
       KR, #trajectory of population
       KR[[1,1],..], #1st point
       KR[-[1,1],..], #last point,
       <Eq0|Eq0>^+, #equilibrium
       #every 100th point (helps show time scale):
       KR[100*[$1..iquo(numelems(KR[..,1]), 100)-1], ..]
   ],
   #This group of options are all lists, each element of which corresponds
   #to one of the above components of the plot:
   style= [line, point$4],
   symbol= [solidcircle$4, soliddiamond],
   symbolsize= [18$4, 12],
   color= [black, green, red, brown, blue],
   thickness= [0$5],
   legend= [`pop.`, init, final, equilibrium, `100 periods`],

   #This group of options are lists, each element of which corresponds to one
   #coordinate axis (horizontal, then vertical).
   view= [0..max(KR[..,1]), 0..max(KR(..,2))],
   labels= [rabbits, foxes],
   labeldirections= [horizontal,vertical],
   size= [700,700], #measured in pixels

   #options applied to whole plot:
   labelfont= [TIMES, BOLDITALIC, 14],
   title= "Population of foxes and rabbits over time" "\n", titlefont= [TIMES,16],
   caption=
      "\n" "Choosing an initial point near the equilibrium causes"
      "\n" "outward spiraling divergence." "\n",
   gridlines= false
);
 

A fieldplot helps show what happens for any starting values. An arrow is drawn from each of a 2-D grid of point. The magnitude and direction of the arrow show the gradient (as a vector) in this case.

plots:-fieldplot(
   rtable_eval(OneStep),
   K= 0..max(KR[..,1]),  R= 0..max(KR[..,2]), grid= [16,16],

   #arrow-specific options:
   anchor= tail, fieldstrength= log, arrows= slim, color= "DarkGreen",

   #other options (same as any 2D plot):
   labels= [rabbits, foxes], labeldirections= [horizontal,vertical],
   labelfont= [TIMES, BOLDITALIC, 14],
   title= "One-step population changes from any point" "\n", titlefont= [TIMES,16],
   caption= "\n" "All trajectories spiral outward from the equilibrium." "\n",
   size= [700,700],
   gridlines= false
);

The above plot is computed only from the symbolic discrete gradient expression OneStep; it does not use the computed population values from the first plot. It only uses the maxima of those computed values to determine the length of the axes.

 

Conclusion: While this is interesting stuff mathematically, and makes for great plots, divergence from the equilibrium doesn't seem realistic to me.

 


 

Download FoxesAndRabbits.mw

I have a solution to a linear ODE which is very long and complicated.  The solition clearly has some parts which are repeated and so it would would be easiest to express those repeated parts as something simpler.

 

For example, suppose I had

 

x = (-b + sqrt(b^2 - 4*a*c) ) /2*a

 

What is the command to take x and do someting like

 

Z = sqrt(b^2 - 4*a*c)

 

x = (-b + Z)/2*a

 

 

 

 

First 42 43 44 45 46 47 48 Last Page 44 of 62