acer

32405 Reputation

29 Badges

19 years, 351 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

I am guessing that your original question was to find the inflection points of x^sin(x) . I consider this reasonably likely since it is short and simple, it's 1st derivative is the formula your originally posted, and there is clearly some confusion since your original query showed a (mistaken) attempt at rootfinding its 1st derivative.

If my guess is wrong then you could simply change the definition of the procedure body of f below, to match your originally posted fprime_expr formula.

But it would be best if you could clarify what is the actual, intended question.

restart;

with(Student:-Calculus1):
with(plots):
interface(warnlevel=0):

#
# I am guessing that your original question was to find
# the inflection points of x^sin(x) .|
#
# If not, then you simply have to change the first line below.
#

f := x -> x^sin(x);

proc (x) options operator, arrow; x^sin(x) end proc

diff(f(x), x);

x^sin(x)*(cos(x)*ln(x)+sin(x)/x)

#
# Inflection points occur where the expression's 2nd derivative
# changes sign.
#
# Another way to conceptualize it is to think of the points
# at which the curve changes between being "convex up" and
# "convex down".
#

Inflpts := InflectionPoints(f(x), x=0..10, numeric);

[1.395288666, 2.916095860, 7.258616748, 8.576145756]

Roots(diff(f(x), x, x), x=0..10, numeric);

[1.395288666, 2.916095860, 7.258616748, 8.576145756]

#
# Yet another way to conceptualize it is to think of the
# points where the first derivative attains a relative
# maximum or
 minimum. (But not the end-points...)
#
{ op( ExtremePoints(diff(f(x), x), x=0..10, numeric) ) } minus {0.,10.};

{1.395288666, 2.916095860, 7.258616748, 8.576145756}

#
# Here, the shaded portion changes color when the curve changes
# between being convex up and convex down (that is, at the inflection
# points).
#
display(
  pointplot(map(p->[p,f(p)],Inflpts),
            symbolsize=20,symbol=solidcircle,color=blue),
  FunctionPlot('f(x)', x=0.0..10.0),
  axis[1]=[tickmarks=Inflpts], size=[500,250]
);

#
# If we plot the 2nd derivative we can see that it changes sign at
# these points.
#
display(
  pointplot(map(p->[p,0],Inflpts),
            symbolsize=20,symbol=solidcircle,color=blue),
  plot(diff(f(x), x, x), x=0..10, legend=Diff(f(x),x,x)),
  axis[1]=[tickmarks=Inflpts], size=[500,250]
);

#
# If we plot the 1st derivative we can see that it has extreme
# values at these points.
#
display(
  pointplot(map(p->[p,D(f)(p)],Inflpts),
            symbolsize=20,symbol=solidcircle,color=blue),
  plot(diff(f(x), x), x=0..10, legend=Diff(f(x),x)),
  axis[1]=[tickmarks=Inflpts], size=[500,250]
);

 

Download inflectionpts.mw

Why do you think that all your separate r1() calls (within the same loop iteration, or even the same piecewise!) will produce the same value?! They do not.

In the loop, first assign the r1() call to some temp variable name. Then use that assigned name in the piecewise and the print.

I had previously submitted a similar bug report against Maple 2020.0 for Linux, for this unfortunate behavior regression. The default font size for 1D input is still (ostensibly) set to 12pt, but the appearance of it was unpleasingly larger than in previous versions.

Of course it makes no sense. My monitor and dot-pitch are unchanged, so 12pt ought to appear the same as before. The default zoom level is the same, at 100%.

If I set the font size to 11pt then it appears visually as the same dimension as 12pt did in previous versions.

I can set a custom style (with 11pt default), and make that my gui's home page. But it's more awkward.

I don't know if the problem is just a Java version idiosyncrasy, or something related to hi-res tweaks, or other.

 

Your eq1 is an equation, with x1 given explicitly.

You can use it to substitute a value for x1 into your eq2 equation (or something else in which x1 appears).

For example,

   eval(eq2, eq1);

 

