## 610 Reputation

14 years, 256 days

## Simply put you are trying to compute thi...

Simply put you are trying to compute this:

 vars:=a,b;Aexpr:=a*b;f:=unapply(Aexpr,vars);A:=a=.123456789,b=.123456789;B:=map(`@`([proc(r) local k; (rhs-lhs)(r)*k+lhs(r), k, k=0..1 end proc], `@`(op,shake)), subs([A], [vars]));S:=`@`(f,op,map2)(op,1,B),`@`({op},map2)(op,2,B),`@`({op},map2)(op,3,B);minimize(S)..maximize(S);;

## Symbolic-algebraic method:...

 asimplify := proc(Expr, Terms::{list, set}, EliminationTerms::{list, set}, Assumptions::{function, procedure}, Execution::{function, procedure})local X, Zs, Ze, ZS, Ot, Oe, i, T1, Z;    Ot := [op](Terms);    Oe := [op](EliminationTerms);    T1 := {Non}(map(identical, {op}(Oe)));    Zs := [seq(cat(Z, i), i = 1 .. nops(Ot))];    Zs := `@`(assume, op, zip)(Assumptions, Zs, Ot), eval(Zs);    ZS := zip((a, b) -> a = b, Zs, Ot);    Ze := Ot - Zs;    X := frontend(Execution@simplify, [Expr, Ze, map(op, [Oe, Zs])], [T1, {}]);    X := subs(ZS, X)end proc;asimplify(f_minus,[a(t)-b],[a(t)],(n,x)->(n,real),x->simplify(convert(x,signum)));

Please test the above code. Let me know the cases that dont work.

## Use simplify....

 restart:f:=abs(a)*abs(1,a); assume(a,real),simplify(convert(f,signum));

Try the above.

## Similar to this...

posting:
http://www.mapleprimes.com/questions/207267-Coefficients-Of-Differential-Polynomial#comment223370

Try with:

function_coeffs := proc(A, v::set(name))
local S, T;
S := indets(A, {function});
S := select(has, S, v);
T := {Non(map(identical, S))};
frontend(proc(A, S) local V; [coeffs](collect(A, S, distributed), S, 'V'), [V] end proc, [A, S union v], [T, {}])
end proc;

eq := (-Omega^2*a*A[2]-Omega^2*m*B[1]+Omega*A[1]*c[1]+B[1]*k[1])*cos(Omega*t)+(Omega^2*a*B[2]-Omega^2*m*A[1]-Omega*B[1]*c[1]+A[1]*k[1])*sin(Omega*t) = 0;

function_coeffs(lhs(eq),{t});

gives:

[-Omega^2*a*A[2]-Omega^2*m*B[1]+Omega*A[1]*c[1]+B[1]*k[1], Omega^2*a*B[2]-Omega^2*m*A[1]-Omega*B[1]*c[1]+A[1]*k[1]], [cos(Omega*t), sin(Omega*t)]

## Final word....

I think this is safe to use:

restart;
A := a, positive, k, positive, Omega, positive, m, positive, -something - 2, positive; assume(A);
Q := -4*k*m+2*Omega^2*a^2*something+Omega^2*a^2*something^2;
u:=-Omega*a*sqrt(2)*sqrt(-Omega^2*a^2-2*k*m+sqrt(Omega^2*a^2*(Omega^2*a^2+4*k*m)))/(-Omega^2*a^2+sqrt(Omega^2*a^2*(Omega^2*a^2+4*k*m)));

`@`(normal,simplify)(u,[Q],[k,something]);

## Some code....

F1 := proc(S, F) local x, f; f := unapply('hastype'(x, F(map(identical, S))), x); (remove, select)(f, S) end proc;
A := F1(indets(eq, anyfunc(dependent(t))), anyfunc);
subs(seq(A[2][i] = cat(K, i), i = 1 .. nops(A[2])), eq);

## Some code....

restart;
A:=a,positive,k,positive,Omega,positive,m,positive,Z,positive,-1+V,positive;interface(showassumed=0),assume(A);
u:=-Omega*a*sqrt(2)*sqrt(-Omega^2*a^2-2*k*m+sqrt(Omega^2*a^2*(Omega^2*a^2+4*k*m)))/(-Omega^2*a^2+sqrt(Omega^2*a^2*(Omega^2*a^2+4*k*m)));

P := Z^2*Omega^2*a^2-k*m, 1+4*Z^2-V^2;
`@`(factor,simplify)(u,[P],[k,Z,V]); #m works too
`@`(expand,solve)({P},{Z^2,V^2});

## If the first one worked then......

`this should work too:createModule3 := proc(A::Matrix(square))    local dim;    dim := RowDimension(A);    module()        export det;        det := (proc(dim) (x::Matrix(1..dim,1..dim)) -> Determinant(x) end proc)(dim);    end moduleend proc:`
`createModule3(Matrix(2)):-det(IdentityMatrix(2));Does the above work?Arguments to procedures are themselves not variables and in your createModule2 you use dim as variable and not parameter.`

## Solve the ranges first....

restart;
A:=interface(showassumed=0),assume(x,real),factor(ln(sqrt(x-12)/(-x^(2)+15*x)));((expr,var)->solve({`@`(evalc,Re)(expr)>=0,`@`(evalc,Im)(expr)=0},var))(op(1,A),{x});
plot(A,x=12..15,scaling=constrained,axes=boxed,thickness=3);

