kill(all)$

fpprintprec:4$
infix("~=")$

van=facebook.com/LearningCalculus$

TimeAB : DistanceAB / SpeedAB$
TimeBC : DistanceBC / SpeedBC$
TimeCD : DistanceCD / SpeedCD$

TimeTotal : TimeAB + TimeBC + TimeCD;

DistanceTotal : DistanceAB + DistanceBC + DistanceCD;

TimeWeightedSpeed:
(TimeAB/TimeTotal)*SpeedAB+
(TimeBC/TimeTotal)*SpeedBC+
(TimeCD/TimeTotal)*SpeedCD$

DistanceAB : 20 * km$ DistanceBC : 15 * km$ DistanceCD : 10 * km$

''DistanceTotal;

SpeedAB : 5 * km/h$ SpeedBC : 3 * km/h$ SpeedCD : 2 * km/h$

''TimeWeightedSpeed ~= float(''TimeWeightedSpeed);

DistanceWeightedSpeed :
    (DistanceAB/DistanceTotal)*SpeedAB+
    (DistanceBC/DistanceTotal)*SpeedBC+
    (DistanceCD/DistanceTotal)*SpeedCD$

''DistanceWeightedSpeed ~= float(''DistanceWeightedSpeed);