Maple 17 Questions and Posts

These are Posts and Questions associated with the product, Maple 17

Hi

 

I have some data:

Matrix(10, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = .5, (2, 2) = 3.25, (3, 1) = 1.0, (3, 2) = 5.82, (4, 1) = 1.5, (4, 2) = 7.50, (5, 1) = 2.0, (5, 2) = 8.79, (6, 1) = 2.5, (6, 2) = 9.83, (7, 1) = 3.0, (7, 2) = 10.66, (8, 1) = 3.5, (8, 2) = 11.35, (9, 1) = 4.0, (9, 2) = 11.94, (10, 1) = 4.5, (10, 2) = 12.46})

 

I want Maple to make a trendline fitting a Logarithmic function. I can make it output some function with this:

LeastSquares(`<,>`(.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5), `<,>`(3.25, 5.82, 7.50, 8.79, 9.83, 10.66, 11.35, 11.94, 12.46), x, curve = a+b*ln(x))

It outputs:

5.96497783539274+4.25309474196387*ln(x)

 

But please notice, the dataset in the function does not have the first 0 and 0. If i do that:

LeastSquares(`<,>`(0, .5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5), `<,>`(0, 3.25, 5.82, 7.50, 8.79, 9.83, 10.66, 11.35, 11.94, 12.46), x, curve = a+b*ln(x))

It outputs: 

Error, (in Matrix) numeric exception: division by zero

 

Besides that, i need the R-squard value for determinating how well it fits.

 

If i do the same thing i Excel the data set will give a formular: 5.5464ln(x)-0.2175 with a R-sward value of 0.9985.

 

How can i do this i maple?

 

Thanks in Advance!

 

----

Emil Kristensen

A large procedure I made caused me some problems. I finally found the source of the problem.
There seems to be some interaction between the end of parameters marker, $, and the elementwise operation ~.

Consider these 3 versions of essentially the same procedure:

restart;
Q1:=proc(Var::list,$) local n;
  n:=nops(Var);
  print(Var,n);
  proc(var::list)
       subs(Var=~[seq(1..n)],var); #Elementwise
  end proc;
end proc:
Q1([x,y]); #Doesn't work : "invalid expression"
Q2:=proc(Var::list,$) local n;
  n:=nops(Var);
  print(Var,n);
  proc(var::list)
      subs(zip(`=`,Var,[seq(1..n)]),var); # zip
  end proc;
end proc:
Q2([x,y]); #No problem
Q3:=proc(Var::list) local n; #No end of parameters marker $
  n:=nops(Var);
  print(Var,n);
  proc(var::list)
       subs(Var=~[seq(1..n)],var); # Elementwise
  end proc;
end proc:
Q3([x,y]); # No problem
lprint(Q3([x,y])); #Curious output involving ` $`
#A fourth procedure in which the output is not a procedure works:
Q4:=proc(Var::list,$) local n;
  n:=nops(Var);
  print(Var,n);
  subs(Var=~[seq(1..n)],Var)
end proc:
Q4([x,y]);

Does anybody have any comments? Is it a bug?

 

 

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)-> ...

 

please help...

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

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

(a) Design your own 3-stage explicit Runge-Kutta method with one-step error O(h4).

(b) Test your method by solving y= −y. Confirm that the global error in your numerical solution

is O(h3).

How to solve this equation

cos(x)^2+2*x*cos(x)-2*sin(x)+4=0

with

solve(%,x) and evalf(%) ?

I get no solution. Is there any option to force Maple to solve this equation by solve and evalf?


Student[Calculus1]:-NewtonsMetnod(%,x=2) solves the problem.
If I use Series for sin(x) and cos(x) Maple can solve it too.

Thank you

 

restart:

Eq1:=S*diff(f(x,t),x,t)+diff(f(x,t),x)^2-f(x,t)*diff(f(x,t),x$2)=diff(f(x,t),x$3);

BCs := {D[1](f)(0,t)=cos(t), f(0,t)=0,D[1](f)(L,t)=0};

ICs := {f(x,0)=0};

S:=10:L:=5:
smod3:= pdsolve(Eq1,ICs union BCs,numeric,range=0..L);

smod3:-plot(t=0,  color=red):

it seems to me that the problem is due to the mixed bcs. Any way around?

Cheers!

restart:

Eq1:=diff(f(x),x$4)+(f(x)*diff(f(x),x$3)-diff(f(x),x$1)*diff(f(x),x$2))=0;

Eq2:=diff(f2(x),x$2)+f(x)*diff(f2(x),x$1)=0;

bcs:=f(0)=0,(D@@2)(f)(0)=0,f(1)=0,D(f)(1)=1,f2(-1)=0.5,f2(1)=1;

dsolve({Eq1,Eq2,bcs},numeric,output = listprocedure);

Error, (in dsolve/numeric/process_input) boundary conditions specified at too many points: {-1, 0, 1},

can only solve two-point boundary value problems

How to handle such problem using dsolve?

Cheers!

 

 

restart:

lambda1:=(1/(K+2))*(S+sqrt(2*alpha*(K+2)+S^2));

lambda2:=(1/(K+2))*(S-sqrt(2*alpha*(K+2)+S^2));

where K>=0, S (-15, 15) and alpha (-15, 15). While plotting for small values of S and alpha, I get complex roots.

  • How we can avoid the complex roots?
  • Is it possible to impose a condition in plotting? 

    solve(lambda1=lambda2,S);

    solve(lambda1=lambda2,alpha);

    solve(lambda1=lambda2,K);

  • How to single out the range of S and alpha for which we have complex roots?

Thanks

 

count the number of primes less than using an if-then statement.  Implement your code where j goes from 2 to 15. 

im at a loss i need a little nudge in the right direction.

Good afternoon sir.

 

I am working on problems related to functions which require dynamic geometry program or

the Geometers sketch pad. I request to you to kindly suggest me with regard to the above cited query.

 

 

With thanks & Regards

 

M.Anand

Assistant Professor in Mathematics

SR International Institute of Technology,

Hyderabad, Andhra Pradesh, INDIA.

so we have to Write a function that diagonalises a complex (2x2) matrix if possible,  

we need the argument to be a (2x2) matrix say A.   and we need the return value to be a list [a1 ;a2 ;b1;b2] of two complex numbers followed by two 2-vectors such that {b1,b2} is a basis for C^2 and so that  

Ab1 =a1b1 , Ab2=a2b2  if these exist. if not then the function should return an empty list []

also, the thing is that we're not allowed to load any maple packages, we have to do it by hand :'(

thanks <3

 

Hello,

I am new to maple and coding so please bare the amateur coding.

 

I am trying to plot the following function:

 

When tgk < tb then I want it it to point a cross, where tgk and tb are functions that both have x and y values in them.

This is what I have:

My domain is x=-18..18 and range is y=0..12

I want x and y values to be integer values in degrees. And I want all possible combinations to be plotted (e.g (1,1) (1,2) (1.3) etc.) I do not know how to do any of this, but I need it for something I am modeling, and this software was recommended to me.

I am new to Maple and I have never really learned how to code. Any help would be really appreciated!

Thanks

First 37 38 39 40 41 42 43 Last Page 39 of 61