Carl Love

Carl Love

28110 Reputation

25 Badges

13 years, 119 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

In your first line of NEUZMinus,

NEUZMinus:= proc(Unten, Oben, f,G,Liste,n)::real;

the ::real is what I call a return-value type assertion[*1]. It needs to be terminated with a semicolon, which you have. The semicolon terminates the assertion itself; it's purpose is not to terminate the proc(...), which needs no terminator. However, your first line of Basenweschel

Basenwechsel:=proc(Dividend, m);

is incorrect because of the semicolon without a type assertion. It is only a coincidence that this particular procedure is syntactically accepable in Maple 2020; it would be incorrect if there were any declarations other than local on the next line, even in 2020.

[*1] There is no stock type named real; instead, real is a property. If you want to include a type assertion, you should make it realcons. Type assertions other than of procedure parameters are only checked if you set kernelopts(assertlevel= 2).

 

Your problem has nothing to do with the Task programming model. If you use lists and nops, then nops(L) is always a valid index of list L. The same is not always true of a 1-dimensional Array and rtable_num_elems if the Array starts at an index other than 1. The command lowerbound(A) is threadsafe and will return the first index of A.

The command coeffs has a long-standing flaw that it's awkward to match monomials to their coefficients. The following procedure corrects that:

Coeffs:= proc(f, V::{set,list}(name))
local C, t;
    C:= coeffs(f, V, t);
    table(sparse, [t]=~[C])
end proc
:
F:= 2*x+6*y+4*x^2+12*x*y-5*y^2:
C:= Coeffs(F, [x,y]):
C[x], C[x^2], C[x*y];
                            2, 4, 12

 

Here's a start:

EvalPts:= proc(
    a::algebraic, h::algebraic, n::posint, 
    {method::identical(left, right, midpoint):= right}
)
local x:= a-(if method='left' then h elif method='midpoint' then h/2 else 0 fi);
    [to n do x+= h od]
end proc
:
RiemannSum:= proc(
    f, intv::name=range, n::posint, 
    {
        method::identical(left, right, midpoint):= right, 
        output::identical(value, plot):= value
    }
)
local 
    a:= lhs(rhs(intv)), b:= rhs(rhs(intv)), h:= (b-a)/n,
    E:= EvalPts(a, h, n, ':-method'= method), F:= eval~(f, lhs(intv)=~ E),
    X:= [a, EvalPts(a, h, n)[]]
;
    if output='value' then return h*add(F) fi;
    plot(
        [f, [seq]([[X[k],0],[X[k],F[k]],[X[k+1],F[k]],[X[k+1],0]][], k= 1..n)],
        intv, color= [red, gray],
        caption= typeset( 
            "The ", method, " Riemann sum for ", f, " on ", intv,
            " using ", n, " evaluations is ", evalf(h*add(F)). "."
        )
    )
end proc
:
RiemannSum(1/(1+x^2), x= -2..2, 9);
                           1101459956
                           ----------
                           498612465 

evalf(%);
                          2.209050181

RiemannSum(1/(1+x^2), x= -2..2, 9, method= midpoint, output= plot);

Like this

<xl12, xl13, xl23> =~ 
   LinearAlgebra:-LinearSolve(<1,1,-1; 1,-1,1; -1,1,1>/2, <X1,X2,X3>)
;
 

You almost had it. You defined RHS but you didn't use it in the plot. You used sys instead. You also have a typo in the bounds for y1.

You only need 1 loop. I can't even conceive of using two.

Edit: Upon further thought, I do see that two nested loops could be used: The outer loop checks convergence conditions, and the inner loop does the updating of the solution vector. 

You need a multiplication sign after the first x. A space may also work, but I prefer an explicit sign.

Simple solve works:

solve(abs(x^2-3*x) + 4*x - 6, x);
              1, -3 

Or are you looking for a way to solve it "by hand" that doesn't involve breaking it into two cases? I don't think that there's any better way. It is the way that I teach it.

Indeed, there is a package named Student:-VectorCalculus, but it's not needed to create vector-valued functions. No package is needed. For example,

Helix:= t-> <cos(t), sin(t), t>

is a vector-valued function.

Simply

ColorTools:-NearestNamedColor~(c);

Surely something like that must've occurred to you?

The order of a permutation is the least common multiple of the lengths of its orbits. So, the order of the permutation that you show is 3. The order of the permutation from your last question is 20. 

If the order is o, then P^e = P^(e mod o).

The mathematical constant that you have as "pi" is spelled Pi (with uppercase P) in Maple. Once you make this correction, the pdetest will take an extremely long time (20 minutes or so), and will not provide a very useful answer (it'll have an unevaluated limit).

You can remove the inequalities and filter the solutions like this:

select(type, eval~(' '[x,y]' ',  {isolve}({x^2+y^2 = 29})), list(posint));

Or, for this specific problem, you could use a dedicated command:

NumberTheory:-SumOfSquares(29);

You've defined the expression to be plotted as

Bst:= [some long expression, 0]

What do you mean by that? I'm pretty sure that Maple's interpretation of what that means---a list of two separate algebraic expressions---is not what you intended it to mean.

First 101 102 103 104 105 106 107 Last Page 103 of 395