Your code is full of syntax errors. The error messages explain them.

For example, your brackets don't match in the first mistake. The number of opening and closing brackets (delimiters) are different.

Also, you need to enter if...then and while..do all in a single execution group. You have mistakenly tried to write thise across multiple execution groups. Use Shift-Enter to move to a new line inside an execution group, and only use Enter to finish and execute it.

Maple works with radians, not degrees. So use Pi/6 instead of 30.

Also, use a floating point value if that's what you want in return (if there is no easy exact result). Eg, sin(4.8) etc.

You could try closing the palettes (panel on the left side of the GUI). I have a recollection of some stall issues related to that.

You could also try closing the context-panel (right side of the GUI). Let us know if either of these makes a difference.

And if you are able to discover a trigger example, then please do share it.

Let us know is the domain over which you want an approximating polynomial is not just 0..1.

restart

lambda := proc (x) options operator, arrow; (-1.565845910+2.393779704*x^2+1.564996800*x^4+1.800900000*x^6)/(x^2+2)^4 end proc

a, b := 0, 1; Digits := 15; K := expand(eval(numapprox:-chebpade(lambda(t), t = 0 .. 1, [11, 0]), T = orthopoly[T]))

0, 1

-1.52912602770120*t^8+.316503853656742*t^7-0.10877005919702e-1*t^5-0.724603953293e-3*t^3+1.54422942262127*t^9-.698472042216867*t^10+.124540489696808*t^11-0.978653647938183e-1+.345390592384950*t^2-.441314123152201*t^4+.499491688907188*t^6-0.1185138058e-5*t

plot(log10(abs(lambda(t)-K)), t = a .. b, size = [500, 200], adaptive = false, numpoints = 70, view = -15 .. 0)

plot([lambda(t), K], t = a .. b, style = [line, point], color = [red, blue], adaptive = false, numpoints = 30, size = [500, 200])

 

Download help2_ac.mw

You could add the listprocedure option to dsolve, and then pick off the procedures individually.

It's generally more efficient to use plots:-odeplot than to plot using the procedures separately as done below. But these compute pretty quickly, so performance may not be a central concern here.

(There are also other ways to pick off the individual results. You can recover some efficiency by using option remember.)

For example,

restart;

ddesys := {diff(S(t),t) = -beta*S(t)*Ix(t)/N,
diff(Ex(t),t) = beta*S(t)*Ix(t)/N - sigma*Ex(t-tau__1),
diff(Ix(t), t) = sigma*Ex(t - tau__1)- gamma*Ix(t-tau__2),
diff(R(t),t) = gamma*Ix(t-tau__2),
diff(Dx(t),t) = delta*Ix(t),
S(0) = 80900, Ex(0) = 1, Ix(0) = 1, R(0) = 0, Dx(0) = 0 }:

dsn := dsolve(eval(ddesys, {beta = 4, gamma = 0.0478, sigma = 0.10,
              delta = 0.0005, N=80900, tau__1 = 1.1,tau__2 = 8.7,tau__3 = 0}),
              numeric, output=listprocedure):

Dxfun := eval(Dx(t), dsn):
Exfun := eval(Ex(t), dsn):
Ixfun := eval(Ix(t), dsn):
Rfun := eval(R(t), dsn):
Sfun := eval(S(t), dsn):

Dxfun(20.0), Exfun(20.0), Ixfun(20.0);

HFloat(4.89877539841769), HFloat(26744.91529379044), HFloat(4309.387881985894)

### Compare
plots:-odeplot(dsn, [[t,Dx(t)], [t,Ex(t)], [t,Ix(t)],
                      [t,R(t)], [t,S(t)]],
               t=0..120, size=[500,300]);

plot([Dxfun, Exfun, Ixfun, Rfun, Sfun], 0..120, size=[500,300]);

 

Download listprocedure.mw

Here are two ways.

You could adjust the values used for width, distance, and offset. (The values are assigned to w,d,o respectively. See the ColumnGraph help page for their meaning.)