#Gives
# A := ln(-(x-12)^(1/2)/x/(x-15))
# {x < 15, 12 <= x}

## Objective....

With small expressions it is hard to observe facilities at work.

interface(version);
mf:=unapply('unapply(F(n),n),F,n'):
phi:=(1+sqrt(5))/2:

#   Maple Worksheet Interface, Release 4, IBM INTEL NT, Apr 16 1996

fn:=unapply(1/2*sqrt(-(u-1)*(u+1)*(u^2-u-1))*u*(4*u-3)/sqrt(u*(u-1)),u):
fn2:=assume(u1>1,u1<phi),mf(`@`(factor,combine,simplify,fn),u1):
fn2(u);

Gives:

#1/2*(4*u-3)*(-(u+1)*(u^2-u-1)*u)^(1/2)

## Transform....

Region boundaries, contents of the grey line are excluded:

A0:=log[2*abs(x-a)](abs(x+a)+abs(x-a)) < 1;
A2 := signum((U1 - U2) * (2 * U1 - 1)) = 1;

It can be shown A0 and A2,U2=abs(x+a), U1=abs(x-a) are equivalent.

## Lagrange. (2)...

You may find this useful:

#interface(version);
#Maple Worksheet Interface, Release 4, IBM INTEL NT, Apr 16 1996

LocalExtrema := proc(obj, expre)
local Solutions, Lagrange, Restraint, Other, Equations, Variables, Lambdas, NewNames, n, i, E, V, lambda;
description `Looks for local extrema of obj, subject of restraint of expre, using Lagrange multiplier method. Returns [Solutions], [obj, Lagrange Function], [Restraint, Lagrange Equations, Other], [Variables, Lambdas, New Names].`;
if type(expre, {list, set}) then E := ([op]@{op})(expre) else E := [expre] fi;
Restraint := `@`({op}, map)(op, {remove(type, E, {relation, logical}), map(lhs - rhs, select(type, E, equation))});
n := nops(Restraint);
Other := `@`({op}, remove)(member, E, select(type, E, {equation, Non({relation, logical})}));
Lagrange := obj + add(lambda[i]*Restraint[i], i = 1 .. n);
Variables := select(type, {args[3 .. -1]}, name);
Lambdas := {seq(lambda[i], i = 1 .. n)};
Equations := map2(diff = 0, Lagrange, Variables);
Solutions := traperror(solve(Equations union Restraint union Other, Lambdas union Variables));
if lasterror = Solutions then lasterror
else
NewNames := indets({Solutions}, name) minus indets({constants, Restraint, Other, Variables, Lambdas, Equations}, name);
[op]({Solutions}), [obj, Lagrange], [Restraint, Equations, Other], [Variables, Lambdas, NewNames]
fi
end:

_EnvExplicit:=true;
A:=LocalExtrema(x^3+y^3+z^3,{x^2+y^2+z^2-1,x>0},x,y,z):
P:=map(subs,A[1],[[x,y,z],(x^3+y^3+z^3)]);
map(print,[A]):

## Practice....

References for your question are too numerous.

Some code:

#interface(version);
# Maple Worksheet Interface, Release 4, IBM INTEL NT, Apr 16 1996

Collatz := proc(x) local m, n; option remember; m := iquo(x, 2, 'n'); if n = 0 then m else 6*m + 4 fi end;
CollatzSeq := proc(x, q)
local y, t;
option remember;
y := x; t := x; while 1 < t do t := Collatz(t); y := y, t od; if q then procname(x, false) := t; y else procname(x, true) := y; t fi
end;

L:=[\$1..60];
map(CollatzSeq, L, false);
type(map(CollatzSeq, L, false), list(1));
#map([CollatzSeq], L, true);
`@`(sort, [op], map)(CollatzSeq, {op}(L), true);

## If all else fails then......

#interface(version);
#   Maple Worksheet Interface, Release 4, IBM INTEL NT, Apr 16 1996

assume(n, positive);
A:=3^(-(1/2)*n)*2^((1/6)*n)-2^((2/3)*n)*6^(-(1/2)*n):
simplify(A);

#if all else fails:
Q:=select(`@`(evalb,proc(base,exponent) is(base,positive)=true and is(exponent,real)=true end,op),indets(A,anything^anything));
if is(n,real) then
Q:=select(type,Q,anything^linear(n));
fi;
A2:=subs(SQ,A);
simplify(A=A2);

## Compose....

Try with:

F:=piecewise(x>=0 and x <= 1, x^2,x > 1 and x<=2, (2-x)^2);
f:=unapply(F,x);
P:=2*frac(x/2);
p:=(expand@unapply)(P,x);
plot(f,0..2,scaling=constrained);
plot(p,0..8,scaling=constrained);
plot(f@p,0..8,scaling=constrained);
Q:=unapply('q*(frac@((x->x)/q)),q');
p:=Q(2);
plot(f@p,0..8,scaling=constrained,color=blue);
plot([f@Q(2),f@Q(4)],0 .. 8,color = [khaki, black],thickness = [3, 0],numpoints = 101,axes=boxed,scaling=constrained);

 First 7 8 9 10 Page 9 of 10
﻿