# Items tagged with maplemaple Tagged Items Feed

### Write a function that takes an integer and a boole...

5 hours ago
0 1

so we have to Write a maple function with -> that takes an integer N and a boolean function

F: {(i,j) l 0<= i,j<= N} -> {true,false}

and returns a list containing all [i,j] such that F(i,j). A procedure that does this
would be

proc(N,F) local i, j, RV;
RV:=NULL;
for i from 1 to N do for j from 1 to N do
if F(i,j) then RV:=RV,[i,j] ; end if ;
end do ; end do ;
return RV ;
end proc ;

The problem is to do this inline, i.e. you have to write
(i,j)-> ...

### How to solve Bvp...

10 hours ago
1 11

Thank you for your help with this question. I found what I was looking for.

### How to prevent a spurious imaginary factor in solv...

Yesterday at 3:47 PM
0 3

This is one of these silly ones that crop up every-so-often (and yes, beta, gamma are just the relativistic v/c and energy):

gamma=1/sqrt(1-beta^2);
solve(%,beta);

comes up with ±I*sqrt(-gamma^2+1)/gamma.

While this is not wrong it is nothing I want to throw at any student trying hard enough as it is to keep his/her head above water. What I want is beta=sqrt(1-1/gamma^2) and I am having a devil of a time getting Maple to do this. even doing it "by hand" the I comes in the moment I take the sqrt. "assuming" does not help (and when I try ...assuming beta::positive, gamma > 1 I get an error claiming these to be inconsistent).

What gives?

Mac Dude

### How do I generate a 4-D array using a function for...

Yesterday at 5:47 AM
1 1

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

### is there a list or one page that lists all new and...

March 06 2014
3 2

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.

### How to use calculate the roots of a function by bi...

March 05 2014
1 6

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);
 > 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)));
 (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)"]);
 (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];
 >

### Calculating derivatives...

March 05 2014
2 3

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

### Remove the "Clarify Expression" pop-up...

March 04 2014
1 5

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?

### convert Matlab code to Maple...

February 23 2014
0 1

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;

### Combining two fractions with a radical in the nume...

February 23 2014
1 4

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.

### A straight line in 3D...

February 23 2014
1 4

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?

JJ

### How to cancel roots of numerator and denominator w...

February 19 2014
0 5

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?

### Ecountered : Error, unterminated procedure in Mapl...

February 18 2014
2 10

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

### Composite Simpson's 3/8 Rule...

February 18 2014
1 3

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.

 1 2 3 4 5 6 7 Last Page 1 of 252
﻿