acer

32313 Reputation

29 Badges

19 years, 311 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

One way is to perform a change of variables, manually.

restart

ans := int((v^2-1)*(v^3-3*v+6)^5, v)

(1/18)*v^18-v^16+2*v^15+(15/2)*v^14-30*v^13+180*v^11-(585/2)*v^10-300*v^9+1539*v^8-1350*v^7-(4239/2)*v^6+5994*v^5-4050*v^4-3888*v^3+9720*v^2-7776*v

H := Int((v^2-1)*(v^3-3*v+6)^5, v)

Int((v^2-1)*(v^3-3*v+6)^5, v)

with(IntegrationTools)

Change(H, u = v^3-3*v+6, u)

Int((1/3)*u^5, u)

value(%)

(1/18)*u^6

ans2 := eval(%, u = v^3-3*v+6)

(1/18)*(v^3-3*v+6)^6

simplify(diff(ans, v)-(diff(ans2, v)))

0

 

Download Question_for_maple_primes_6_acc.mw

Without having to rely on visual examination of the plot for a starting point, we can find the first root to the left of zero as well as the first root to the right of zero.

restart;

 

f := 2.0*cos(1.5*x + 4.0) + 2.2:
g := 2.0*cos(1.6*x + 3.85) + 2.0:

 

Smallest positive root (without needing an upper bound),
ie. first root moving right from 0.

RootFinding:-NextZero(unapply(f-g,x),0);

3.834531622

Greatest negative root (without needing a lower bound),
ie. first root moving left from 0.

-RootFinding:-NextZero(unapply(eval(f-g,x=-x),x),0);

-.7967442904

Download tworoots.mw

For expressing the four roots explicitly in terms of radicals,

ans := [ solve(x^4-x^3-3*x^2-x+12=0, x, explicit) ];
simplify(ans, size);

or, for floating-point approximations of the four roots,

fsolve(x^4-x^3-3*x^2-x+12=0, x, complex);

I think that it would be much better to not make those assignments at all(!), and to use eval(...,[...]) to evaluate other expressions whenever you need to utilize those particular values. That would allow you to do subsequent symbolic manipulation without having to unassign. I think that is decent practice, if done in a usual and sensible manner. For example,

restart;

 

We can store this, for multiple re-use late on.

vals := [xb=1000, yb=2500, db=5321, eb=521];

[xb = 1000, yb = 2500, db = 5321, eb = 521]

 

eq:=eb=ab*yb*db*x;

eb = ab*yb*db*x

ans := isolate(eq,x);

x = eb/(ab*yb*db)

We can now evaluate the symbolic solution (or another
expression) using the stated values.

eval(ans, vals);

x = (521/13302500)/ab

Download usual.mw

I don't really recommend the goal that you've described (of first assigning, and then symbolically manipulating expressions containing those assigned name, without having to unassign) whether you use the methodology below or some alternative.

In my opinion the following is using Maple is a very backwards manner. (If you do manipulations of more complexity you might have even more tricky hoop-jumping to do.) 

restart;

 

xb:=1000: yb:=2500: db:=5321: eb:=521:

 

eq:='eb'=ab*'yb'*'db'*x;

eb = ab*yb*db*x

ans := isolate(eval(eq,1),x);

x = eb/(ab*yb*db)

With evaluation it picks up the assigned values.

ans;

x = (521/13302500)/ab

But we can prevent that.
eval(ans,1);

x = eb/(ab*yb*db)

We can even substitute for the (assigned) names.

eval(eval(ans,1), ['eb'=777]);

x = 777/(ab*yb*db)

f:=unapply(eval(ans,1), ['eb']);

proc (eb) options operator, arrow; x = eb/(ab*yb*db) end proc

f(777);

x = (777/13302500)/ab

Download wickedness.mw

You might notice that the following direct use of plots:-odeplot (with mode=log for axis[1]) undersamples and renders a coarser curve in the lower range, as compared with plots:-semilogplot. I can't tell whether that's an issue for you since you haven't bother to provide your full example.

restart;

res := dsolve({diff(N(t),t)=t^(-2/11),N(0.02)=1},numeric):

plots:-odeplot(res, [t,N(t)], 0.1e-2 .. 1000,
               axes = boxed, tickmarks = [3, 2],
               color = red, thickness = 1, size=[500,300],
               labeldirections = [horizontal, vertical],
               labelfont = [Helvetica, roman, 18]);

plots:-odeplot(res, [t,N(t)], 0.1e-2 .. 1000,
               axes = boxed, tickmarks = [3, 2],
               axis[1] = [mode=log],
               color = red, thickness = 1, size=[500,300],
               labeldirections = [horizontal, vertical],
               labelfont = [Helvetica, roman, 18]);

