Carl Love

Carl Love

28095 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

The syntax requires

dsolve({bs} union sys1);

Note that you used {} on sys1 and not on bs. You need to take that into account in your call to dsolve.

But there is a deeper problem. The system cannot be solved for the last constant. You can impose the first five boundary conditions like this:

dsolve({bs[1..5]} union sys1);

This will give you a system with one constant. For now, I leave it to you or someone else to address why it cannot be solved for this constant using your conditions.

This will be easiest to do in the case where the curves in the original are all one color and you want to convert them to all one color. Let's suppose that you want to convert them all to black. Then do

macro(C= ColorTools):
subs(
     indets(P, specfunc(anything, COLOUR))[] =
     COLOUR(RGB, C:-RGB24ToRGB(C:-NameToRGB24("black"))[]),
     P
);

Note carefully that COLOUR is spelled with a U and that ColorTools is spelled without a u (a result of a Canadian identity crisis :-) ).

If you are dealing with a case of multiple colors, something can still be done---let me know.

Use

return fff, ggg;

or

return [fff, ggg];

Use the former if you are prepared to accept multiple outputs. Use the latter if you want to treat the multiple outputs as a single entity.

@jcrose 

First, convert the decimals in your Matrix to exact fractions with

polyGLS:= convert(polyGLS, rational):

Then

RRF:= LinearAlgebra:-ReducedRowEchelonForm(polyGLS);

This command completes in about 4 minutes on my computer, and uses only about 300M of memory. I get the bottom three rows of the matrix going to 0. This can be viewed with

RRF[5..7, ..];

I am using Maple 18. If you are using earlier Maple and cannot duplicate my results, please let me know.

You need to use one more level of unevaluation quotes:

Z2:= ' 'sin(-a*x+b)' ';
subs(sin= cos, Z2);

Another option is to use inert functions. The inert form of a function is obtained by prepending % to the name. For example,

Z2:= %sin(-a*x+b);
Z4:= subs(%sin= %cos, Z2);

When the expression is the way that you want it, use value to change the inert functions to their active forms:

value(Z4);

Change x < y to is(x < y). Or is that still too awkward?

I cannot follow your English, your notation, or your formatting close enough to check your work, your truth tables. However you can easily check them yourself using Maple's Logic package. Example:

with(Logic):
`&->`:= `&implies`:
`&<->`:= `&iff`:
`&^`:= `&and`:
`&v`:= `&or`:

MP:= (A,B)-> B &-> A:
Tautology(MP(p,q) &<-> MP(&not q, &not p));

                                                           true

The corrected version of your procedure returns eval(expr):

f:=proc()
local z,x,expr;
     expr:=3*z;
     z:=solve(x-1=0,x);
     eval(expr)
end proc:

You violated precisely the rule expressed in the paragraph which you thought wasn't in plain English: expr was only evaluated to a single level. You might find this explained more clearly at ?eval . Let me know.

 

You need to follow the anonymous procedure definition with a ( ) to invoke it. Otherwise, the whole procedure definition becomes the return value of the if statement (if that branch is taken). (The body of the if statement is indeed being called in your example.) Example:

f:= proc()
local x:= 9;
     if x < 10 then
          proc()
          local z:= 20;
               x:= z
          end proc
          ()    
     end if;
     x
end proc:

f();                                                    
                                            20

I use this technique fairly often in my code. It is especially useful when you want to execute the inner procedure in the evalhf environment. The () can go right next to the end proc if you want; my style is to place in on its own line to clearly distinguish it from a procedure-as-return-value.

Maple calls them keyword parameters. They are heavily used in library code. See ?parameter_classes . Example:

Foo:= proc({Arg_1::integer:= NULL, Arg_2::float:= NULL})
     Arg_1+Arg_2
end proc:
Foo(Arg_1 = 3, Arg_2 = 0.5);
                                                          
3.5

I don't really the understand the question as posed by your prof, but I do understand what you were trying to do with your code. Here's how to actually do it. Only one command is required.

plots:-contourplot(x^2-2*y^2, x= -5..5, y= -5..5, contours= [seq(C, C= -5..5)]);

What is f:= 1 doing in your code?

If diff(f(x), x) = 1, then f(x) = x. It's a straight line. Then you plot x vs. diff(f(x),x), which is just a horizontal line. Furthermore, it should be plots:-odeplot.

(N,F)-> seq(seq(`if`(F(i,j), [i,j], NULL), j= 1..N), i= 1..N);

To truly make a procedure inline, it should be declared with option inline:

P:= proc(N,F)
option inline, operator, arrow;
      seq(seq(`if`(F(i,j), [i,j], NULL), j= 1..N), i= 1..N)
end proc;

If you want to rewrite the fundamental operators, then you should be studying assembly language or maybe something even lower level than that. There is a relatively small (a few hundred) set of commands in Maple that are called "built in" or "part of the kernel". These are essentially the atoms of Maple programs. There is no point in trying to rewrite them in Maple itself: You'd only be using other atoms. Integer division (iquo) and remainder (irem) are kernel commands.

That being said, a fairly decent alternative to irem can be written as

Irem:= (n,d)-> n - trunc(n/d)*d:

That still uses a kernel procedure, trunc. But note that `*``-`, and `/` are also kernel procedures in Maple:

eval(`*`);

 

I don't know what Excel is doing with the ln(0), but Maple cannot handle it. Attempting ln(0) in Maple gives a division-by-zero error. I don't think that you can trust the Excel result obtained by including the [0,0] data point.

Statistics:-LinearFit is essentially the same as CurveFitting:-LeastSquares except that the former allows access to the summary statistics that can be used to compute R-squared (the coefficient of determination).

restart:
macro(S= Statistics):
X:=  < .5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5 >:
Y:=  < 3.25, 5.82, 7.50, 8.79, 9.83, 10.66, 11.35, 11.94, 12.46 >:
curve:= [1, ln(x)]:
Sol:= S:-LinearFit(curve, X, Y, x, output= solutionmodule):

The solution curve is
add(curve[k]*Sol:-Results(parametervalues)[k], k= 1..nops(curve));

n:= numelems(Y):

The R-squared statistic (coefficient of determination) is
Rsq:= 1 - Sol:-Results(residualsumofsquares)/S:-Variance(Y)/(n-1);

 

First 315 316 317 318 319 320 321 Last Page 317 of 395