Items tagged with maple maple Tagged Items Feed

Hi,

I have a 4-D function that I have found an analytic expression for in Maple, but I want to generate a numerical 4-D array, which I can export for use in Matlab. However, I don't think I'm using a very good solution, because it is extremely slow (several minutes for even 10x10x10x10 elements). My code is

NumRange:=10:
NumElements:=10:
dx:=2*NumRange/(NumElements-1):
A:=Array(1..NumElements,1..NumElements,1..NumElements,1..NumElements,[seq([seq([seq([seq(evalf(rho(ws1,ws2,ws1p,ws2p)),ws2p=-NumRange..NumRange,dx)],ws1p=-NumRange..NumRange,dx)],ws2=-NumRange..NumRange,dx)] , ws1=-NumRange..NumRange,dx)],datatype=float);

Rho is an exponential with 10 terms in the exponents.

I also tried using four for-loops but that was even slower!

Thanks for any input

I really do not want to click on hundreds of pages here http://www.maplesoft.com/products/maple/new_features/index.aspx in order to figure what new functions  there are in Maple 18. Even when clicking on these pages and following the links, it is hard to collect and enumerate what the new functions are and one gets lost in the processes. It seems all marketing material.

Any one knows a page that lists these new functions all in one place? It will be nice if there is a list of new functions/packages and list of modified functions in Maple 18.

Trying to find what new functions or modified functions in Maple is not easy.

 

Hi, 

 

I wish to be able to calculate the roots of the function f(p) by using the roots of the function h(p) and applying the bisection method due to the fact that the roots of h(p) bracket the roots of f(p) as can be seen in the graph below. I have done this before for another example when h:=J0(p); and hence i could use The commands BesselJZeros(0,n)/BesselJZzeros(0,n+1) to find the roots. So my problem arises with the finding the roots of h(p) and how to insert them into my bisection loop(underlined below).

Any advice would amazing. Many thanks


restart;

Digits := 30:
with (plots):
with(RootFinding):

#Define given parameters

R:=1: #external radius of particles, cm

d:=10^(-3): #diffusivity cm^2 per second

alpha:= 1: #fractional void volume

c0:=10^(-6): #concentartion of soltion in void volume of solid initially, moles per liter

C0:=0: #concentration of main body of solution initially, moles per liter

k1:=0.5: #constant in adsorption isotherm (ka)

k2:=0.75: #constant in adsorption isotherm (kd)

k:=2.5: #equilbrium constant for adsorption kinetics

n0:=(k1/k2)*c0:#initial amount absrobed on solid, moles per liter

V:=0.1: #volume of external solution, liters

W:=0.1: #weight of absorbant, grams

rho:=2.0: #solid aparrant density, g/cc

delta:=(1/d)*((p+alpha*k2+k1)/(p+alpha*k2));

beta:=W*alpha*d/(rho*V);

   

1000*(p+1.25)/(p+.75)

 

0.500000000000000000000000000000e-3

 

 

 

 

 


f:=p->(BesselJ(0,R*sqrt(-delta*p))*k*p-(R*sqrt(-delta*p))*BesselJ(1,R*sqrt(-delta*p))*(d*p/R + 2*beta*k/(R^2)));

proc (p) options operator, arrow; BesselJ(0, R*sqrt(-delta*p))*k*p-R*sqrt(-delta*p)*BesselJ(1, R*sqrt(-delta*p))*(d*p/R+2*beta*k/R^2) end proc

(2)

h:=p->(BesselJ(0,R*sqrt(-delta*p)));
plot([f(p),h(p)],p=-0.3..0,axis=-5..5,legend=["f(p)","h(p)"]);


 




proc (p) options operator, arrow; BesselJ(0, R*sqrt(-delta*p)) end proc

 

 

 

(3)



