0

I'm trying to use Newton's method to approximate where the gradient of a function = 0 But I'm guessing error messages when I try to put in guesses for an iteration of Newton's, and I don't know what the problem is.

(For reference, Profit = 144TVa - 0.07TVb TVb - 0.01 TVa^2 + 174TVb -0.01TVb^2 - 4E5)

with(LinearAlgebra):
with(VectorCalculus):

DProfit := Gradient(Profit, [TVa, TVb])
F := unapply(DProfit, TVa, TVb)
J := Jacobian(DProfit)
Guess := V->evalf(V-Multiply(Jinv,F(V))):

But when I try to evaluate Guess at any points, it gives me an error:

Guess(3000,3000)
Error, (in Guess) invalid input: F uses a 2nd argument, TVb, which is missing
Guess(<3000,3000>
Error, (in Guess) invalid input: F uses a 2nd argument, TVb, which is missing

even though F(3000,3000) returns [-66,-36]

Thanks for the help.

GFauxPas
  • 299
  • 1
  • 14

1 Answers1

0

Figured out how to fix it!

Instead of:

Guess := V->evalf(V-Multiply(Jinv,F(V))):

I did:

Guess := V->evalf(V-Multiply(Jinv,F(V[1],V[2]))):
GFauxPas
  • 299
  • 1
  • 14