Christopher2222

5785 Reputation

24 Badges

16 years, 349 days

MaplePrimes Activity


These are answers submitted by Christopher2222


simp := plot(sin(x), x = 0 .. Pi);

 

interface(verboseproc)

1

(1)

``

 

Download transform_test.mw

It works here in M12

No notice but it will be released very soon, probably end of march or sometime in april.

bits and pieces help is all I have

L(:,1:m) is the same as L[..,1..m] in Maple

I'm not sure what the ; is in [90;90] or in v(1;1:m) others are probably more matlab knowledgable than myself. 

Interestingly the nice table of isotope procedure I wrote here in Mapleprimes for Maple showed up in the following release of Mathematica.  Hmm... very interesting.  Although the code written for Mathematica is about 10 x's smaller, Maple was first.  Actually I remember looking, at the time, to see if such a table existed in Mathematica or Matlab before embarking on such a project.  It seems to me like they took that page right out of our books.  Time to start thinking/coding and up the ante a little more I think. 

Just for interest, let's step back 2-1/2 years to http://www.mapleprimes.com/posts/96059-Why-Is-Maple-Last#comment96222 -

I mention about 1 reply down the first page that pops up in google search from the internet sea using the tags ` Maple Mathematica and Matlab `  is http://amath.colorado.edu/computing/mmm/ the same page I mention above.  Ironically today that same page is still first in the list and nothing has changed.  And the 3M coding war-room hasn't started yet, I would start it but I haven't got any time. 

So would it then be wise then for everyone assigning values to use the uneval form in everything?

Using range we need to close the ends.  Here's the updated proc for that.  Sorry I haven't elaborated on the bee swarm plot but basically I think that is data jittered inside a violin plot.  Also using method=exact speeds up the production of the plot.

 

violinplot := proc (data) local a, b, c, caps, lc, rc; a := Statistics:-KernelDensityPlot(data, range = min(data) .. max(data), color = blue, method = exact); b := plottools:-reflect(a, [[0, 0], [1, 0]]); lc := Statistics:-KernelDensity(data, eval = min(data)); rc := Statistics:-KernelDensity(data, eval = max(data)); caps := plot({[[max(data), rc], [max(data), -rc]], [[min(data), lc], [min(data), -lc]]}, color = blue); c := plots:-display(a, b, caps, axes = box, color = blue); plots:-display(plottools:-rotate(c, (1/2)*Pi)) end proc:

b := [45, 7, 4, 345, 8, 456, 3, 2, 45, 444, 111, 34]

[45, 7, 4, 345, 8, 456, 3, 2, 45, 444, 111, 34]

(1)

violinplot(b)

 

``

 

Download violinplot_proc_4.mw

**edit** adding bandwidth=nops(data)*2 gives a little more flavour to the plot and a better indication of where the data points are.

Actually using left and right distorts the distribution too much.  Using range makes it better. You were right with the caps.  The whiskers for the tips, yes I would want to reach min and max points without going over, however I think that offsets the data too much. 

And just for fun.

with(plots):
with(plottools):
a := seq(rectangle([-sqrt(2)^n, sqrt(2)^n], [sqrt(2)^n, -sqrt(2)^n]), n = 0 .. 4):
b := implicitplot([seq(x^2+y^2 = (sqrt(2)^n)^2, n = 0 .. 4)], x = -5 .. 5, y = -5 .. 5, numpoints = 5000):
display(a, b, color = green, transparency = .7)



So you want the solution to be something like cos( X ) - where X is a collection of some constant, w, t, and theta?

As Carl said, you can't get any more simplified than what you got.  Or did you want it as some collection of added cosine terms?

142.3*cos(w*t-theta) + 142.3*cos(w*t+(1/3)*Pi+theta) + 142.3*cos(w*t+theta)
                                               ------                                                           ------
                                                   2                                                                    2

**edit add** I used trigsubs to get the above.

CC:=convert(C,rational)*10/1423:

trigsubs(op(CC)[1])+trigsubs(op(CC)[2])

%*142.3

If the solution curve does not hit the extents of the x range it will not be shown.  Manipulating the x and y ranges will help but it may also be necessary to separate the initial valued solutions into different plots and use display with view to get a better represented graph of the solutions. 

Or just use Preben's solution as acer pointed out above.

 

I like to simulate these types of problems.  Here is a little code snip.  Increasing the number of trials we can see that we approach our expected probability 31.9% of winning $10 before loosing our $20.  But it takes a while (280sec in M12 with the code I present) to run through 5000 trials.

I set the number of betting times to 1000 per trial to ensure that the results most likely would be either a loss or a win but sometimes there will be an odd time that even after 1000 bets the player still hasn't won $10 nor lost his $20 and that would show up in the end result if the values do not sum to 1.

Note: for some reason only the last output line in shown, no matter.  The win showed .3190 a discrepancy due to some trials ending with no condition met but of course code could be added to address the situation.

trials := 5000:

total := 20:

bets := 1000:

``

``

b := table():

"Lost", .6796000000

(1)

``

``

``

NULL

NULL


Download simple_roulette_sim.mw

 

Changing x to some other variable, say t, appears to work in 16.02

with(DEtools):
eqn3 := diff(y(t), t) = t+sin(y(t));
IC3 := [y(0) = 2, y(3) = 0];
DEplot(eqn3, [y(t)], t = -5 .. 5, IC3, y = -5 .. 5, arrows = comet, linecolor = BLACK)

 

 

**edit add **

It is a range problem bug.  Changing your x range  x=-3..2 will remedy the problem and display the solution curves. 

eqn3:=diff(y(x),x)=x+sin(y(x));
IC3:=[y(0)=2,y(3)=0];
DEplot(eqn3,[y(x)],  x=-3..2  ,IC3,y=-5..5,arrows=comet,linecolor=BLACK);

set your plots equal to some variables, say a and b

then use

display(Array([a,b]));

This will display your plots in side by side graphs.  If you mean side by side in the same graph then use DualAxisplot

DEplot(diff(y(x), x) = x^2+y(x)^2-1, y(x), x = 0 .. 5, y = -1 .. 5, [y(0) = 0])

First 18 19 20 21 22 23 24 Last Page 20 of 47