acer

32562 Reputation

29 Badges

20 years, 26 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Are any of these what you had in mind?

f := x-> sum(1/n^2,n=x+1..infinity);
plot(f,1..5);
plots:-pointplot([seq([i,eval(f(i))],i=1..10)]);

But for this case, the sum can be found as a function known to maple, ie. Psi(1,x+1).

fe := sum(1/n^2,n=x+1..infinity) assuming x::posint;
plot(fe,x=1..5);
plots:-pointplot([seq([i,eval(fe,x=i)],i=1..10)]);

I wasn't sure whether you wanted a continuous or a discrete plot. You can create a proc (rather than an arrow operator) with a type attached to the argument (using :: notation), but other than that Maple doesn't easily associate domains with "functions".

acer

What's the domain of interest here? You'll want function f to be 1-1, where you hope to invert it properly.

Let's look at your function,

f := x -> piecewise(
   x<=20,
   100-x-(3/80)*x^2+(3/1600)*x^3-2*x,
   x>=20 and
   x<=fsolve(1495/16-(201/64)*x+(33/1280)*x^2-(3/25600)*x^3=0),
   1495/16-(201/64)*x+(33/1280)*x^2-(3/25600)*x^3);

plot(f,-100..100);
plot(f,-40..10);
Optimization:-Maximize(f,-40..10);

finv := proc(y, highlow := 'high')
global f;
 if highlow = 'high' then
   fsolve(x -> f(x) - y, -17.37 .. 100);
 else
   fsolve(x -> f(x) - y, -100 .. -17.37);
 end if;
end proc:


And so now, using -17.37 the maximal point as the cut-off between high and low ranges for the domain,

> finv(50); f(finv(50));
                                  16.02900152
 
                                  50.00000001
 
> finv(50,low); f(finv(50));
                                 -38.85067771
 
                                  50.00000001

> finv(f(2),high);
                                  2.000000000
 
> finv(f(-20),low);
                                 -20.00000000

acer

>  patmatch((1.330+2.440*x)*exp(-3.660*x),
> (a_num::realcons+b_num::realcons*x)*exp(c_num::realcons*x),
> 'res');
                                     true
 
> res;
                [a_num = 1.330, b_num = 2.440, c_num = -3.660]

You can utilize those values, in res, using 2-argument eval() later on. But if you really want the assignments actually done, then,

> a_num;
                                     a_num
 
> assign(res);
> a_num;
                                     1.330

acer

> E1 := x^2-y = 5:
> E2 := x-y^2 = -13:

> RootFinding:-BivariatePolynomial([rhs(E2)-lhs(E2),rhs(E1)-lhs(E1)],
>                                  [x, y]);

[3.000000000 + 0. I, 4.000000000 - 0. I],
 
    [-2.860805853 - 0. I, 3.184210129 + 0. I],
 
    [1.114907541 - 0. I, -3.756981174 + 0. I],
 
    [-1.254101688 + 0. I, -3.427228955 - 0. I]
 
> RootFinding:-Isolate([rhs(E2)-lhs(E2),rhs(E1)-lhs(E1)],
>                      [x, y]);

[[x = 1.114907541, y = -3.756981174], [x = -1.254101688, y = -3.427228955],
 
    [x = -2.860805853, y = 3.184210129], [x = 3., y = 4.]]

> _EnvExplicit:=true:
> esol := [solve({E2, E1}, {x, y}, AllSolutions)]:
> seq( simplify(eval([E1,E2],esol[i])), i=1..nops(esol) );

[5 = 5, -13 = -13], [5 = 5, -13 = -13], [5 = 5, -13 = -13], [5 = 5, -13 = -13]

acer

Try fsolve(K=S*F^n,F) .

