eq1 := x^2+y^2+z^2=1:
eq2 := z=y:
# Now substitute eq2 into eq1.
neweq := eval(eq1,{eq2});
# You want a parametrization that has x=cos(t).
# But that forces what y (and z) must be. You can
# ask maple to solve for the y, after the
# substitution of x=cos(t).
eq_subsforx := eval(neweq,x=cos(t));
solve(eq_subsforx,y);
# Check, by substitution.
eval(neweq,{x=cos(t),y=sin(t)*sqrt(2)/2});
eval(eq1,{x=cos(t),y=sin(t)*sqrt(2)/2,z=sin(t)/sqrt(2)});
# Plots are another way to examine the results.
p1 := plots[implicitplot3d](eq1,x=-1..1,y=-1..1,z=-1..1,style=surface):
p2 := plots[implicitplot3d](eq2,x=-1..1,y=-1..1,z=-1..1,style=surface):
p3 := plots[intersectplot](eq1,eq2,x=-1..1,y=-1..1,z=-1..1):
plots[display]([p1,p2,p3],axes=boxed);
plots[spacecurve]([cos(t),sin(t)*sqrt(2)/2,sin(t)/sqrt(2),t=-0..2*Pi],axes=boxed);
acer
The copy() command should produce a copy of an Array along with the indexing function.
Eg, simply,
B := copy(A);
That should work for Array, Matrix, or Vector. It should also reproduce 'storage' and 'order'. The only thing that it does not reproduce, I believe, is the attribute readonly (which makes sense, to me, as I can't see why one would ever want two identical readonly objects).
acer
Did you mean to write,
Maximize(Payoff(Q, sval, pval, paval))
instead of,
Maximize(Payoff(Q, s*val, pval, paval))
Also, why go to the expense of defining procedure Payoff each time that Qopt2 is called? Actually, why use a procedure for the payoff altogether, instead of an expression?
I'm thinking that you could do it something more like this,
Payoff := proc(Q, s, p, pa)
1 - 1/24*s^3 - 1/2*s*min(1, Q + 1/2*s)^2 + 1/4*s^2*min(1, Q + 1/2*s)
- 1/3*min(1, Q + 1/2*pa)^3 + 1/3*min(1, Q + 1/2*s)^3
+ Q*min(1, Q + 1/2*pa)^2 - Q*min(1, Q + 1/2*s)^2
- Q^2*min(1, Q + 1/2*pa) + Q^2*min(1, Q + 1/2*s)
+ s*Q*min(1, Q + 1/2*s) - 1/2*pa + 1/2*pa*min(1, Q + 1/2*pa)^2
+ 1/4*pa^2 - 1/4*pa^2*min(1, Q + 1/2*pa) - s*Q + pa*Q
- pa*Q*min(1, Q + 1/2*pa) - p*Q;
end proc:
Payoffeq:=Payoff(Q, s, p, pa);
Qopt2 := proc(sval, pval, paval)
local eq, result;
global Payoffeq;
if not type({args},'set'(numeric)) then
return 'procname'('args');
end if;
eq := subs({s=sval,p=pval,pa=paval},Payoffeq);
result := Optimization:-Maximize(eq,Q=0..1);
if type(result,'list'({numeric,list})) then
return result[1];
else
return 'procname'(args);
end if;
end proc:
Qopt2(.2, 0.1e-1, 1);
plot('Qopt2'(s, 0.1e-1, 1),s=0.1..0.5);
You'd want to check that I didn't make any mistakes above, that the fornulae match, and that the results make sense, etc.
The results I get differ from yours, even when using Q_opt() on just single points and not plotting it. So, let's look at what the Payoff looks like for a particular set of the parameters.
plot(subs({s=0.2,p=0.1e-1,pa=1},Payoffeq),Q=0..2);
For those values, I see a maximum at just over 0.9. And that seems to agree with the procedures I've shown here, and not with Q_opt(.2, 0.1e-1, 1) which returned 0.7911 for me.
acer
Consider the slightly different call,
plot([Q_opt(0.1,0.01,0.5),Q_opt(0.2,0.01,0.5),Q_opt(0.3,0.01,0.5),Q_opt(0.4,0.01,0.5)],s=0..0.5,legend=["Actual value s=0.1","Actual value s=0.2","Actual value s=0.3","Actual value s=0.4"]);
Does it come out the same?
acer
Rewrite both fractions with a denominator of 18*19.
1/19 = (1/19)*1 = (1/19)*(18/18) = (1*18)/(19*18)
-5/18 = (-5/18)*1 = (-5/18)*(19/19) = (-5*19)/(18*19)
( 1*18 -5*19 )/(18*19)
acer
You can get input such as the greek letters to be typeset in 2D by using the command completion facility. This facility allows you to get a name completed by maple.
In Linux, command completion is accomplished by simultaneously pressing Ctrl-Shift-Spacebar.
For example, if I am in 2D Math input mode, and I type,
alph
then the partial input word underway (alph) will complete to the nice 2D typset greek letter alpha. It also seems to work just when the word's last letter has already been immediately entered by me (ie. when the font changes from italic to normal).
acer
All those 80 x[i] are strings, not numbers. So sum() can't add them up.
Try putting a parse() around the x[i_4]'s and x{i_5]'s, or use fscanf to read floats instead. There should be several ways to do it.
Also, you might help yourself if you use add() instead of sum() for simply adding up sums. (I suppose it may have come out of a palette.) And for this sort of work, and for learning programming in the Maple language, you might try 1D Maple input instead of 2D Math input, and Worksheet instead of Document.
acer
The help-page ?separator may provide some explanation.
acer
See the help-page ?Task,EquationOfLineBetweenTwo2DPoints
Or, run the command,
Student[Precalculus][LineTutor]();
acer
How many times do we have to see submitters' getting caught up with the less-than symbol, before the mapleprimes maintainers switch the default Input format to plaintext?
Most submitters are not using marked-up input. It's the new submitters who pay most here. The old hands would know better, if by default they had to toggle on Filtered HTML as the Input format.
acer
While it may require an extra step to use, mint may also assist with locating syntax errors.
On the one hand it may take an extra step to invoke, be that as a separate shell command or as use of a vi/emacs macro.
But I mention mint because it can do so much more, to help author large maple sources, and because not every user out there will have heard of it. I have always supposed that its name is a joke on `lint` (for C).
On Unix at least, mint is a program than sits in the bin.ZZZ directory alongside the `maple` and `xmaple` scripts. It has a help-page accessible within maple itself. It also comes with a man-page on Unix.
It can do a lot more than simple syntax checking, including reporting on undeclared locals, globals, dead code sections, and lots of other good stuff. The level of reporting can be fine-tuned, via options.
I find that mint is especially good for finding some sorts of coding mistakes that, while not syntax errors per se, can still come back and bite in unexpected ways.
While I'm showing my preference for the commandline Maple interface for managing larger programming jobs, I can also point out the very nice $include and $define directives. I have seen $include used both for module source layout (each local procedure gets its own $include in the module source defn file) and for injecting common code fragments.
acer
Let's try to create a customized refinement of the Atomic system of units, in which energy is simplified and displayed by default to keV, length to cm, area to cm^2, and volume to cm^3.
Units:-AddSystem(customAtomic,Units:-GetSystem(Atomic),cm,cm^2,cm^3,keV);
Units:-UseSystem(customAtomic);
Now to try and test that,
simplify(3.0*Unit(g)*Unit(mm)^2/Unit(s^2));
with(Units[Standard]):
T:=3.0*Unit(g)*Unit(mm)^2/Unit(s^2);
T/(1.1*3.0*Unit(g)*Unit(mm)/Unit(s^2));
T/(1.1*3.0*Unit(g)/Unit(s^2));
T/(1.1*3.0*Unit(g)*Unit(mm^(-1))/Unit(s^2));
acer
You're calling int() with the wrong syntax.
It should be,
int((4*x-3)^3, x);
and not,
int((4*x-3)^3, dx);
Using the correct syntax, you should get the right answer straight away.
If you'd like to try the change of variables anyway, just for fun, it can be done as follows.
First, step by step,
P:=Int((4*x-3)^3, x);
Pu:=student[changevar](u=4*x-3,P,u);
pu:=value(Pu);
eval(pu,u=4*x-3);
Or, in one single line,
eval(value(student[changevar](4*x-3=u,Int((4*x-3)^3, x),u)),u=4*x-3);
acer
This raises several interesting questions.
How can one create a variable which gets dislayed with a long overbar as 2D Math input but which does not have any of the mathematical meaning of conjugation?
It should be clear that sometimes one will want both foo and \overbar{foo} without a relationship between them of conjugation. One approach is to convert the input object, which underneath the hood is actually conjugate(foo), into a unique variable with no relationship or mathematical connection to variable foo. This can be done inplace on the input using the context-menu choice 2-D Math -> Convert To -> Atomic Identifier.
Does the conversion to atomic identifier (unique variable name, independent of name foo) need to be done each time the variable is entered as input? Apparently it usually does. Copy & paste of overbar output wipes out the atomic identifier aspect, getting back to conjugate().
Programmatically, one can also enter something like `#mover(mi("foo"),mi("_"))` to get a unique name, independent of name foo, which gets displayed as output with an overbar. This is not as nice as LaTeX syntax. Also, how can one use this to get an atomic identifier which gets actually typeset as foo overbar for input?
Notice the two Layout palette entries whose hover-over bubble help are "over" and "over2". The first produces a conjugate() object. The second entry, "over2" can sometimes produce an atomic identifier, it seems. So, I tried using the "over2" entry. For the upper part, entering a minus sign, ie. - , produced something with an unfortunately short bar. After selecting palette entry over2 I also tried the keystrokes,
foo\_
but this just produced an object which was conjugate(foo) in nature and also showing with the short overbar as input.
Wouldn't it be more appropriate if the "over" entry instead had bubble help stating "conjugate", and if the "over2" entry instead had bubble help something like "overliteral".
I couldn't find a way to get a long bar for the 2D Math input, as there can be for the 2D output of the same object. Is there a way?
How can one discern whether a 2D typeset object (input and output) is an atomic identifier or an instance of conjugate()? Is there something easier than lprint?
Maple 11.00, Linux.
acer
It should be possible to "fix up" the pie chart after the fact, using Maple itself. The pie chart gets created as just another PLOT structure, and hence should be subject to programmatic manipulation.
For example,
restart:
with(Statistics):
p:=PieChart([Wales = 40, Unknown = 56, GB = 341, E = 237, RUS = 31, D = 93, F = 91, IRL = 39, S = 35, Other = 244], color = orange .. green):
newp:=subsindets(p,specfunc({list,identical("Wales")},TEXT),f->subsop([1][1]=[op(1,f)[1]+0.5,op(1,f)[2]],f)):
plots[display](newp);
It should be possible to construct a maple procedure that moves all the captions away from the centre and outside the unit circle. One could likely make such a procedure reusable, for other pie charts.
acer