points:=5:
rts:= Array(1..points):
for n from 1 by +1 to points do
pl:=evalf(#**first root of h**);
pu:=evalf(#**second root of h, i.e n+1 root**);
pe:= (pl+pu)/2;
while abs(f(pe))>10^(-6) do
pe:=(pu+pl)/2;
if f(pu)*f(pe) <0 then
pl:=pe;
elif f(pl)*f(pe)<0 then
pu:=pe;
end if;
od;
rts[n]:=pe;

od;
rts[n]:=p[n];

 

 

Download spherical_continue.mw


 

Download spherical_continue.mw

Hello there,

i got a question regarding derivatives in Matlab.

 

I got a function for a example:

f:=f1(y)*f2(x)

 

from this function i need the partial derivatives with respect to x and y, i can easily get them with

diff(f,x)

diff(f,y)

 

now i want to compute the derivative of f with respect to time t, assuming that y and x both depend on t - how can i tell maple that y and x depend on t?

 

thanks

ben

Hello Maplers, i have encountered a little annoyance with Maple, that i would like to ask, whether it can be solved. 

 

It's when i try to define a function, like f(x)=2x and try to define it with a command f(x):=2x, a pop-up box comes up, asking me whether i'd like to use a 'function definition', or 'remember table assignment', and i would like to make Maple remember my choice that i want a function. 

 

I know i can write it like f:=x->2x, but i hate to look at that, to be frankly..

 

So, is there any way to solve this?

 

I have computed the infinite multiplication using Maple, $\Pi_{k=3}^{\infty} ( \cos (\frac{\pi}{k} ))$, as follows, but it resulted in 0! I wonder why this happened, although maple was using exact arithmetic.


    P := Product(cos(Pi/k), k = 3 .. infinity)   

    value(P)

Note that if I use floating-point instead, it gives me the right answer, 0.1149420449.


    evalf(P)
By the way, I did not expect such a situation! Exact arithmetic should be exact! I am multiplying non-zero numbers to each other, starting from $1/2$ to $1$ as $n \rightarrow \infty$. So it should not be zero! Why such a thing happened?

Dear all

I would like to convert Matlab code to Maple, is there anu idea, this is the code.

 

% Usage: [y t] = abm4(f,a,b,ya,n) or y = abm4(f,a,b,ya,n)
% Adams-Bashforth-Moulton 4-th order predictor-corrector method for initial value problems
% It uses
% Adams-Bashforth 4-step method as a precdictor,
% Adams-Moulton 3-step method as a corrector, and
% Runge-Kutta method of order 4 as a starter
%
% Input:
% f - Matlab inline function f(t,y)
% a,b - interval
% ya - initial condition
% n - number of subintervals (panels)
%
% Output:
% y - computed solution
% t - time steps
%
% Examples:
% [y t]=abm4(@myfunc,0,1,1,10);          here 'myfunc' is a user-defined function in M-file
% y=abm4(inline('sin(y*t)','t','y'),0,1,1,10);
% f=inline('sin(y(1))-cos(y(2))','t','y');
% y=abm4(f,0,1,1,10);

function [y t] = abm4(f,a,b,ya,n)
h = (b - a) / n;
h24 = h / 24;

y(1,:) = ya;
t(1) = a;

m = min(3,n);

for i = 1 : m % start-up phase, using Runge-Kutta of order 4
    t(i+1) = t(i) + h;
    s(i,:) = f(t(i), y(i,:));
    s2 = f(t(i) + h / 2, y(i,:) + s(i,:) * h /2);
    s3 = f(t(i) + h / 2, y(i,:) + s2 * h /2);
    s4 = f(t(i+1), y(i,:) + s3 * h);
    y(i+1,:) = y(i,:) + (s(i,:) + s2+s2 + s3+s3 + s4) * h / 6;
end;

for i = m + 1 : n % main phase
    s(i,:) = f(t(i), y(i,:));
    y(i+1,:) = y(i,:) + (55 * s(i,:) - 59 * s(i-1,:) + 37 * s(i-2,:) - 9 * s(i-3,:)) * h24; % predictor
    t(i+1) = t(i) + h;
    y(i+1,:) = y(i,:) + (9 * f(t(i+1), y(i+1,:)) + 19 * s(i,:) - 5 * s(i-1,:) + s(i-2,:)) * h24; % corrector
end;

I'd like to get MAPLE to take this as an input: 1/2+(1/3)*sqrt(2) and give this as an output: (3+2sqrt(2))/6. For the life of me, I can't get it to do that.  I fieel like an idiot; it should be easy.

Dear Maple users,

 

i have a set of 2 Lines: L1 (determined by the intersection of plane x + y -1=0 and plane x - z - 1=0), 

L2 ( intersection of plane x + y-7=0 and plane x-y+1 = 0 ).

which functions or commands of maple should I use "visualize" those 2 lines L1 and L2?

 

thanks for your help,

 

JJ

I have a rational function

R(s)=(s+21.2618806754099918582959684287)*(s+11.5825785765671047665686926962)*(s+2.32652929385663964079968631791)*(s+1.59184930187007023058678840475)*(s+.810126597053864402120805704729)*(s+.767936478999246633196341750975)*(s+.389728032793176474756405528288)*(s+.389709386740696868210134112440)*(s+.384534001672741409749016411776)*(s+.211738661184088496193941380283)*(s+.211735400886327624028116769728)*(s+0.123260440562617421046327062708e-1)*(s+0.749282759458414677904525855939e-2)*(s+0.129947118285955895103018704133e-2)*(s+0.128454333534479589397814117349e-2)*(s+0.342482256507583139104896521750e-3)*(s+0.342471571076865824849860353286e-3)/(s+21.2618806754099918582960530179)*(s+21.1471825573992794470615428324)*(s+2.32652929385663964079964525218)*(s+2.28350165975702233286000082419)*(s+.810126597053864402120855775248)*(s+.804997206582678244211665005890)*(s+.389728032793176474755312749208)*(s+.389718248252695846631246554139)*(s+.384534001672741409750430258543)*(s+.243633167007009257956784127718)*(s+.211735400886327624028133231990)*(s+.211726934369736929202050835884)*(s+0.749282759458414677904914554540e-2)*(s+0.555247691543530827690454070563e-2)*(s+0.128454333534479589395816020810e-2)*(s+0.126961222591792792857168643430e-2)*(s+0.342471571076865824866184397991e-3)*(s+0.342461825593204099734633561207e-3)

I want to cancell the roots which are equal up to 7 digits?

How to write a maple code for this problem?

Hi Mapleprimes community,

 

I am a maple novice and was trying to write a procedure but cannot tell what my syntax error is.  I would greatly appreciate if anyone can point out what I did wrong or any improvement in the code that I can make.  Thanks

SLRrepeatedsample_pr.mw

 

Henry

I am trying to create a procedure that can solve integrals using the Composite Simpson's 3/8 rule. However when I test my procedure against maple's ApproximateInt I am getting the wrong results.

Here is my attempt:

restart;


f:= x -> exp(x)*sin(4*x); # function I am using

simp := proc(a, b, n)
  local h, sum, i, single:
  h := (b-a)/n:
  sum := 0:
  single := (3*h/8) * (f(a) + f(b)): # this is the end points
    for i from a+h by h to b-h do
       sum := sum + (3*h/8) * (3*f(i)):
    end do:
print(evalf(sum + single));
end proc:


simp(0,1,12);
                                                                                0.6224486445
evalf(Student:-Calculus1:-ApproximateInt(f(x), 0..1, method = simpson[3/8], partition=12));

                                                                                0.5323516717

 

As you can see my answer is not very close to the answer given by Maple. I am not sure why my procedure simp is wrong.

Hi there,

I'm quite new to Maple so please forgive me! I have a system of partial differential equations I'm trying to solve in Maple as such below 

 

df/dt = f(1-f) - f * h

dg/dt = g(1-g) * Gradient(1-f * gradient(g))

dh/dt = (g - h) + Laplacian(h),

where f,g,h are functions of space and time (i.e. f(x,y,z,t)). I guess my first question is - is this possible in Maple to evaluate? (I'm currently unsure on ICs as I'm figuring it out from the model - it's a model for cancer growth I'm trying to evaluate but have a rough idea of what I'd use).

If it is possible, can you please share how I'd write this? Everytime I've tried I seem to be failing to define anything properly, so your expertise would be greatly appreciated!

Hello, Please how do I compute cdf of student t distribution in maple Tξ+1(.). I have a function that i nvolves student t distribution but finding it difficult to compute student t in the funcion. I am new to maple.

if ((a.d-b.c)=0) then print([0,0,0,0])
fi;
MARK:=(a,b,c,d)->[d/(a.d-b.c),-b/(a.d-b.c),-c/(a.d-b.c),a/(a.d-b.c)];

2 3 4 5 6 7 8 Last Page 4 of 255