If K and S are known real numeric values and n is a known positive integer then that should return the real solutions as floating-point numbers (which appears to be what you're after).

acer

This is the sort of thing that should be in the Tasks section of the help system.

The closest Task I can find to this is ?Task,EquationOfLineBetweenTwo2DPoints  . And that one is done using the geometry package, so can't serve to instruct anyone in the underlying mathematics. Which is a slight shame.

This below can also be done using `.` for DotProduct and ^%T for Transpose. Or VectorCalculus could be used. I'm not sure which is clearer.

with(LinearAlgebra):
r0 := <0, 4/3, - 5/3>:
 
p1,b1 := <3,1,-1>, 3:
DotProduct(Transpose(<x,y,z>), p1) = b1;
                               3 x + y - z = 3
# zero, only if r0 lies on plane 1
DotProduct(Transpose(p1), r0) - b1;
                                      0
p2,b2 := <1,2,4>, -4:
DotProduct(Transpose(<x,y,z>), p2) = b2;
                             x + 2 y + 4 z = -4
# zero, only if r0 lies on plane 2
DotProduct(Transpose(p2), r0) - b2;
                                      0
# line perpendicular to (p1 and p2) the normals of planes 1 and 2
L := CrossProduct(p1, p2):

# zero, only if L is perpendicular to p1 the normal of plane 1
DotProduct(Transpose(p1), L);
                                      0
# zero, only if L is perpendicular to p2 the normal of plane 2
DotProduct(Transpose(p2), L);
                                      0
# parametric Vector form, one form of the answer
Lpara := r0 + t*L:

# zero, only if any value of parameter t in Lpara makes point lie on plane 1
DotProduct(Transpose(p1), Lpara) - b1;
                                      0
# zero, only if any value of parameter t in Lpara makes point lie on plane 2
DotProduct(Transpose(p2), Lpara) - b2;
                                      0
# parametric form (using x,y, and z notation)
DotProduct(Transpose(<x,y,z>), Lpara, conjugate=false);
                            /4       \     /  5      \
                    6 t x + |- - 13 t| y + |- - + 5 t| z
                            \3       /     \  3      /

acer

The original posting is opaque to me. I went back a few times to try and figure it out.

I didn't understand what M, N, Q and V were supposed to be. There are referenced in the code, but not defined. Are they tables of arrays? Even the purpose of W is not fully clear.

I also didn't understand what was being requested, in the sense of display and columns.

There were a few sentences that I couldn't parse. Eg, "I'm trying to print a nice looking array (6 columns with various numbers of rows) from an array that storing the data with 5 indices." And, "I can print P as a table, but I want it to print with i for the columns 1..6 and the column can just fill up with the entries. "

acer

Do you mean something other than like this?

> den:=a*u*Dirac(u)+b*u*u*Dirac(u)+c*u^(3/2)*Dirac(u)+d*cos(v+Pi/6)*Dirac(v):

> simplify(den);
                                  1/2
                              1/2 3    d Dirac(v)

acer

Something like this?

Ez:=(sigma*z*int(r/((r^2+z^2)^(3/2)),r=0..a))/(2*epsilon0) assuming z::real;
E:=unapply(eval(Ez,[epsilon0=8.854e-12,sigma=1e-6,a=0.1]),z);
plot(E,-5*0.1..5*0.1);
plot(eval(Ez,[epsilon0=8.854e-12,sigma=1e-6,a=0.1]),z=-5*0.1..5*0.1);

acer

That's pretty sophisticated, and wouldn't be easy with only a basic knowledge.

Have a look at the help-page  ?IterativeSolver  which describes how a conjugate gradient solver may be accessed by calling the LinearAlgebra:-LinearSolve routine.

acer

What version of Maple and operating system do you have?

Here's what I get, with Maple 11.02 (Linux),

> v:=Vector([v1, v2, v3, v4, v5]);
                                        [v1]
                                        [  ]
                                        [v2]
                                        [  ]
                                   v := [v3]
                                        [  ]
                                        [v4]
                                        [  ]
                                        [v5]
 
> CodeGeneration[C](v);
cg[0] = v1;
cg[1] = v2;
cg[2] = v3;
cg[3] = v4;
cg[4] = v5;
What precisely were your commands?

acer

You can generate the filenames in a loop as follows, using concatenation.

There are a variety of utilities that can be used to write the data to the file. One such is writedata, but you should also be able to use fopen, fprintf, and fclose directly.

M := matrix([[1.,2.,3.],[4.,5.,6.],[7.,8.,9.]]);

for i to 3 do
  fname := "basename"||i||".txt";
  writedata(fname,M);
  fclose(fname);
end do;

For Matrix (as opposed to matrix) objects you could look at the ExportMatrix routine.

acer

The Statistics:-NonlinearFit routine can achieve this, setting up and solving it as a least squares problem.

Do you just need the answer, or is it a homework exercise for which you are requested to submit all the details?

acer

y := <2,4,8>;
x := <1,4,6>;

sol := Statistics:-NonlinearFit(p*t + q, x, y, t);

Alternatively,

sol2 := CurveFitting:-LeastSquares(x,y,t);
evalf(sol2);

You can then plot them all,

p1:=plots:-pointplot([seq([x[i],y[i]],i=1..3)]):
p2:=plot(sol,t=0..7):
p3 := plot(sol2,t=0..7):
plots:-display([p1,p2,p3]);

acer

The %n values that you see are placeholders for common subexpressions.

That is to say, subexpressions which appear more than once in the output. With them extracted out and displayed in this way the whole result is supposed to be easier to view and understand.

See this blog entry, for some fun details. Also see the labelling and labelwidth entries in the ?interface help-page.

You may see them used in the Classic GUI and the commandline (TTY) interface, but not at present in the Standard GUI. (That's a shame, about the Standard GUI, on the same level as the inability to select and get context-menus for subexpressions in output.)

acer

First 318 319 320 321 322 323 324 Last Page 320 of 338