kill(all)$
load("lrats")$

optimization ratio M0/P from rocket some parameters. version 1.0
peter.vlasschaert@gmail.com,28/07/2018.

use : number of stages of  'rocket' ,parameters,version 1.0

1e) ratio:(P+M0)/P
===============

p1:(P+M0)/P=product((ε[k]*μ[k])/(1-(1-ε[k])*μ[k]),k,1,n);

2e) v[tot] =total increase of velocity.
==============================

p2:v[tot]-sum(c[k]*log(μ[k]),k,1,n)=0;

rem : 1e) and 2e) from, see above : 'use'

M0:                  Minimizing ( = reduce the 'cost' to construct the rocket)
-------------------------------------------------------------------------------------------------------

=>  P=constant =payload (=sattelite,nuclear warhead)

(M0+P)/P        Minimizing (= reduce the 'cost' to construct the rocket)
------------------------------------------------------------------------------------------------------

How to minimize : 'above ratio' = (P+M0)/P
====================================
====================================

math : lagrange multiplier.

part 1: from 1e
============

p3:log(p1);

p3a:rhs(p3), logexpand=super;

rem :log(x1*x2) =log(x1)+log(x2)
          log(x1/x2) =log(x1)-log(x2)  
-------------------------------------------------
rules : log 

rem : convert : super product  to a sum : log 'operator'

p3b:lhs(p3) = p3a;

rem : rhs 'p3b', function we want to 'minimize'

part 2  : constraint ' total increase velocity' ,from 2e
===========================================

p4:p2;

part 3: lagrange multiplier, λ = multiplier
=================================
G = function to optimize + λ*constraint

find : λ ? 

p5:lhs(p3) = rhs(p3b)+λ*lhs(p4);

p6:expand(p5);

part 4 : differentation expression with respect to μ[k].
============================================

p7:'diff(lhs(p6),μ[k])=diff(rhs(p6),μ[k]);

part 5 : rhs(part4) =0 , find : μ[k]
===========================

a)  algebraic manupulation :
------------------------------------------

p8:rhs(p7) = 0;

to combine sum 'p8'
-------------------------------
1e)  intosum
2e) sumcontract

p9:intosum(p8);

p10:sumcontract(p9);

b)  find :μ[k]
------------------

p11:part(p10,1);
p11a:part(p10,2);

p11b:part(p10,1,1)=p11a;

p11c:solve(p11b,μ[k])[1];

part 6: find :λ ? (use :μ[k] into v[tot])
==============================

p12:p2;

p12a:subst([p11c],p12);

rem : v[tot] = 8 km/s

p12b:part(p12a,1,1) = -part(p12a,1,2);

              simplify model :c,ε,μ
           ====================
           ====================
=================================
c : info for burning time for each stage
ε : structural constant for rocket
=================================

simplify model : c[k] =c,ε[k] =ε,μ[k]=μ
=>   k : stage of the rocket.

part 1:   use 'p11c'
================

p13:subst([c[k] =c,ε[k] =ε,μ[k]=μ],p11c);

part 2:   use 'p12' (total increment of the velocity)
=========================================

p14:subst([c[k] =c,ε[k] =ε,μ[k]=μ],p12);

part 3 : solve for : μ
=================

p15:solve(p14,μ);

part 4: find λ ?  : from 'p15' into 'p13' 
==============================

p16:subst(p15,p13);

p16a:solve(p16,λ);

part 5: 'p16a'  into  'p5'
===================

a) simplified model : lagrange equation  G

p17:subst([c[k] =c,ε[k] =ε,μ[k]=μ],p5);

b) use 'p14' into 'p17'

p17a:subst([p14],p17);

c) find : x= (P+M0)/P

p17b:subst([lhs(p1)=x],p17a);

p17c:solve(p17b,x);

logcontract(%e^(-n*log(ε*μ-μ+1)+n*log(μ)+n*log(ε)));

p17d:lratsubst([x=lhs(p1)],p17c);

p17e:logcontract(p17d)[1];

p17f:radcan(p17e);

d) solve for : M0/P

p17g:solve(p17f,M0)[1];

p17h:factor(p17g);

p17i: p17h/P;

e)   μ from 'p15' into 'p17i'

p18:subst(p15,p17i);

p18a:expand(p18);

f)  values: 
================================
 v[tot] = 8 km/s = 8000 m/s
 I[spc] = 300 s (burning time for stage)
 ε =0.8
 g = 9.81 m^2/s
================================

p19:c= g*I[spc];

p19a:subst([ I[spc] = 300,g=9.81 ],p19);

p19b:[p19a,v[tot]=8000,ε=0.8];

p19c:subst(p19b,p18a);

one stage  rocket : n=1, M0/P
========================

p20:subst([n=1],p19c),float;

rem : impossible one stage rocket

two stage rocket :n=2, M0/P
=======================

p20a:subst([n=2],p19c),float;

three stage rocket :n=3, M0/P
=========================

p20b:subst([n=3],p19c),float;

four stage rocket :n=4, M0/P
========================

p20c:subst([n=4],p19c),float;

fifth stage rocket :n=5, M0/P
=======================

p20d:subst([n=5],p19c),float;

rem : NASA use three stages rockets. (see why 'above')

when  : n => inf  = ∞?
=================

p21:limit(''p19c, n,inf);