Carl Love

Carl Love

27306 Reputation

25 Badges

11 years, 364 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

Whenever you use is, you need to consider the possibility that it returns FAIL instead of true or false. If all of the is-es return FAIL or false, then ormap will return FAIL.

foo:= proc(a, {S::list:= []})
    S<>[] and
    S[1]::{1, And(specfunc('typeset'), identical(true) &under (s-> ormap(is, s, 1)))}
end proc:

 

1. First, let's focus on setting up your equations; solving them is relatively unimportant at this point. Solving them symbolically may not be possible, but it also may not be necessary or even useful at all. The final mouse driver will use a compiled numeric solver dedicated to this particular set of equations. Solutions accurate to 3 or 4 significant digits will be sufficient. Maple can be used to produce such compiled code, which will ultimately run independently of Maple (not even requiring the existence of Maple).

From the code that you showed, I'm not convinced that your equations are set up correctly. In my plain human reading of your code, I've noticed several potential problems (some mentioned below). I cannot really check your code until you upload a worksheet.

2. You can upload a Maple worksheet using the green up-arrow on the toolbar of the MaplePrimes editor. If you get a message about the upload having failed, ignore it. That message only means that MaplePrimes cannot display the uploaded worksheet. Almost always the file link is correctly uploaded anyway.

3. Forget about your linearization T; only work with L. An "exact" symbolic solution of a crude symbolic approximation is of very dubious value.