plots:-semilogplot(t->eval(N(':-t'),res(t)), 0.1e-2 .. 1000,
                   axes = boxed, tickmarks = [3, 2],
                   color = red, thickness = 1, size=[500,300],
                   labeldirections = [horizontal, vertical],
                   labels=[t,N], labelfont = [Helvetica, roman, 18]);

 

Download ode_semilog.mw

Are you looking for this distinction, which is documented on the Help page for arctan?

plot3d([arctan(y,x),arctan(y/x)], color=[blue,red], style=[surface,line]);

arctan(1.0), arctan(-1,-1.0);

.7853981634, -2.356194490

 

Download arctan.mw

You don't need the Embedded Plot Component in order to simply plot them all together, with the plots being rendered at the cursor's current output location.

For that all you need is,
    plots:-display(plotlist);
or, within a procedure call that returns something else,
    print(plots:-display(plotlist));

Here are those two ideas: pdisp.mw

In contrast to the above, a Embedded Plot Component allows you to set a fixed location in your document. That way, you can replace with other plots later on, programatically, and they will all appear in the same location as earlier, not matter how many times you repeat. You could also do that whenever some procedure of yours gets called. The key thing is that the plots are rendered in the same location, overwriting what was there before. This can also help save space, so that your worksheet doesn't get cluttered or scroll as much.

If you have some other usage scenario then it would be best if you could describe it precisely. (I can think of some other scenarios, but guessing can be inefficient.)

Your problem was not in evaluating the entries of x (ie. each Vector in your aVectorList). It was due to not accounting for AddVector being reused each time through the loop.

[edit] I gave a 1-liner alternative below, using seq. (Other alternatives are possible, using map[2], etc, including the one Carl has subsequently provided in his Answer.) Since a terse one-off replacement doesn't provide insight into what went wrong for you originally, I wrote all the rest with the hope of explaining by example.

restart

aVectorList := [Vector(2, [1, 2]), Vector(2, [3, 2])]

aVectorList := [Vector(2, {(1) = 1, (2) = 2}), Vector(2, {(1) = 3, (2) = 2})]

[seq(Vector(4, x), `in`(x, aVectorList))]

[Vector(4, {(1) = 1, (2) = 2, (3) = 0, (4) = 0}), Vector(4, {(1) = 3, (2) = 2, (3) = 0, (4) = 0})]

results := []; for x in aVectorList do results := [op(results), Vector(4, x)] end do; results

[Vector(4, {(1) = 1, (2) = 2, (3) = 0, (4) = 0}), Vector(4, {(1) = 3, (2) = 2, (3) = 0, (4) = 0})]

Augementing a list in this manner is inefficient.

results := []; for x in aVectorList do AddVector := Vector(4); AddVector[1] := x[1]; AddVector[2] := x[2]; results := [op(results), AddVector] end do; results

[Vector(4, {(1) = 1, (2) = 2, (3) = 0, (4) = 0}), Vector(4, {(1) = 3, (2) = 2, (3) = 0, (4) = 0})]

"results:=Array():  AddVector:=Vector(4): for i from 1 to nops(aVectorList) do"?"     AddVector:=Vector(4):     AddVector[1] := aVectorList[i][1];     AddVector[2] := aVectorList[i][2];     results(i):= AddVector; end do: convert(results,list);"

[Vector(4, {(1) = 1, (2) = 2, (3) = 0, (4) = 0}), Vector(4, {(1) = 3, (2) = 2, (3) = 0, (4) = 0})]

results := 'results'; AddVector := Vector(4); for i to nops(aVectorList) do AddVector := Vector(4); AddVector[1] := aVectorList[i][1]; AddVector[2] := aVectorList[i][2]; results[i] := AddVector end do; convert(results, list)

[Vector(4, {(1) = 1, (2) = 2, (3) = 0, (4) = 0}), Vector(4, {(1) = 3, (2) = 2, (3) = 0, (4) = 0})]

NULL

Download Mutable_ac.mw

restart;
kernelopts(version);

   Maple 2021.1, X86 64 LINUX, May 19 2021, Build ID 1539851

Ftarg := 1/2+signum(x-mu)/(2*GAMMA(1/beta))
             *(GAMMA(1/beta)-GAMMA(1/beta, abs((x-mu)/sigma)^beta)):

f := beta/(2*sigma*GAMMA(1/beta))*exp(-(abs(x-mu)/sigma)^beta):

