Привет! Скинул такой код преподавателю, но он выполняется слишком долго. Попробуй…
- User
Привет! Скинул такой код преподавателю, но он выполняется слишком долго. Попробуй оптимизировать его. Он сказал, если счёт уменьшится в два раза, то поставит зачет, поэтому постарайся, пожалуйста. with(plots); funF := proc (x, y) options operator, arrow; xexp(y)+sin(xy) end proc; funG := proc (x, y) options operator, arrow; yexp(x)-cos(xy) end proc; pF := plot3d(funF, -2 .. 2, -2 .. 2, axes = boxed, labels = ["x", "y", "funF(x,y)"], grid = [30, 30], color = [.2, .7, .2]); pG := plot3d(funG, -2 .. 2, -2 .. 2, axes = boxed, labels = ["x", "y", "funG(x,y)"], grid = [30, 30], color = [.7, .2, .6]); display(pF); display(pG); InverseMap := proc (u, v) local sols, lst, eq, Xval, Yval; sols := fsolve({funF(x, y) = u, funG(x, y) = v}, {x, y}); if sols = NULL then return NULL end if; if type(sols, 'set') then if nops(sols) = 0 then return NULL end if; lst := [op(sols)] else lst := [sols] end if; Xval := NULL; Yval := NULL; for eq in lst do if type(eq, 'equation') then if lhs(eq) = x then Xval := rhs(eq) end if; if lhs(eq) = y then Yval := rhs(eq) end if end if end do; if Xval = NULL or Yval = NULL then return NULL end if; return [evalf(Xval), evalf(Yval)] end proc; InvX := proc (u, v) local inv; inv := InverseMap(u, v); if inv = NULL then return NaN else return inv[1] end if end proc; InvY := proc (u, v) local inv; inv := InverseMap(u, v); if inv = NULL then return NaN else return inv[2] end if end proc; printf("InvX(1,1) = %a\n", InvX(1, 1)); printf("InvY(1,1) = %a\n", InvY(1, 1)); pInvX := plot3d(InvX, -2 .. 2, -2 .. 2, axes = boxed, labels = ["u", "v", "InvX(u,v)"], grid = [30, 30], color = [.2, .7, .2]); pInvY := plot3d(InvY, -2 .. 2, -2 .. 2, axes = boxed, labels = ["u", "v", "InvY(u,v)"], grid = [30, 30], color = [.7, .2, .6]); display(pInvX); display(pInvY)
- Assistant
- User
Error, invalid 'if' statement
- Assistant
- User
Error, (in fsolve) complex = false is an invalid option Error, (in plot3d) bad range arguments: axes = boxed, color = .2 Error, (in plot3d) bad range arguments: axes = boxed, color = .7 Error, (in plots:-display) expecting plot structure but received: pInvX Error, (in plots:-display) expecting plot structure but received: pInvY
- Assistant
- User
Error, (in plot3d) bad range arguments: axes = boxed, color = .2 Error, (in plot3d) bad range arguments: axes = boxed, color = .7 Error, (in plots:-display) expecting plot structures but received: [pInvX, pInvY]
- Assistant
- User
Напиши итоговый код полностью
- Assistant
- User
Error, (in plot3d) first argument must be either in standard or parametric form Error, (in plot3d) first argument must be either in standard or parametric form Error, (in plots:-display) expecting plot structures but received: [pInvX, pInvY]
- Assistant