Each answer here was worked out by hand, without RatMath, before the RatMath code was written. Where the arithmetic is long, the working says how it was checked.
1.A linear program
Maximise 3x+5y subject to x≤4, 2y≤12, 3x+2y≤18, x,y≥0.
Answer
The corners are (0,0),(4,0),(4,3),(2,6),(0,6) with values 0,12,27,36,30: the maximum is 36 at (2,6).
2.Shadow prices
For the same program, find the dual solution (shadow prices) and check that the dual value equals 36.
Answer
At (2,6) the second and third constraints are tight. Solving y1⋅1+3y3=3, 2y2+2y3=5 with y1=0 gives y=(0,23,1); 4⋅0+12⋅23+18⋅1=36.
3.Minimising
Minimise 3x+2y subject to x+y≥4, x+3y≥6, x,y≥0.
Answer
The corners are (6,0),(3,1),(0,4) with values 18,11,8: the minimum is 8 at (0,4).
4.Infeasibility
Show that x+y≤1, x+y≥2, x,y≥0 has no solution.
Answer
Adding the first inequality to the negative of the second gives 0≤−1.
5.Unboundedness
Show that maximising x+y subject to x−y≤1, x,y≥0 is unbounded.
Answer
Along (0,t) every constraint holds and x+y=t grows without bound.
6.Integer programming
Maximise 5x+4y subject to 6x+4y≤24, x+2y≤6, x,y≥0 integers. Compare with the LP relaxation.
Answer
The relaxation peaks at (3,23) with value 21. Among integer points, (4,0) gives 20, (3,1) 19, (2,2) 18: the integer optimum is 20 at (4,0).
7.Knapsack
Items weigh 2, 3, 4, 5 and are worth 3, 4, 5, 6. Which should go in a knapsack holding weight 5?
Answer
The pairs within weight 5: only {1,2} (weight 5, worth 7); single items are worth at most 6. Take items 1 and 2, worth 7.
8.Assignment problem
Assign four workers to four jobs at least total cost, with costs 9657248673198784.
Answer
By the Hungarian method: worker 1 → job 2, 2 → 1, 3 → 3, 4 → 4, cost 2+6+1+4=13.
9.Transportation problem
Two warehouses hold 20 and 30 units; three stores need 10, 25 and 15. Shipping costs per unit are (896121013). Find the cheapest plan's cost.
Answer
Warehouse 1 sends 20 to store 2; warehouse 2 sends 10, 5, 15. Cost 120+90+60+195=465 (checked by the stepping-stone test: every unused route has nonnegative reduced cost).
10.Optimising a rectangle
A rectangle has perimeter 20. What is the largest area it can have?
Answer
With sides x and 10−x, A=x(10−x) is largest at x=5: area 25.
11.One-variable minimum
Find the minimum of f(x)=x4−3x3+2.
Answer
f′(x)=x2(4x−9): critical points 0 (not an extremum) and 49. f(49)=−2561675≈−6.5430.
12.Critical points in the plane
Find and classify the critical point of f=x2+xy+y2−3x.
Answer
fx=2x+y−3=0, fy=x+2y=0: (2,−1). The Hessian (2112) is positive definite, so it is a minimum, f=−3.
13.Second-derivative test
Classify the critical points of f=x3−3x+y2.
Answer
fx=3x2−3, fy=2y: (±1,0). The Hessian is diag(6x,2): at (1,0) a minimum, at (−1,0) a saddle.
14.Lagrange multipliers
Find the point of the line x+2y=5 closest to the origin.
Answer
Minimise x2+y2: 2x=λ, 2y=2λ, so y=2x and x=1, y=2; distance squared 5.
15.A constrained maximum
Maximise xyz on the plane x+y+z=3 with x,y,z>0.
Answer
By symmetry (or AM–GM, 3xyz≤1), the maximum is 1 at (1,1,1).
16.Convexity
Is f=2x2+2xy+3y2 convex? Give the Hessian's eigenvalues.
Answer
The Hessian (4226) has eigenvalues 5±5≈2.7639,7.2361, both positive: strictly convex.
17.Least squares
Fit a line y=a+bx to (0,1),(1,3),(2,4),(3,4) by least squares.
Answer
xˉ=1.5, yˉ=3, Sxy=5, Sxx=5: b=1, a=1.5.
18.Gradient descent
Take one gradient-descent step of size 0.1 from (1,1) on f=x2+4y2.
Answer
∇f=(2x,8y)=(2,8), so the step lands at (1,1)−0.1(2,8)=(0.8,0.2).
19.Newton's method for a minimum
Take two Newton steps for minimising f(x)=x2−lnx from x0=1. What is the exact minimiser?
Answer
f′=2x−1/x, f′′=2+1/x2. x1=1−31=32, x2=32−2+9/44/3−3/2=32+512=1712≈0.70588. The minimiser is 1/2≈0.707107.
20.Duality
Write the dual of: maximise x+y subject to x+2y≤4, 3x+y≤6, x,y≥0; show both optimal values agree.
Answer
Dual: minimise 4u+6v with u+3v≥1, 2u+v≥1, u,v≥0. Primal optimum at (58,56) is 514; dual optimum at (52,51) is 58+56=514.