NapkinCalc

Start Here — A Complete Tour

Goal-seek when you can't rearrange — nsolve()

continues from lesson 9 — values defined earlier in the course stay live here

Some equations can't be rearranged cleanly. nsolve("residual", "variable", guess) finds the value that drives the residual to zero numerically — and it is unit-aware: the unit of your guess is the unit of the answer. Here we size a cylinder: what radius gives a 100 m³ tank that is 3 m tall?

tankheight:=3mtank_{height} := 3 m = 3 m
tankvolume:=100m3tank_{volume} := 100 m^3 = 100 m^3
tankradius:=nsolve("tankvolumeπr2tankheight","r",1m)tank_{radius} := nsolve("tank_{volume} - \pi *r^2*tank_{height}", "r", 1 m) = 3.2574 m guess 1 m; the unit carries through
✓ pass abs(πtankradius2tankheighttankvolume)<1e6m3abs(\pi *tank_{radius}^2*tank_{height} - tank_{volume}) < 1e-6 m^3 plug it back in: the volume really is 100 m³