4. This is a description of the main potential error that I see in your code. I will call a variable indexed if it ends with a pair of square brackets ( [...). (Whether there's anything in the square brackets is irrelevant.) So, in your code, p[ni]m[m]s[n]phi[1], ..., phi[3]theta[1], ..., theta[6], etc., are all indexed variables. It is highly error prone to use variables in both indexed and unindxexed forms in the same problem. For example, you use unindexed theta as a variable (it's one of the solution variables) and you assign values to the indexed forms theta[1], etc.

5. I will call a variable subscripted if it contains a double underscore in its name. For example, your p__n is subscripted. Subscripted variables are immune to any of the potential errors that indexed variables can lead to. Note well that I'm not saying that there's anything wrong with using indexed variables; they can be quite useful. The problems may occur when you try to use them simultaneoulsy in both indexed and unindexed form, and especially when some of those have values assigned to them.

Assuming that cornerPoints is an array or matrix with dim = 3 rows and 4 columns, you could also do this, which requires no indexing or dimension references:

plots:-textplot3d(
    [op,`<,>`]~(convert(cornerPoints^%T, listlist)), 
    align= {above, right}, font= [Courier, bold, 20]
);

The absolute value of your final computation is independent of the order of the 4 vectors, so it doesn't matter which one you subtract from the others.

V:= (p,q,r,s)-> abs(LinearAlgebra:-`&x`(p-s, q-s) . (r-s));

proc (p, q, r, s) options operator, arrow; abs(LinearAlgebra:-`&x`(p-s, q-s).(r-s)) end proc

Pts:= ['LinearAlgebra:-RandomVector(3)' $ 4];

[Vector(3, {(1) = -59, (2) = 12, (3) = -62}), Vector(3, {(1) = 72, (2) = 42, (3) = 18}), Vector(3, {(1) = 52, (2) = -13, (3) = 82}), Vector(3, {(1) = 70, (2) = -32, (3) = -1})]

for pts in combinat:-permute(Pts) do V(pts[]) od;

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

851671

 

Download BoxProduct.mw

Your final formula can be simply proved by mathematical induction, without any need for a closed-form algebraic expression for the Fibonacci sequence.

restart:

interface(prompt= ""):

The prroposition to prove:

eval(G(2*n) = G(2*n+1) + G(2*n+2), G= arctan@`/`@F);

arctan(1/F(2*n)) = arctan(1/F(2*n+1))+arctan(1/F(2*n+2))

for positive integers n where F = combinat:-fibonacci.

 

We start by having Maple confirm a fairly well-known identity for a sum of arctangents:

combine(arctan(1/a) + arctan(1/b)) assuming a > 1, b >= 1;

arctan((b+a)/(a*b-1))

So we just need to verify this Fibonacci identity:

1/F(2*n) = subs({a= F(2*n+1), b= F(2*n+2)}, op(%));

1/F(2*n) = (F(2*n+2)+F(2*n+1))/(F(2*n+1)*F(2*n+2)-1)

It'll be easier to work with in polynomial form. This will be the verification goal of mathematical induction:

Goal:= numer((lhs-rhs)(%)) = 0;

-F(2*n)*F(2*n+2)-F(2*n)*F(2*n+1)+F(2*n+1)*F(2*n+2)-1 = 0

To form the induction hypothesis, change n to n-1:

IH:= eval(Goal, n= n-1);

-F(2*n-2)*F(2*n)-F(2*n-2)*F(2*n-1)+F(2*n-1)*F(2*n)-1 = 0

Verify the induction base case:

is(eval(Goal, {n=1, F= combinat:-fibonacci}));

true

And verify the Goal by simplifying with respect to the induction hypothesis and the defining recursive formula for the Fibonacci sequence:

is(simplify(Goal, {IH, seq(F(2*n+k)+F(2*n+k-1) = F(2*n+k+1), k= -1..1)}));

true

 

Download FibonacciAtanIdentity.mw

@C_R Your understanding of (...)(...) is totally correct. The reason that the extra parentheses (as shown by @nm) are necessary is the precedence of Maple's binary infix operators: -> has lower precedence than = (just like has lower precedence than *). See ?operators,precedence.

You can avoid the need for the extra parentheses by replacing x->x with x@@0, which is the identity function. `@@` has higher precedence than =. You could also use 1@@0_@@0, etc.

The multiplication symbol can be easily suppressed:

make_nice:= e-> subs(
    "&lowast;"= "&InvisibleTimes;",   
    InertForm:-Display(evalindets(e, And(`*`, fraction &under curry(op,1)), `%*`@op))
): 

Also, by changing @nm's typespec from `&*`(fraction, anything) to And(`*`, fraction &under curry(op,1)), my procedure can handle products of any number of factors, such as 3/8*ln(x/y)*exp(z).

You just need to add the arrows option to your DEplot3d command. For example, by adding arrows= cheap I get this:

In your display command, remove the options gridlines= true and axes= none, and add the options

axis[1]= [gridlines=17, tickmarks=0], axis[2]= [gridlines= 8, tickmarks=0], view= [0..16, 0..7]

You should get this:

In your Case 2, solve chose (somewhat arbitrarily) two different branches of LambertW, but any branch would work. If you change all instances of solve(...to solve(..., allsolutions), I think you'll understand what's happening. If not, I'll explain further.

First, pick a value of Kr to use. I chose 0.1. Then do

Kr:= 0.1:
F:= [f, Theta, Phi](eta):
Frame:= Inf-> plots:-odeplot(
    dsolve({OdeSys, eval([Cond], 10= Inf)[]}, numeric),
    `[]`~(eta, F), legend= F
):
plots:-animate(Frame, [Inf], Inf= 0.1..10, frames= 50, size= 500*[2,1]); 


 

All you need is 

(A,B):= convert~(Solution, list, nested)[]: print('A'=A, 'B'= B);

6Here's a procedure for it:

#Bins takes a histogram and its data sample and returns a list of "bin-bounds" = count.
Bins:= (
    H::And(specfunc(PLOT), patfunc(specfunc(POLYGONS), anything)),
    S::{rtable,list}(numeric)
)-> 
local `&<`:= curry, `&>`:= rcurry;
    (Statistics:-TallyInto &< S &> _rest @ (op&<[1,1]..op&<[2,1])~)(
        [indets(op(1,H), And(listlist(numeric), 4 &under nops))[]]
    )
:

Applying it to the histogram in your worksheet:

Bins(Q,A);   

[-2.71396014591046 .. -2.66663223217829 = 2, -2.66663223217829 .. -2.61930431844611 = 0, -2.61930431844611 .. -2.57197640471394 = 0, 
-2.57197640471394 .. -2.52464849098177 = 2, -2.52464849098177 .. 2.4773205772496 = 0, -2.4773205772496 .. -2.42999266351743 = 1, -2.42999266351743 .. -2.38266474978526 = 1, -2.38266474978526 .. 
-2.33533683605308 = 2, -2.33533683605308 .. -2.28800892232091 = 1, 
-2.28800892232091 .. -2.24068100858874 = 3, -2.24068100858874 .. 
-2.19335309485657 = 1, -2.19335309485657 .. -2.1460251811244 = 0, 
-2.1460251811244 .. -2.09869726739223 = 4, -2.09869726739223 .. 
-2.05136935366005 = 0, -2.05136935366005 .. -2.00404143992788 = 1, 
-2.00404143992788 .. -1.95671352619571 = 3, -1.95671352619571 .. 
-1.90938561246354 = 5, -1.90938561246354 .. -1.86205769873137 = 2, 
-1.86205769873137 .. -1.8147297849992 = 4, -1.8147297849992 .. 
-1.76740187126702 = 4, -1.76740187126702 .. -1.72007395753485 = 2, 
-1.72007395753485 .. -1.67274604380268 = 3, -1.67274604380268 .. 
-1.62541813007051 = 4, -1.62541813007051 .. -1.57809021633834 = 2, 
-1.57809021633834 .. -1.53076230260617 = 3, -1.53076230260617 .. 
-1.48343438887399 = 5, -1.48343438887399 .. -1.43610647514182 = 7, 
-1.43610647514182 .. -1.38877856140965 = 7, -1.38877856140965 .. 
-1.34145064767748 = 7, -1.34145064767748 .. -1.29412273394531 = 6, 
-1.29412273394531 .. -1.24679482021313 = 4, -1.24679482021313 .. 
-1.19946690648096 = 12, -1.19946690648096 .. -1.15213899274879 = 6, 
-1.15213899274879 .. -1.10481107901662 = 9, -1.10481107901662 .. 
-1.05748316528445 = 6, -1.05748316528445 .. -1.01015525155228 = 13, 
-1.01015525155228 .. -.962827337820104 = 18, -.962827337820104 .. 
-.915499424087933 = 8, -.915499424087933 .. -.868171510355761 = 19, 
-.868171510355761 .. -.820843596623589 = 15, -.820843596623589 .. 
-.773515682891417 = 9, -.773515682891417 .. -.726187769159246 = 15, 
-.726187769159246 .. -.678859855427074 = 17, -.678859855427074 .. 
-.631531941694902 = 11, -.631531941694902 .. -.584204027962731 = 19, 
-.584204027962731 .. -.536876114230559 = 11, -.536876114230559 .. 
-.489548200498387 = 21, -.489548200498387 .. -.442220286766215 = 13, 
-.442220286766215 .. -.394892373034044 = 20, -.394892373034044 .. 
-.347564459301872 = 15, -.347564459301872 .. -.3002365455697 = 24, 
-.3002365455697 .. -.252908631837528 = 12, -.252908631837528 .. 
-.205580718105357 = 21, -.205580718105357 .. -.158252804373185 = 16, 
-.158252804373185 .. -.110924890641013 = 22, -.110924890641013 .. 
-.0635969769088414 = 23, -.0635969769088414 .. -.0162690631766695 = 25, 
-.0162690631766695 .. .0310588505555018 = 14, .0310588505555018 .. 
.0783867642876737 = 18, .0783867642876737 .. .125714678019845 = 22, 
.125714678019845 .. .173042591752017 = 18, .173042591752017 .. .220370505484189
= 19, .220370505484189 .. .267698419216361 = 22, .267698419216361 .. 
.315026332948532 = 14, .315026332948532 .. .362354246680704 = 22, 
.362354246680704 .. .409682160412876 = 10, .409682160412876 .. .457010074145048
= 20, .457010074145048 .. .504337987877219 = 10, .504337987877219 .. 
.551665901609391 = 7, .551665901609391 .. .598993815341563 = 17, 
.598993815341563 .. .646321729073735 = 21, .646321729073735 .. .693649642805906
= 11, .693649642805906 .. .740977556538078 = 15, .740977556538078 .. 
.78830547027025 = 15, .78830547027025 .. .835633384002421 = 12, 
.835633384002421 .. .882961297734593 = 13, .882961297734593 .. .930289211466765
= 13, .930289211466765 .. .977617125198937 = 14, .977617125198937 .. 
1.02494503893111 = 10, 1.02494503893111 .. 1.07227295266328 = 11, 
1.07227295266328 .. 1.11960086639545 = 13, 1.11960086639545 .. 1.16692878012762
= 7, 1.16692878012762 .. 1.2142566938598 = 8, 1.2142566938598 .. 
1.26158460759197 = 7, 1.26158460759197 .. 1.30891252132414 = 13, 
1.30891252132414 .. 1.35624043505631 = 11, 1.35624043505631 .. 1.40356834878848
= 11, 1.40356834878848 .. 1.45089626252065 = 9, 1.45089626252065 .. 
1.49822417625283 = 6, 1.49822417625283 .. 1.545552089985 = 9, 1.545552089985 ..
1.59288000371717 = 6, 1.59288000371717 .. 1.64020791744934 = 9, 
1.64020791744934 .. 1.68753583118151 = 8, 1.68753583118151 .. 1.73486374491368
= 4, 1.73486374491368 .. 1.78219165864586 = 4, 1.78219165864586 .. 
1.82951957237803 = 3, 1.82951957237803 .. 1.8768474861102 = 3, 1.8768474861102
.. 1.92417539984237 = 3, 1.92417539984237 .. 1.97150331357454 = 6, 
1.97150331357454 .. 2.01883122730671 = 6, 2.01883122730671 .. 2.06615914103889
= 4, 2.06615914103889 .. 2.11348705477106 = 1, 2.11348705477106 .. 
2.16081496850323 = 1, 2.16081496850323 .. 2.2081428822354 = 3, 2.2081428822354
.. 2.25547079596757 = 2, 2.25547079596757 .. 2.30279870969975 = 0, 
2.30279870969975 .. 2.35012662343192 = 2, 2.35012662343192 .. 2.39745453716409
= 2, 2.39745453716409 .. 2.44478245089626 = 0, 2.44478245089626 .. 
2.49211036462843 = 0, 2.49211036462843 .. 2.5394382783606 = 1, 2.5394382783606
.. 2.58676619209278 = 1, 2.58676619209278 .. 2.63409410582495 = 1, 
2.63409410582495 .. 2.68142201955712 = 0, 2.68142201955712 .. 2.72874993328929
= 0, 2.72874993328929 .. 2.77607784702146 = 0, 2.77607784702146 .. 
2.82340576075363 = 0, 2.82340576075363 .. 2.87073367448581 = 1, 
2.87073367448581 .. 2.91806158821798 = 0, 2.91806158821798 .. 2.96538950195015
= 1]

You asked:

  • I am unable to add a constraint with if statement.

The if syntax that you were using isn't allowed in 2D Input. Anyway the same thing can be better expressed with max because it'll remain symbolic until the solver supplies values for the variables, whereas an if evaluates immediately.

eq1:= Q2 = max(0, d*h*(x - delta*(alpha+beta)));

  • I have to minimize the function TRC, i am unable to do. 

You need a comma after the I2 = 0..8.

  • Check whether i have represented I1 and I2 with respect to alpha and beta right or wrong.

I think that I'd need substantial background information on the problem to answer that.

Anyway, making the two minor syntax changes that I've given, the solver will at least return an answer, which is a step in the right direction, even though the ensuing discussion indicates that there are still some logic errors to work out.

You've been making the same mistakes over and over, for years now. In your 2D Input, you need to remove any spaces after displaytextplot, and draw. Also, the arguments to display need to be in parentheses, not square brackets, just like all other procedural commands. These are exactly the same problems as the last Question of yours that I Answered.

4 5 6 7 8 9 10 Last Page 6 of 390