solve1: initialize fjac only if it needs to be computed numerically.
trust_region: replace a loop with a matrix expression