PatrickT

Dr. Patrick T

2153 Reputation

18 Badges

16 years, 142 days

MaplePrimes Activity


These are answers submitted by PatrickT

It's hard to see from image (if you copy-paste your input in Maple's 1D format, it will be easy for others to copy-paste into their worksheet and see what's going on), but you've got dots, e.g. a dot between b and y, is that the dot product for vectors, a multiplication operation for scalars, etc.? if the latter, if you're using a 1D worksheet, try replacing it with a star *. Can you tell us: Are you using document/worksheet, 1D/2D, etc.?

in this example, you can solve analytically, in which case Maple returns the two roots.

solve(sqrt(x^2+4*x-3) = -1+2*x, x);
solve(sqrt(x^2+4*x-3) = -1+2*x, x,AllSolutions); # if not all solutions had been returned by default, they should be now

For numerical solutions, there does not seem to be a direct equivalent of the option AllSolutions (correct me if I'm wrong). There is an intriguing tool of the package RootFinding, namely NextZero, which should be made to work here, but we would really need

RootFinding:-PreviousZero(f,%);
Error, PreviousZero is not a command in the RootFinding package

but I didn't see anything like that in the help page (did I miss it?)

In your case, RootFinding:-NextZero(f,%); doesn't work out of the box (does it?)

# Any of these should work, note that I re-wrote your equation slightly:
f := proc(x) sqrt(x^2+4*x-3)+1-2*x end proc:
f := x -> sqrt(x^2+4*x-3)+1-2*x:
f := unapply( sqrt(x^2+4*x-3)+1-2*x, x):

# NextZero works if you start from the small rool 2/3, but it doesn't (?!) work if you start from 2...
fsolve(f(x), x, avoid = {x = 2.00000000});
RootFinding:-NextZero(f,%);
fsolve(f(x), x);
RootFinding:-NextZero(f,%);

                          0.6666666667
                          2.000000000
                          2.000000000
                              FAIL


This, from the Help page was useful to know:

"The capabilities of NextZero are limited to finding zeros (and singularities) for functions that have local Laurent expansions, and as such it is unable to find zeros for pathological functions, such as exp(-1/x^2), and in fact for this example it may not even terminate."

Reference:

http://www.mapleprimes.com/questions/101310-How-To-Get-All-Solutions-Of-An-Equation#comment101315

Does this recent answer given by acer help?

http://www.mapleprimes.com/questions/129011-Why-Does-A-Minor-Change-In-A-Parameter#comment129014

@Markiyan Hirnyk 

In my experience (French high school), N stands for the natural numbers while N* stands for N\{0}, that's N without the zero element. That would be my guess here.

so if my interpretation is correct, the last line of Preben's code would be select(type,%,[posint,integer]);

you are looking at an implicit boundary value problem with an unassigned parameter, that is a system that is implicit rather than explicit in the derivative.

Note that you could solve the equation for diff(y(x),x) by squaring and solving the resulting quadratic; this would give you an explicit ode in the format diff(y(x),x) = the solution (there are typically 2 solutions here for a quadratic equation)

You have specified your conditions as y(x1)=y1 and y(x2)=y2, which makes the problem a bvp, but perhaps you can figure out an alternative set of conditions of the form y(0)=y0 and y'(0)=yx0, which would make it an ivp.

In addition, you have a non-numeric parameter a in the equation; you need to either assign it a value or treat it formally as a parameter by declaring it as such (see the help files on that).

The usual format is:

ode := x*(diff(y(x), x))/sqrt(1+(diff(y(x), x))^2) = a; # this is an IMPLICIT ODE
ode := subs(a=1,ode); # assign a value to the parameter
ics := y(1) = 2, y(2) = 1; # this makes it a BVP
dsolve({ics, ode}, 'type' = numeric);

This should take you a bit closer to a solution. Post back if you get stuck.

@lzhao 

I haven't noticed any major difference between Maple 14 and Maple 15, as far as my limited use is concerned. Maple 15 has been advertised as a major release, and I'm sure that's true, but I would not have noticed, both work well for me (and both suffer from the same 3D plotting limitations). So if your installation of v.14 is working properly while v.15 is not, then you should stick with what works! In fact, I often use the classic GUI, which has not been developed since, I think, Maple 12 or maybe earlier.  You can actually keep both versions alongside, installed in separate folders. Many Maple experts at mapleprimes do that, because it allows them to discover when a particular bug or feature appeared or disappeared.

plot(x,x=-1..1, tickmarks = [8,10]);

produces what you describe, on Maple 15 Worksheet Standard GUI, Windows.

In my experience, this method does not always work, so if you experience problems do post back with the specific example you need to tweak.

dsolve([sys_ode]);

 

where [...] denotes a list, is the correct syntax,

 

as far as I can see, your code is incomplete.

There is no reference to rand() in the code I see.

I tried to edit your post, to clean it up a bit, but mapleprimes experienced server problems, so I couldn't.

Here is the part of the code I can read:

camp23Dp := proc(X,Y,r,tx,ty,tz,a,b,c,d) 

description "obtain the points in 3D in the camera reference from the pixel position of the camera plane";

Vector([(b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*r[1]*d+r[4]*f*b*tx+a*r[2]*f*tx-r[2]*f*r[4]*d
+r[2]*r[7]*Y*d-r[8]*X*r[4]*d-a*r[8]*Y*tx+r[1]*b*tz*Y+r[7]*X*b*tx
-r[4]*b*tz*X-r[5]*r[7]*X*d+r[8]*Y*r[1]*d-a*r[2]*tz*Y-r[7]*Y*b*tx
+a*r[8]*X*tx-a*r[5]*f*tx+a*r[5]*tz*X)/(a*r[8]*Y*r[3]+r[2]*f*r[4]*c
+r[1]*b*r[9]*Y-r[7]*X*b*r[6]-r[8]*Y*r[1]*c-r[5]*f*r[1]*c-r[4]*b*r[9]*X
+r[7]*Y*b*r[3]-r[4]*f*b*r[3]-a*r[8]*X*r[6]+a*r[5]*r[9]*X-a*r[2]*r[9]*Y
-a*r[2]*f*r[6]-r[2]*r[7]*Y*c+r[8]*X*r[4]*c+r[1]*f*b*r[6]+a*r[5]*f*r[3]
+r[5]*r[7]*X*c) ]) ;

end proc ;

Can you give an example of X,Y,r,tx,ty,tz,a,b,c,d ? If it comes from a plot, give an example of the plot, etc. a fully-functioning example that we can copy-paste into Maple and run.


print(`output redirected...`);

It seems perfectly sensible to me, icegood (you seem to be in a bad mood lately?)

How about this?

restart;
interface(typesetting=extended):
Typesetting:-Settings(striptrailing=true):

3^(2.0);
                               9.
a^(2.0);
                               2.
                              a   


coming a few months late to this, but since there has been no reply, here a pertinent discussion:

http://www.mapleprimes.com/questions/40724-Symbols-In-Textplot-And-Plot

This explanation, coming from Paulina Chin of Maplesoft, is worth quoting in full,

First, rest assured that we don't really expect users to figure out how to use the internal typesetting representation and generate those ugly strings with msubs and all. You shouldn't have to do this. The easiest approach, if possible, is not to use 1-D input at all. In a 2-D input line, enter textplot([0.75, 0.4, 2-d-expression]). Where I've written 2-d-expression, go to the Layout palette, choose the expression you want and fill in the entries. Then execute and you should get the result you want. If there's a chance that the entry might evaluate or parse incorrectly, then it's best to select the expression and convert into an atomic identifier using the context menu. If you must use 1-D input (e.g. you're writing a procedure that's saved to a text file), you can still do this fairly easily. To get p with subscript g and superscript t, for example, use textplot([0.75, 0.4, typeset(p[g]^t)]). Doing typesetting in 1-D is a lot trickier because the expression must be parsed correctly in 1-D. So if you want t to be the symbol `*`, you must then resort to using something like Typesetting:-mo("*") because * has a particular meaning in 1-D math. Of course, as a developer, I'd prefer that you avoid using the internal undocumented representation unless it's absolutely necessary. You shouldn't have to do this in the majority of cases. Paulina Chin Maplesoft

But I found that something as simple as:

plots:-textplot([ 1, 1, typeset( y[bug] ) ]):

prints correctly inline, may be exported properly with a cumbersome right-click of the mouse, but causes Maple 15 to freeze when using plotsetup(ps, etc.

And while Maplesoft "don't really expect users to figure out how to use the internal typesetting representation and generate those ugly strings with msubs and all" ...

... that's exactly what they have to do!

Markiyan,

I observe the same behaviour that you report INLINE. And I must say, what a paradox.  I notice that "numpoints = 50" looks just as good, to me, as "numpoints = 500" . But, naturally, "numpoints = 5" isn't so good. So there is an "optimal" value of numpoints somewhere between, approx, 5 and 500.

However, after export I do not observe any difference,

For instance, with the proc below (the relevant bit is plotsetup as "gif"):

MakePlot := proc(p::evaln)
  local name, place, opts:
  name := cat(convert(p,string),".gif"):
  place := cat(currentdir(),kernelopts(dirsep)):
  opts := `color,portrait,noborder,transparent`:        
  plotsetup('gif', 'plotoutput'=cat(place,name), 'plotoptions'=opts):
  print( plots:-display( eval(p), 'axesfont' = [ TIMES, 10 ], 'labelfont' = [ TIMES, ROMAN, 10] ) ):
plotsetup(default):
end proc:

p500 := plots:-spacecurve(, t = 0 .. 2*Pi, thickness = 4, numpoints = 500):
  plots:-display(%);
  MakePlot(p500);

p5000 := plots:-spacecurve(, t = 0 .. 2*Pi, thickness = 4, numpoints = 5000):
  plots:-display(%);
  MakePlot(p5000);

The gif images look the same to me (viewed with irfanview). Maple 15 / Windows7x64 / Standard.

Do you get the same behaviour?

Before your loop,

M; PP; KK; HH;
                              0.3
                              0.87
                              0.02
                              0.69

However, after your loop,

M; PP; KK; HH;
                              0.3
                              0.87
                              0.02
                              HH

Inside your loop,

HH, LL:= op(subs(sol, [H(z), L(z)]));

so you are redefining HH and by the time the loop is run HH no longer has a numeric value.

(there may be other problems)

if the following discussion  doesn't help, try to be more specific, namely copy-paste the code you've tried,

http://www.mapleprimes.com/questions/126485-Syntax-For-Plotting-2-Sets-Of-Data-On-One-Plot

specifically pagan's code on how to plot from Matrix data:

http://www.mapleprimes.com/questions/126485-Syntax-For-Plotting-2-Sets-Of-Data-On-One-Plot#comment126488

I'm not sure I understand the problem here, why would you "select all" and "delete"? is that an accidental manipulation?

perhaps this tip might be helpful (but then again perhaps not): if you frequently "select all" and copy-paste stuff around, under Windows you can use a freeware such as clipboard magic and set it up to save "clips" of your copy-paste actions. Not just the last copy-pasted text but all of them (or up to a predefined number, e.g. the last 50).

Here is an example of use. When I type a message into the mapleprimes window, as I'm doing now, every paragraph or so I do: "CTRL-A" followed by "CTRL-C". It's become a reflex, I do it without thinking. If I accidentally refresh the window and my text disappears or if I get interrupted in the middle of writing and my session expires or something like that, the text content of every "select all, copy" action is remembered by clipboard magic. You can set it up to save in a file as well. You can set it up to load on startup. I find it very useful.

Linux typically has these clipboard tools available in a standard release.

I just did a CTRL-A CTRL-C and am going to submit my answer now.

I do realize it is possibly off topic, apologies if I'm producing unecessary noise.

3 4 5 6 7 8 9 Last Page 5 of 24