Carl Love

Carl Love

27296 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love


(**)

restart:

(**)

d:= proc(s)  option remember;  parse(s)  end proc:
d("0"):= 1:

(**)

p:= n-> `*`(map(d, StringTools:-Explode(sprintf("%d", n)))[]):

(**)

add(p(n), n= 1..2014);

194785

(**)

 


Download product_digits.mw


1.

(**)

restart:

(**)

B:= 2*A:  C:= 4*A:

(**)

solve(A+B+C = Pi, A);

(1/7)*Pi

(**)

A:= %:

By law of sines:

(**)

b:= sin(B)*a/sin(A):  c:= sin(C)*a/sin(A):

(**)

simplify(1/b + 1/c);

1/a

2.

(**)

simplify(cos(A)^2 + cos(B)^2 + cos(C)^2);

5/4

(**)

 


Download Geometry.mw


(**)

x:= 2014!/5^20:

(**)

d:= 0:

(**)

while d=0 do x:= iquo(x,10,'d') end do:

(**)

d;

6

(**)

 


Download 2014.mw


(**)

restart:

(**)

solve(t^2-2016*t-1, t);

1008+1016065^(1/2), 1008-1016065^(1/2)

(**)

lambda:= %[1]:

(**)

x:= proc(n::posint)
option remember;
     floor(lambda*thisproc(n-1))
end proc;
x(0):= 1;

proc (n::posint) option remember; floor(lambda*thisproc(n-1)) end proc

1

(**)

x(2016) mod 2016;

1009

(**)

 


Download 2016.mw


x:= 4/mul(5^(1/2^k)+1, k= 1..4);

4/((5^(1/2)+1)*(5^(1/4)+1)*(5^(1/8)+1)*(5^(1/16)+1))

(**)

rationalize(%);

`[Length of output exceeds limit of 100000]`

(**)

expand(%);

-1+5^(1/16)

(**)

(%+1)^48;

125

(**)

 


Download 125.mw

Here is an example of multivariate Newton's method. I didn't have access to your equations, so I made some random similar examples.


F:= ['randpoly([y[k] $ k= 1..5], degree= 3) +
      randpoly([y[k] $ k= 1..5], degree= 1, dense)'
    $ 5];

[57*y[1]^2*y[3]-49*y[1]*y[2]*y[5]+31*y[2]^3+73*y[2]*y[5]^2-84*y[1]*y[3]+95*y[1]+148*y[2]-29*y[3]+5*y[4]-26*y[5]-51, 80*y[1]*y[2]*y[5]+90*y[1]*y[3]*y[5]-57*y[1]*y[3]+85*y[4]^2+74*y[1]+27*y[2]+9*y[3]-127*y[4]+81*y[5]+70, 36*y[1]^2*y[3]-8*y[2]^3+30*y[2]*y[3]^2-3*y[3]^2*y[5]-56*y[3]*y[4]^2-5*y[2]^2-91*y[1]-70*y[2]+42*y[3]+9*y[4]-21*y[5]-27, 49*y[1]*y[2]*y[4]-58*y[3]^2*y[5]+49*y[3]*y[5]^2-44*y[2]*y[4]-31*y[2]*y[5]+45*y[5]^2+y[1]-95*y[2]+86*y[3]-97*y[4]-14*y[5]+83, 96*y[1]^2*y[3]-51*y[1]*y[2]*y[3]+89*y[1]*y[3]*y[5]+14*y[2]*y[5]^2-79*y[3]*y[4]^2-58*y[1]-95*y[2]+123*y[3]-2*y[4]+86*y[5]+57]

(**)

fsolve(F);

{y[1] = -1.52634660833751, y[2] = 1.14614000845494, y[3] = -0.912884720559115e-1, y[4] = -.156870015505402, y[5] = 0.268564748179879e-1}

(**)

J:= VectorCalculus:-Jacobian(F, [y[k] $ k= 1..5]):

(**)

Y:= <[1$5]>:  #Dummy first iteration.

(**)

Y1:= <[0$5]>:  #Initial guess

(**)

for n to 100 while LinearAlgebra:-Norm(Y-Y1) > 1e-15 do
     Y:= evalf(Y1);
     Y1:= Y - LinearAlgebra:-LinearSolve(
          eval(J, [seq](y[k]= Y[k], k= 1..5)),
          <eval(F, [seq](y[k]= Y[k], k= 1..5))>
     )
end do:

(**)

n;

7

(**)

Y1;

