<

itsme

734 Reputation

14 Badges

15 years, 46 days

MaplePrimes Activity


These are questions asked by itsme

This question is probably for maple devs...

I was wondering if it would be possible to outline what algorithm is used to generate replications (realizations) for various processes by the Finance:-SamplePath command (and friends). For example in the code like this:

with(Finance):

X := WienerProcess();
A := SamplePath(X(t), t = 0 .. 1, timesteps = 100, replications = 20);

Is it the Euler-Maruyama method?

Alternatively maybe you can show the portion of the code that is responsible for the integration of the SDE that the Wiener process defines.

I can't find any details related to this information in the help, and it would be very helpful to know this (and more importantly have it in the help section).

Thanks!


I'm trying to add a label to a plot and need the derivative to be represented as a dot. My typesetting rules are set to extended, and it works in a worksheet but not in the plot. See attached image. The code to generate it is:

#the output is shown with a dot over phi
diff(phi(t),t);

#derivative in label not shown as a dot
plot(sin( t), t=0..10, labels=["t", typeset(diff(phi(t),t))], labeldirections=[horizontal, vertical]);

any ideas?

thanks

EDIT:

this seems to work... ( i will leave this question here as it might come in handy to someone else).

plot(sin( t), t=0..10, labels=["t", Typesetting:-Typeset(diff(phi(t),t))], labeldirections=[horizontal, vertical]);

Is it a bug that using the first variant does not work? any ideas from the experts?



Hi:

I would like to slightly modify the "Explore" command -- I find it extremely useful, but the layout often doesn't work well for me (my typical use case is say 12 plots with ~10 parameters that vary). The problem is that the default alignment the columns of the table that contains a matrix of plots is "Center" and my plots don't fit on the screen properly (no matter how I play with sizes, placement, etc) and I would like it to be "Left" aligned --- aligning things manually (via right click) after the explore command is executed is possible, but painful, given that I often change my code.

... bottom line is that I would like to be able to re-define the "Explore" command.

I tried doing so by first calling:
showstat(Explore);

... then removing all the numbers, renaming the proc to sat MyExplore, declaring it (i.e. so maple understands it) and for now using that instead of the old Explore in my program (with no actual code changes for now). The problem is that I get the following error:

Error, (in DocumentTools:-Layout:-Table) number of Column arguments, 3, exceeds total column span, 1, computed from Rows' Cells

I think, somehow maybe showstat is not showing the full thing? or maybe it is part of a more complicated module? or maybe by removing the numbers the formatting got screwed up (i was careful here)?

So my question:

How would I define my own function "MyExplore" that (for now) contains exactly the same code and functionality as the built-in "Explore"?

thanks!

Consider a plot generaged by:

export_plot_options:=font=[TIMES, roman, 30], axis=[thickness=4, location=low], size=[850,850]:
points := [seq([seq(exp(-(x^2+y^2)*(1/100)), x = -10.0 .. 10.0)], y = -10.0 .. 10.0)]:
plots:-listdensityplot(points, export_plot_options);

How can one get rid of white space between the axes and the actual data??

thanks

Hi

I have to numerically solve this equation many (tens of thousands) of times for theta_n (as I vary different parameters, especially n):

tan(theta_n) - C_a*Z_0*(-v^2*(Pi*n-theta_n)^2/x_l^2+omega_a^2)*x_l/(v*(Pi*n-theta_n)) = 0

theta_n should be in [-pi/2, pi/2). It seems like solving this is the slowest single component of the chain of calculations (that follow this).

Currently I do it with this function:

get_theta_n_array:=proc(max_n::integer, omega_a::float, v::float, x_l::float, C_a::float, Z_0::float)
    local theta_n_array:=Array(
        select(x->Re(x)<evalf(Pi/2) and Re(x)>=-evalf(Pi/2), [seq(
        #NOTE: careful with fsolve - in some cases returns unevaluated equation
        fsolve(tan(theta_n) - C_a*Z_0*(-v^2*(Pi*n-theta_n)^2/x_l^2+omega_a^2)*x_l/(v*(Pi*n-theta_n)) = 0, theta_n) , n=1..max_n)]
        , real)
        ,datatype=float[8]);
    if ArrayNumElems(theta_n_array) <> max_n then
        printf("Bad Array Dimensions! Got too many or not enough solutions.");
        theta_n_array:="CHECK: get_theta_n_array()": #dirrrrty hack that will ring an alarm bell if array is not the right size
    end;
    theta_n_array;
end;

And call it like so (for say n=1000)

st:=time();
result:=get_theta_n_array(1000, 100e9, 1e8, 0.3, 20e-14, 50.0);
time()-st;

This will take say 3.5s on my PC.

Does anyone have any ideas how to speed this up? I would hope this to take at least an order of magnitude less time. I played with DirectSearch lib but that was not faster.

Also, I should note that this is the only portion of my code that is not thread safe (because of the fsolve call), which leads to "extra" slowdowns because I have to use Grid:-Map, instead of Thread:-Map when parallelizing, and more importantly because I can't compile the rest of the code (Grid:-Map is not compatible with compiled functions).

Let me know if you have any ideas...

thanks!

4 5 6 7 8 9 10 Page 6 of 12