Adri van der Meer

Adri vanderMeer

1405 Reputation

19 Badges

19 years, 208 days
University of Twente (retired)
Enschede, Netherlands

My "website" consists of a Maple Manual in Dutch

MaplePrimes Activity


These are replies submitted by Adri van der Meer

@kfli Use

type(R2,Matrix);
                              true
R2[1,1];
                               44

 

@waseem What is the question? Do you mean something like:

restart; with(plots):
f := x -> x+1:
pp := pointplot( [seq([x,f(x)],x=0..10)], symbol=solidcircle, symbolsize=20, color=red ):
pl := plot( f, 0..10, thickness=2, color=red ):
display( {pp,pl}, view=[0..11,0..11] );

 

@Adam Ledger In the command remove(f,L), f must be a boolean-valued procedure.

@Adri van der Meer This procedure doesn't work properly if the polynom has coefficients of the form -c.
So I made a correction:

restart;

pol := q^3-a*q^2+b*q^2-5-c*q^4;

-c*q^4-a*q^2+b*q^2+q^3-5

(1)

coeffs(pol,q);

-c, 1, -a+b, -5

(2)

map(op,[coeffs(pol,q)]);

[-1, c, 1, -a, b, -5]

(3)

# op(-c) is -1,c. Only sums have to be splitted:

nplus := x -> if type(x,`+`) then op(x) else x end if:

cs :=map(nplus,[coeffs(pol,q)]);

[-c, 1, -a, b, -5]

(4)

remove(type,cs,'numeric'): cs1 := %=~1;

[-c = 1, -a = 1, b = 1]

(5)

subs(cs1,pol): newpol := subs(-~cs1,%);

q^4+q^3+2*q^2-5

(6)

 

Download UnitRoots.mw

@carriewong For example, if z takes values in the square -2-2i (bottom left) to 2+2i (top right):

conformal(I*sqrt(z),z=-2-2*I..2+2*I,grid=[8,8],numxy=[50,50]);

@Axel Vogt If F is defined by "->", the right hand side stays unevaluated until it is called as F(x). So, when f changes after the definition of F, F changes too. If "unapply" is used, the right hand side is evaluated, so changing the definition of f has no effect on F.

f := x -> x;

proc (x) options operator, arrow; x end proc

(1)

F1 := x -> int( f(X), X=0..x );

proc (x) options operator, arrow; int(f(X), X = 0 .. x) end proc

(2)

F1(x);

(1/2)*x^2

(3)

F2 := unapply( int( f(X), X=0..x ), x );

proc (x) options operator, arrow; (1/2)*x^2 end proc

(4)

f := x -> sin(x)*cos(x):

F1(x);

(1/2)*sin(x)^2

(5)

F2(x);

(1/2)*x^2

(6)

 

 

@H-R My second suggestion is meant for the general case, where x(t), y(t) are the coordinate functions. There is, of course, no need to calculate the tangent vector: just make an arrow from one point on the curve to another.

x,y := t->cos(t), t->sin(t):
p1 := plot([x(t),y(t),t=0..2*Pi] ):
p2 := plottools:-arrow( [x(Pi/4),y(Pi/4)],[x(Pi/4+0.05),y(Pi/4+0.05)], 0.03,0.05,1 ):
plots:-display( {p1,p2} );

@AngelaRURU Perhaps it resides in the startupcode? Ctrl+Shift+E

@vahid65 See my previous answer.

Note that you solve for x in the command c := solve(...), and assign the result to the variable c.
so you have to apply the condition to x, i.e. solve simultaneously one equation:
limit( (f(x+h)-f(x))/h, h=0 )= (f(b)-f(a))/(b-a),
and two inequations:
x>a, x<b

now the answer comes in the form:
{x=...}

and to assign this value to te variable c:
c := subs(%,x);

Try to find out what to do if there are more solutions in the interval (a,b).
Hint: [solve( ... )] and use subs~(...), see ?Element-wise Operators

@farzane you need the second operand of the second element of the output:

op(2,plottools:-getdata(p)[2,2]);
                      1.81963128310659839

@asa12 use a parametrization for the surface:

plot3d( [0,y,z], y=0..1, z=0..1, axes=normal );

for example this question     .

@shadi1386 Apply LeastSquares to the logarithm of the dependent variable:

XYlist := zip( (x,y) -> [x,ln(y)], xlist,flist):
p1 := plot(XYlist):
with(CurveFitting):
LS := LeastSquares( XYlist, x, curve=add(a[i]*x^i, i=0..7) );
p2 := plot( LS, x=0..1 ):
plots:-display( {p1,p2} );

@shadi1386 If you (only) want to calculate the integral, the data are so detailed that a straightforward Riemannsum (like my answer of sept 28) will give a good result. But if the purpose is a single formula that fits the data, then use CurveFitting:-LeastSquares

@Markiyan Hirnyk Right! I forgot an expand in nops (answer corrected). Of course a procedure is more elegant (like Stephen Forrest did).

1 2 3 4 5 6 7 Last Page 1 of 11