If your actual data is quite different then it would really help if you uploaded and attached it. If your numeric and string data are simply rows/columns of a Matrix then you could extract those, convert to lists, and use like L and S below.

restart;

L:=[74,71,87,83,85,61]:
S:=["Belgium","Bulgaria","Czechia","Denmark",
    "Germany (until 1990 former territory of the FRG)",
    "Estonia"]:

(w,d,o) := 25,60,30:
Statistics:-ColumnGraph(L, width=w, distance=d, offset=o,
                        axis[2]=[tickmarks=[[seq(0..100,10)],color=black],
                                 gridlines=[color=black], color=white],
                        axis[1]=[tickmarks=[seq(o+w/2+(i-1)*(w+d)
                                                =typeset(StringTools:-WrapText(S[i],11)),
                                                i=1..nops(S))]],
                        axesfont=["Lucida Sans",10], axes=normal, color="SteelBlue",
                        view=[0..o+(nops(S)-1)*(w+d)+d,0..100], size=[600,400]);

 

Download columngraph_ac.mw

The following uses plots:-textplot instead of tickmarks on the x-axis.

restart;

L:=[74,71,87,83,85,61]:
S:=["Belgium","Bulgaria","Czechia","Denmark",
    "Germany (until 1990 former territory of the FRG)",
    "Estonia"]:

(w,d,o) := 25,60,30:
plots:-display(
  Statistics:-ColumnGraph(L, width=w, distance=d, offset=o,
                          axis[2]=[tickmarks=[[seq(0..100,10)],color=black],
                                   gridlines=[color=black], color=white],
                          axis[1]=[tickmarks=[]], axesfont=[TIMES,10],
                          axes=normal, color="SteelBlue"),
  seq(plots:-textplot([o+w/2+(i-1)*(w+d),-2,
                       typeset(StringTools:-WrapText(S[i],11))],
                       align=[below],font=[TIMES,10]),i=1..nops(S)),
  plots:-pointplot([[0,102]],color=white),
  view=[0..o+(nops(S)-1)*(w+d)+w+d/2,default], size=[600,400]);

 

Download columngraph_tpl.mw

The sort command can be used to rearrange the additive terms in some kinds of polynomial, using a flavour of monomial ordering. It works by replacing the particular expression's form that the kernel stores in its table of "uniquified" expressions (aka "simpl" table).

I can cook one up for your example, by eye. For such a monic example it'd be easy to write a procedure that does a subsindets on suitable `+` subterms -- where the action involves a scan and a sort call.

restart;


I forcibly enter the expression in the undesired form, to illustrate
that it can occur. Then I sort it. And then I show that its form has
been changed.

( - a1b2 + a2b1) * j1 + ( - a3b5 + a4b4) * j2:
a := (a2b1-a1b2)*j1+(a4b4-a3b5)*j2:

 

a;

(-a1b2+a2b1)*j1+(-a3b5+a4b4)*j2

 

sort(a, order=plex(a2b1,a4b4)):

 

a;

(a2b1-a1b2)*j1+(a4b4-a3b5)*j2

Download sort_ex.mw

But the facility is restricted. You can easily construct a more general example for which none of the available sortings would be able to achive the goal.

 

kernelopts(version)

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

restart; assume(1 <= x, x <= 4)

assume(0 < y, y < 1)

f := 1-4*(x-1)*(1+y)/(x^2*(1-y))

sols := [solve(f > 0, useassumptions)]

[{x = 1, 0 < y, y < 1}, {0 < y, 1 < x, x < 2, y < (x^2-4*x+4)/(x^2+4*x-4)}, {0 < y, 2 < x, x < 4, y < (x^2-4*x+4)/(x^2+4*x-4)}, {x = 4, 0 < y, y < 1/7}]

seq(`assuming`([is(f > 0)], [sols[i][]]), i = 1 .. nops(sols))

true, true, true, true

restart

