acer

32348 Reputation

29 Badges

19 years, 330 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@janhardo Thank you, I already know all about the PlotBuilder.

The documented default grid option value for implicitplot is [26,26] in Maple 2020. So if you supply it as [25,25] then you are already forcing a coarser starting resolution than is the documented default. In addition, what Carl wrote above about implicitplot and grid is not the whole story. The implicitplot command uses the grid option's value as a starting grid, but by default it does several kinds of further refinement -- which affects the effective resolution. See the Help page.

I reiterate some of my previous Comment's remarks: there is no need to adjust the options unless the curve looks coarse or incomplete, and no set of options will make every curve look best.

ps. It might be just a language and understanding issue, but it seems to me that you are resistant to believing quite of bit of what I offer as advice and commentary. I think that perhaps it's best that I sign off here.

@janhardo There is little point in supplying additional options (gridrefine, etc)  to the implicitplot command in the case that the default option values make the curve appear smooth and complete.

There are no setting for the options which will make all possible curves look best.

I did not try all the nine or so examples in your question 7.

If things don't look ok then I usually start by throwing in gridrefine=2, and fiddle from there. It varies.

I'll note that the default behavior of implicitplot has improved, over the years. In Maple 16.02 (2013) the following example renders quite raggedly, though it can be improved with option gridrefine=2, say. But in Maple 2020.0 it looks quite smooth with defaults.
   plots:-implicitplot(x^2*y+x^3+x*y^3+y+1,x=-4..2,y=-4..5);
And your book was written for what, Maple 7 or Maple 8? I expect that quite a bit more fiddling with options might have been required in those old versions, for some of the nine examples.
 

@janhardo You wrote, "But this grid area is wherein the implicit curve must be plotted."

And that's what the attachment in my Answer does, for part i).  I had already adjusted it, to match [ -4,2]x[-4,5].

@Carl Love You've written that [-4, 2] X [-4, 5] means x= -4..4, y= -4..5. But I suspect you meant x= -4..2, y= -4..5.

@janhardo I've changed the range in the attachment in my Answer, to use the range x=-4..2 and y=-4..5 for part i).

I also showed that it's easier to get the intersections of the example's bivariate polynomials with the equation of the unit circle using the solve or RootFinding:-Isolate commands. See the updated attachment in the Answer.

@janhardo The attachment looks at 7 ii) and i).

If you want to use x=-4..2 and y=-4..5 instead in part 7 i)  then you can just edit the ranges.

You can edit any of it, as you choose or to investigate.

@mmcdara If I were to put the row labels on the right then I'd prefer to shade the right-most column differently instead of the left-most column. (I suspect that was just an oversight or a typo on your part.)

Also fun is making use of the color names, eg.,

restart;

S := Matrix([[0,9,8,0,7],[3,5,6,5,1],[1,0,0,3,2]]):
RowNames := Vector(3, ["small","medium","large"]):
ColNames := Vector[row](6, ["Rose","Teal","Plum","Sand","Peach",""]):

DocumentTools:-Tabulate(<ColNames,<S|RowNames>>,
      color=((T,i,j)->`if`(i=1 or j=6, "0000FF", "#000000")),
      fillcolor=((T,i,j)->`if`(i=1 or j=6, "HTML NavajoWhite", white)),
      widthmode=pixels, width=400):

 

 

Ctab := table(["Rose"="Spring Rose","Teal"="Teal","Plum"="Plum",
               "Sand"="Wheat","Peach"="Orange"]):
DocumentTools:-Tabulate(<ColNames,<S|RowNames>>,
  color=((T,i,j)->`if`(j=6, "0000FF",
                  `if`(i=1,
                       `if`(Luma(ColorTools:-Color(Ctab[ColNames[j]]))>0.5,
                            "000000","FFFFFF"), "000000"))),
      fillcolor=((T,i,j)->`if`(i=1 and j<6, Ctab[ColNames[j]], white)),
      widthmode=pixels, width=400):

 

 

 

Tab_fill.mw

@janhardo 

Your own document said, "suitable length".  As I read it, it was referring to the length of the actual line segment, and not the length of the x-ranges.

If you choose merely that the x-ranges have a common distance between lower and upper end-points then the line segments will have different lengths. If the curve has a very large slope then the line segment will be extremely long there. You won't be able to gracefully restrict the visible y-view in such a problematic situation, unless you hard-code it and make the solution less able to handle different examples well.

If you focus on a common length of the line segments, then it's easy to make them have a "suitable length". You would then need to compute the x-ranges, for each tangent line segment.

I just happened to scale by 1.5*(b-a)/n.  Of course, one could scale by (b-n)/(n-1) instead. That's not the primary matter.

What matters is that one would still need to use the slope to compute the x-ranges' end-points, for each tangent line segment. That's why I showed 1/sqrt(m[i]^2+1) .

It doesn't matter what common segment length might be chosen as the target. What might matter is that -- given a common target length -- one can compute the individual x-ranges such that the segments all have the same length. That involves adjusting using the individual slopes.

