Closey

25 Reputation

3 Badges

2 years, 30 days

MaplePrimes Activity


These are questions asked by Closey

I've got a really bizarre error. In my quite short code, if I do not have the print statement, I get the error message 'Error, (in fib_even_sum) illegal use of an object as a name'. If I do use the print statement, the code runs fine, albeit having printed an unnecessary zero.

Here's the code:

fib_even_sum := proc()::integer:

options threadsafe,autocompile:

uses combinat:

local val := 0, n := 1, FN := 0:

#print(%);

while FN <= 4000000 do:

if type(FN,even) then:

val += FN:

else end if:

++n:

FN := fibonacci(n):

end do:

return val:

end proc:

fib_even_sum();

I can't see what would be making it behave like this; perhaps I'm missing something really obvious?

I'm asking this because I'm sure I'm just missing something.

If I solve a DE with numerics, i.e., dsolve(...,numeric), I get a procedure, say h. I want to answer: if I have a point a that I know, what are the root(s) of h(x) - h(a) = 1? In other words, solve for x.

I thought this would just involve something like fsolve or solve/evalf, or perhaps a root finding package, but I can't figure it out. What I want to avoid is having to write a procedure to hone in on the root myself, since my code is already quite slow.

Any help would be greatly appreciated.

EDIT 1: Here is my MWE (or, what should work in my mind but doesn't). The ODE isn't important, it's just an easy example.

restart;

ode := diff(f(x),x) = f(x);

initial_condition := f(0)=1;

a := 1;

h := dsolve({ode,initial_condition},numeric);

solution := fsolve(h(x) - rhs(h(a)[2]) = 1);

If I have a tensor T[mu,nu,alpha] in 3-dimensions which is symmetric on {mu,nu} and anti-symmetric on {nu,alpha}, then the number of independent components should be zero. However, if I put this into Maple, using Library:-MinimizeTensorComponents followed by Library:-NumberOfIndependentTensorComponents it returns 4.

Any insight into why it does this would be great, thanks.

Page 1 of 1