f := 1-4*(x-1)*(1+y)/(x^2*(1-y)):

solsO := [solve({f > 0, 1 <= x, x <= 4, 0 < y, y < 1})];

[{x = 1, 0 < y, y < 1}, {0 < y, 1 < x, x < 2, y < (x^2-4*x+4)/(x^2+4*x-4)}, {0 < y, 2 < x, x < 4, y < (x^2-4*x+4)/(x^2+4*x-4)}, {x = 4, 0 < y, y < 1/7}]

seq(`assuming`([is(f > 0)], [solsO[i][]]), i = 1 .. nops(solsO));

true, true, true, true

``

Download positive_function_ac.mw

Append the string with the full location of the .mla file to libname, in Maple. For example,

   libname := libname, "C:/Users/Lisa6/Documents/myfolder/filename.mla";

You only need to do that once per session, so you could put it at the beginning of your worksheet, or right after a restart .

Note that a .mla file can contain several things. It's possible that your file blah.mla also happens to contain a module package blah, so that you can issue the with(blah); command. But the name of the things stored in your blah.mla file may be named differently.

A unit is not part of the embedded component per se.

But you can force a particular unit for a particular dimension, as a preference set with the Units:-UseUnit command. And that will get carried over to what is put inside a MathContainer. For example,

restart;

W := 87.7 * Unit(joule/m^2);

87.7*Units:-Unit(J/m^2)

combine(W, units);

87.7*Units:-Unit(kg/s^2)

V := 45.6 * Unit(kg/s^2);

45.6*Units:-Unit(kg/s^2)

Units:-UseUnit(N/m):

combine(W, units);

87.7*Units:-Unit(N/m)

combine(V, units);

45.6*Units:-Unit(N/m)

simplify(V);

45.6*Units:-Unit(N/m)

DocumentTools:-SetProperty("MathContainer0", expression, combine(V, units));

Download UseUnit_EC.mw

You can also re-express something in terms of units of compatible dimension. And that can always be done directly, without Units:-UseUnit . Again, the unit is simply a part of the expression, and not specific to the embedded component. For example,

restart;

V := 45.6 * Unit(kg/s^2);

45.6*Units:-Unit(kg/s^2)

convert(V, units, N/m);

45.6*Units:-Unit(N/m)

DocumentTools:-SetProperty("MathContainer0", expression, convert(V, units, N/m));

Download Unit_EC.mw

In either scenario above you could also produce results in terms of kN/m if you prefer. The component step would be done similarly.

restart;

V := 45.6 * Unit(kg/s^2);

45.6*Units:-Unit(kg/s^2)

convert(V, units, kN/m);

0.4560000000e-1*Units:-Unit(kN/m)

Units:-UseUnit(kN/m):

combine(V, units);

0.4560000000e-1*Units:-Unit(kN/m)

 

Download Unit_kN.mw

 

There are several ways to get such an effect.

You should be able to adjust the following easily (to alter the colors or symbolsize, include the axes, remove the blue circle, slow it down with more frames, etc). If you want help just state precisely what effects you want. Or see the Help pages for Topics like animate or plot,options .

restart;

bg := plot([sin(tt),cos(tt),tt=0..2*Pi],color="Navy",thickness=0):

G := proc(t) local tt;
  plots:-display(
    bg,
    plot([sin(tt),cos(tt),tt=0..t],color="Red",thickness=3),
    plot([[sin(t),cos(t)]],style=point,color="Red",
         symbol=solidcircle,symbolsize=30));
end proc:

plots:-animate(G, [t], t=0..2*Pi, frames=50,
               paraminfo=false, axes=none);

 

Download circle_trace.mw

I find that one of the easiest ways to start doing an animation is to contruct a procedure that produces just a single frame. Here, the procedure G can be called to show a single frame. For example,

G(Pi/4)

That makes calling plots:-animate much simpler. And it allows you to test easily the generation of any particular frame, without having to build the whole animation.

First 124 125 126 127 128 129 130 Last Page 126 of 336