The aspect ratio due to the visible view alters it a little. But it can do reasonably well. tangentlines_length2.mw

It doesn't matter to me which you way you choose to go.

@janhardo I put a version into my previous comment.

I used 1/sqrt(m[i]^2+1) in computing the x-range's distance, where m[i] is the slope of the ith tangent line, and then further scaled by (b-a)/6.

I scaled further by a factor or 1.5, but you could use whatever you want. Yould could scale it down a little, instead, so that if all the tangents were horizontal then they wouldn't overlap.

The distance of the line segment is sqrt((y2-y1)^2+(x2-x1)^2) and the slope-line formula is m=(y2-y1)/(x2-x1). You can isolate for y2-y1 = m*(x2-x1) from the slope-line formula, and then substitute into the distance formula. That allows you to find an x-increment so that -- given a slope m -- the line segment length has a target value.

ps. It would also be possible to adjust the line segments' lengths so that they would visually appear to be of identical rendered length, given a supplied ratio of the visible view (rendered x- and y-ranges). I'd suggest that would make the topic too confusing and Maple-specific for students.

@janhardo In my opinion the tangent line segments would look better if their length was a fixed proportion of the distance from endpoint a to endpoint b.

That is not the same as the distance between the x-coordinates of the ends of the tangent line segments.

You already have the slope of the tangent line segments. The adjustment would be straightforward, given the slopes.

The idea is that even when the slope of the curve is very great the tangent line segments stay within a modest y-range.

Looking back through your inlined attachments, it seems as though for this particular exercise some "suitable length" is requested for the tangent line segments, in contrast with another exercise (inflection points?) for which the fixed x-ranges x[i]-1 .. x[i]+1 or similar were requested.

For example (and you could easily adjust this for a varying number of points),

restart;

Tangentlines:= proc(f, a::numeric , b::numeric):
local G, P, fprime, i, j, L, x, xaxis;
  G:=Array(1..6, 1..3):
  P:=Array(0..6, 1..2):
  fprime:=D(f);
  for i from 1 to 6 do
     G[i, 1]:=a + (i - 1)*(b/5 - a/5);# x-values interval
     G[i, 2]:=f(G[i, 1]);
     G[i, 3]:=G[i,2]+fprime(G[i,1])*(x-G[i,1]);
     L := 1.5 * (b-a)/(6*sqrt(fprime(G[i,1])^2+1));
     P[i, 1]:=plot(G[i,3], x=G[i, 1]-L/2..G[i, 1]+L/2,'thickness'=2):
     P[i, 2]:=plots:-pointplot([G[i,1],G[i,2]], 'symbol'='solidcircle',
                                 'symbolsize'=10, 'color'="blue", 'legend'="tangent points"):
 end do:
 P[0,1]:=plot(f(x),x=a..b,'color'="black"): # is f de functie
 xaxis:=[seq(G[i, 1], i=1..6)]; # x waarden
 plots:-display(P[0,1],
                seq(seq(P[i,j], i=1..6), j=1..2)
                ,'axis'[1]=['tickmarks'=xaxis],'color'="red",
                'size'=[800,400], 'scaling'='constrained');
end proc:

Tangentlines(x->x^sin(x),0.1,16);

 

Download tangentlines_length.mw

You wrote, "I set the function as "spline"."

What function? Is it an expression, a procedure, something returned by another command? Upload and attach a worksheet that recomputes it, so that we can see, or else explain it wih adequate details.

Presumably you have only some finite and limited number of data points, and have made a fit to those. Otherwise you would be better off dynamically computing the extrema from whatever originally produces the data.

Hopefully you realize that any extrema of an approximated fit of fixed sampling will be somewhat error prone, since the location will vary according to the fitting method and distribution of the sampled data points.

@janhardo Previously (earlier in this sheet, and in the procedure of previous worksheets) you had used the x-values +-0.8 or +-1.0 for plotting the tangent lines. (In one of your document's exercises a range of +-1 around the inflection points was proscribed, if I recall correctly.)

I've adjusted that to match the earlier use, and adjusted the local declarations.

The version using a range works. The version using two separate parameters for end-points works. Neither is objectively wrong. It's up to you to decide which you prefer.

betounes_ex_set_2_opg_6via_codeexample2.3_uitwerking2_ac.mw

@mmcdara Yes, I knew that. And not only did I know it, but I already stated it, above. I wrote that one could augment the Matrix and use DocumentTools:-Tabulate against it. That is in the second paragraph of my Answer, appearing before my description of an approach using DataFrames.

Now, if the user really does have only Maple 17 then neither Tabulate nor DataFrames are available. There is DocumentTools:-Layout:-Table but it is a crude early version and most of the rest of Layout is not yet present. I am waiting for a response from the OP, before I decide whether to make an effort to get just enough for a nice display.

@mwahab What makes you think that the eval command I showed did not actually do the substitution?

@janhardo Twice you wrote /*  */ but multi-line comments in Maple Notation are delimited by (* and *) rather than by /* and */.

First 174 175 176 177 178 179 180 Last Page 176 of 592