192 Reputation

6 Badges

14 years, 346 days

MaplePrimes Activity

These are questions asked by Deadstar

Hey folks I need some help with basic string manipulation.


Say I want to find the sum of the digits of 123


What I've been doing is the loooong way of converting 123 to a string, breaking it up into 3 seperate numbers, converting these back to their decimal value, then adding them up.


How could I make this more efficient? Is there some part of StringTools that would do this for me?



Hey folks, I'll give you the actual problem I'm trying to solve before I show you my code in case anyone can think of a better idea...

Long read but you can ignore the examples and additional info if you don't need it.


Take the doubling map,

f(x) = 2x if 0 <= x <= 1/2

f(x) = 2x - 1 if 1/2 < x <= 1.


Or in maple code, f := x -> piecewise(x<=1/2, 2*x, 2*x - 1):


This looks...

Hey folks I have a question about how to use solutions from fsolve in future calculations without copying and pasting.


Here is the code...


Order := 13:
f := x -> -x + x^2 - x^3 + add(a[i]*x^i,i=4..11):
A := n -> coeff(series(f(f(x)), x), x^n):
fsolve({seq(A(k) = 0, k=5..12)}, {seq(a[j], j=4..11)});


Now this gives values of a[k] from a[4] to a[11] but then if I were to type a[5] in the...

Hey folks. I have a massively complicated equation I'm trying to solve and the internal memory can't take it.


Here is the problem.


Let f(x) := 1 - lambda*x^2

alpha := 1/f(1)


By solving the following equation,


alpha*f(f(x/alpha)) = f(x) + O(x^4)


We can determine a value of lambda and hence alpha (for which the real value is roughly -2.5 and the calculated value here is roughly -2.7).

I'm trying to write a code to find out how many strings of 3 or more same numbers appear in the first 10000 digits of pi. This is what I wrote but I know it's very very inneficient, although it does seem to work I think...

A := NULL:
a := NULL:
for k from 0 to 9997 do
a := [floor(evalf[10000]((10^k)*Pi)) mod 10,
floor(evalf[10000]((10^(k+1))*Pi)) mod 10,
floor(evalf[10000]((10^(k+2))*Pi)) mod 10]:
if a[1]=a[2] and a[1]=a[3] then
A := A+1:
k := k+3
end if:
end do:


1 2 3 4 5 Page 2 of 5