conds := x::real, mu::real, beta > 0, sigma > 0:

simplify( diff(Ftarg, x) - f ) assuming Or(x>mu, x<mu), conds;

                       0

In some older versions such as Maple 2015 you could split that into separate integrations for x>mu and x<mu.

For input it is exp(...) not e^(...).

The name "e" has no special value in Maple.

The typeset output displays as a bold, upright Roman e^(...) and that is what often confuses people.

restart;                                                                           

uu := (x, y, t) -> exp(.2*t)*(exp(-x)+exp(-y)):                                    

uu(.1, .1, .1);                                                                    

              1.846232693

You could also type the letters exp and then press the Esc key and so use command-completion, in order to get a nicely typeset input like that bold, upright e^....

You could also use the appropriate entry from the Expressions palette., although personally I find that more awkward since your hand has to switch back and forth between keyboard and pointer.

At the top right corner of each Question/Post/Answer you should be able to see a Thumbs-Up icon and a Star icon.

The Star icon is for marking something as one of your favorites. When marked it appears in blue, when unmarked it appears in grey.

Put the Library file (.mla filename extension) in a location that is in the path as specified by libname.

And so one possibility is to put it in a location of your choice, and then to augment libname with that location. 

You could read Answers to several previous, related Questions. Eg. here and here.

A Vector is properly a mutable structure, ie. its entries can be changed in-place.

In consequence, different Vectors are distinct structures, even if they just happen to have the same entries. So a set of such are not reduced by merely apparent duplicates (ie. Vectors having the same entries).

In contrast, lists are not properly mutable; two lists having the same entries point to the same uniquified structure in memory. So a set of equal lists gets duplicates removed.

note: There is some purportedly user-friendly functionality that lets you change a list's entries as if it were acting in-place. But the result is a new and distinct structure, so this is actually faking in-place action.

a := {Vector(2, [1, 0]), Vector(2, [2, 0])}

{Vector[column](%id = 18446883925989928582), Vector[column](%id = 18446883925989928702)}

b := [Vector(2, [1, 0]), Vector(2, [2, 0]), Vector(2, [1, 0])]

[Vector[column](%id = 18446883925992055142), Vector[column](%id = 18446883925992055262), Vector[column](%id = 18446883925992055382)]

c := convert(b, set)

{Vector[column](%id = 18446883925992055142), Vector[column](%id = 18446883925992055262), Vector[column](%id = 18446883925992055382)}

d := [[1, 0], [2, 0], [1, 0]]``

[[1, 0], [2, 0], [1, 0]]

e := convert(d, set)

{[1, 0], [2, 0]}

addressof(b[1]), addressof(b[3])

18446883925992055142, 18446883925992055382

addressof(d[1]), addressof(d[3])

18446883926001396702, 18446883926001396702

b[1][2] := 13; b[1]

Vector[column](%id = 18446883925992055142)

addressof(b[1])

18446883925992055142

d[1][2] := 13; d[1]

[1, 13]

addressof(d[1])

18446883925981769838

``

Download DuplicateEntries_ac.mw

restart:

f := sin(2*t)-sin(3*t)+sin(4*t);

sin(2*t)-sin(3*t)+sin(4*t)

Student:-Calculus1:-Roots(f, t = 0 .. 2*Pi);

[0, (1/3)*Pi, (2/3)*Pi, Pi, (4/3)*Pi, (5/3)*Pi, 2*Pi]

Download SC1Roots.mw

I submitted a bug against solve about three weeks ago -- that it was missing solutions -- in a very similar case (trig, bounded above and below). I will submit this new example.

Someone else mentioned that applying expand worked for this example. For some other examples applying combine works (but not for this example). Another possibility here is to split the domain.

{solve([f, t >= 0, t <= Pi], allsolutions, explicit)}
union
{solve([f, t >= Pi, t <= 2*Pi], allsolutions, explicit)};

  /                                /    1   \    /    2   \   
 { {t = 0}, {t = Pi}, {t = 2 Pi}, { t = - Pi }, { t = - Pi }, 
  \                                \    3   /    \    3   /   

    /    4   \    /    5   \ \ 
   { t = - Pi }, { t = - Pi } }
    \    3   /    \    3   / / 

For any of these workarounds one can find similar examples for which it fails while some others succeed.

None of these workarounds seems as robust as Calculus1:-Roots, for some restricted flavour of problem.

That should be
   with(GeM):
instead of,
   With(GeM):
as you showed it.

If that's not your problem then you should upload and attach you worksheet.

First 78 79 80 81 82 83 84 Last Page 80 of 336