Vector(5, {(1) = -.937327749126478, (2) = .819756118294004, (3) = -0.193900192863524e-1, (4) = .123223922590096, (5) = -.340268950372420})

Note that we obtained a different solution than fsolve. There are multiple solutions.

(**)

eval(F, [seq](y[k]= Y[k], k= 1..5));

[HFloat(1.4210854715202004e-14), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(7.105427357601002e-15)]

(**)

 


Download MVNewton.mw

You asked about solving this system of equations, or one very similar to it, a few days ago here. I thought that I had convinced you to use fsolve instead of an ad hoc method based on the Jacobian.  You even said "It works like magic." So why aren't you using fsolve?

Addressing the length-of-output issue: The message is not an error message. The output still exists in Maple's memory, and you can still work with it; Maple's GUI just won't print it on the screen.

Assuming that you want to implement a Newton's method, you're going about it all wrong. The first rule of numerical linear algebra: Never invert a matrix; always solve a linear system instead.

Please post your worksheet. I don't get any decimal point. I get this:

inttrans[laplace](diff(diff(f(t),t), t), t, s);

Try doing a restart and doing the command again.

In your dsolve command, include the option output= listprocedure. So, you'll have

reseni:= dsolve(..., output= listprocedure):

Then

Reseni:= eval(dvars, reseni):

Now Reseni is a list of procedures, which can be used as a list-valued procedure, returning a list of pure numbers.

Reseni(tend);

restart:
F:= [sin, cos, tan]:
V:= [0, Pi/6, Pi/4, Pi/3]:
M:= Matrix(nops(F), nops(V), (i,j)-> F[i](V[j]));

M1:= < < `F/V`|``|`<|>`(V) >, `<|>`(``$nops(V)+2), < < F >|< [``$nops(F)] >| M > >;

ssid:= Spread:-CreateSpreadsheet();

Spread:-SetMatrix(ssid, M1);

Your problem is that the with command does not work in procedures. In a procedure, the alternative to with is ?uses . In the procedure's declarations, either immediately before or immediately after the locals, put the statement

uses LinearAlgebra, Student:-MultivariateCalculus;

I see that you have some old, deprecated linalg commands in your procedure. You should replace those with equivalent commands from LinearAlgebra. In particular, there's ?LinearAlgebra,GaussianElimination or ?LinearAlgebra,ReducedRowEchelonForm . Column swapping can now be done with simple indexing:

MM:= M1[.., [5,2..4,1]];

How about

A, B:= Matrix(6, symbol= a), Matrix(6, symbol= b);

nops([StringTools:-SearchAll]("5", sprintf(cat("%d"$2013), $(1..2013))));
                              601

plots:-polarplot([cos(t), sin(t)], t= 0..Pi);

Why do you say that the roots are not real? You can't tell until you plug in values for a1, a2, a3, b1, b2, b3. Just because the symbolic solution has an I in it does not mean that the numerical solution will be non-real. For example:

p:= x^3-x^2-2*x+1;
                        3    2          
                       x  - x  - 2 x + 1
fsolve(p);
     -1.24697960371747, 0.445041867912629, 1.80193773580484
solve(p);
                     (1/3)                                   
1 /            (1/2)\                    14               1  
- \-28 + 84 I 3     /      + -------------------------- + -,
6                                                 (1/3)   3  
                               /            (1/2)\           
                             3 \-28 + 84 I 3     /           
                        (1/3)                                    
  1  /            (1/2)\                    7                1   
- -- \-28 + 84 I 3     /      - -------------------------- + - +
  12                                                 (1/3)   3   
                                  /            (1/2)\            
                                3 \-28 + 84 I 3     /            

             /                     (1/3)
  1    (1/2) |1 /            (1/2)\     
  - I 3      |- \-28 + 84 I 3     /     
  2          |6                         
             |                          
             \                          

                               \                          (1/3)
                 14            |    1  /            (1/2)\     
   - --------------------------|, - -- \-28 + 84 I 3     /     
                          (1/3)|    12                         
       /            (1/2)\     |                               
     3 \-28 + 84 I 3     /     /                               

                                                 /  
                 7                1   1    (1/2) |1
   - -------------------------- + - - - I 3      |-
                          (1/3)   3   2          |6
       /            (1/2)\                       |  
     3 \-28 + 84 I 3     /                       \  

                     (1/3)                             \
  /            (1/2)\                    14            |
  \-28 + 84 I 3     /      - --------------------------|
                                                  (1/3)|
                               /            (1/2)\     |
                             3 \-28 + 84 I 3     /     /

First 348 349 350 351 352 353 354 Last Page 350 of 390