Carl Love

## 27214 Reputation

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

## linear system...

Just take the ln of both sides of each equation, and you then have a simple system of linear equations.

 > sys:= {2^x*3^y*5^z = 240, 3^x*2^y*5^z = 360,  5^x*3^y*2^z = 1350}, {x,y,z}:
 (**) solve(sys):
 (**) simplify(%);

 (**) evalf(%);

 (**)

## Use codegen:-optimize as workaround...

It seems like the seventh and eighth rows of your Matrix are being converted to lists by CodeGeneration:-Matlab. I have no idea why this is (there are no lists in your input Matrix), but here is a workaround: Change your last command to

Matlab(
subsop([-1,1]= J, eval([codegen:-optimize](tmp, tryhard), pow= `^`)),
output = string, defaulttype = numeric
);

I don't have Matlab to test this, so please let me know how this works for you.

## seq...

y(seq(x[k], k= 1..n))

If x is actually a list, you can do y(x[]).

## consecutive integer bounds...

If you make assumptions such as assume(m>0, m<1), assume(m>2, m<3), etc., that place m between two consecutive integers, then MultiSeries:-multiseries will work.

## One section per slide...

You need to use one section per slide. So, if you have a section that is too long to fit on one slide, then you need to divide it into multiple sections.

## Is n defined?...

Does n have a definite integer value equal to the number of rows of the Matrix? So the Matrix should be n x J. It is probably i rather than j that is causing the problem.

Also, you should use add instead of sum, and then you don't need the quotes on A[i,j]. Use sum for symbolic summation.

If that doesn't fix the problem, then you'll need to post more of the code.

## sum or product...

I think that in general what you are trying to do is impossible. The limit command, unlike int, does not have a procedure option. But if you could rethink your procedure and express it in terms of sum or product then you may be able to use limit.

## x=3, y=13...

 (**) restart:
 (**) eqn:= arctan(x) + arccos(y/sqrt(y^2+1)) - arctan(4):
 (**) f:= numer(simplify(expand(tan(eqn)))) assuming x>=0, y>=0;

 (**) Sol:= [isolve](f);

 (**) remove(hastype, Sol, negative);

I am somewhat skeptical about isolve's ability to return all the solutions. So, investigating further,

 (**) solve(f,x);

 (**) convert(%, parfrac);

Now it is clear that y = 13 is the only positive integer solution.

## 964...

nops([StringTools:-SearchAll("0", sprintf("%d", 2014!))]);

964

## (* ... *)...

Anything between (* and *) is commented out, even if it is multiple lines.

## Adding text with fake multiplication...

Anything can be a ?symbol (a variable's name) in Maple if you enclose it in back quotes (``), aka accent grave. And symbols can be multiplied with `*`. The multiplication appears as simple juxtaposition when it is printed.

Your original expression is not mathematically correct. It should have a factor of "delta x" on the left side of the equation. Putting it all together, we get this:

 (**) f := x-> x^2; a := 0; b := 1; for i to 5 do      print(           `The answer is `*'f'(x[i])*Delta*x           = f(a+i*(b-a)/5)*(b-a)/5      ) end do:

 (**)

## Use unevaluated form, 'f'...

printf (and lprint) produce only 1d output. Perhaps you can acheive what you want by using the unevaluated form of fi.e., by enclosing it in forward single quotes 'f'.

 (**) f := x-> x^2; a := 0; b := 1; for i to 5 do        print('f'(x[i])=f(a+i*(b-a)/5)*(b-a)/5) end do;

 (**)

Is that what you want?

## a(n) = 3*2^(n-1)...

a(0) = 1

a(n) = 3*2^(n-1), n > 0

## final evalhf module to do it...

Here is the final evalhf/module version of your program. It runs in about 7 seconds; so, about a factor-of-8 improvement over the regular version.

Combi:= module()
export
probVector::Vector(realcons),  #probability vector
lambdaVector::Vector(realcons)
;
local
Combi:= proc(
k::integer,
boxContent::Vector,
activeBox::integer,
marblesRemaining::integer,
Output::Matrix,
Index::Vector,
p::Vector
)
local j::integer;

if activeBox < k then
for j from 0 to marblesRemaining do
boxContent[activeBox]:= j;
thisproc(k, boxContent, activeBox+1, marblesRemaining-j, Output, Index, p)
end do
else
boxContent[activeBox]:= marblesRemaining;
Index[1]:= Index[1] + 1;
Output[1, Index[1]]:= n!*mul(p[j]^boxContent[j], j= 1..k)/mul(boxContent[j]!, j= 1..k);
Output[2, Index[1]]:= `if`(
mul(boxContent[j], j= 1..k) = 0,
undefined,
)
end if
end proc,

ModuleApply:= proc(n::posint, k::posint, p::~Vector(realcons))::identical();
local
Index::Vector(realcons), Output::Vector(realcons),
boxContent::Vector(realcons)  #A vector whose i'th entry holds the number of marbles in the i'th box
;
boxContent:= Vector(k, datatype= float[8]);
Output:= Matrix(2, binomial(n+k-1, k-1), datatype= float[8]);
Index:= Vector(1);
evalhf(Combi(k, boxContent, 1, n, Output, Index, p));
probVector:= Output[1, ..];
lambdaVector:= Output[2, ..];
[][]
end proc
;
end module;

A recursive procedure

 (**)
Combi:= module()

## 194785...

 (**) restart:
 (**) d:= proc(s)  option remember;  parse(s)  end proc: d("0"):= 1:
 (**) p:= n-> `*`(map(d, StringTools:-Explode(sprintf("%d", n)))[]):