Matlab R2019 Update 3
syms x y k real;syms f(x,y);syms a b;xd = -a*tanh(k*f)+b*sech(k*f);yd = -b*tanh(k*f)-a*sech(k*f);chid = atan2(yd, xd);d_chid_dx = diff(chid, x);simplify(d_chid_dx, 'Steps', 100, 'Criterion', 'preferReal')
produces result
ans(x, y) = (((real(b*k*diff(f(x, y), x)*(tanh(k*f(x, y))^2 - 1)) - imag((b*k*sinh(k*f(x, y))*diff(f(x, y), x))/cosh(k*f(x, y))^2) + real((a*k*sinh(k*f(x, y))*diff(f(x, y), x))/cosh(k*f(x, y))^2) + imag(a*k*diff(f(x, y), x)*(tanh(k*f(x, y))^2 - 1)))/(imag(b*tanh(k*f(x, y))) - real(a*tanh(k*f(x, y))) + imag(a/cosh(k*f(x, y))) + real(b/cosh(k*f(x, y)))) - ((imag((a*k*sinh(k*f(x, y))*diff(f(x, y), x))/cosh(k*f(x, y))^2) - real(a*k*diff(f(x, y), x)*(tanh(k*f(x, y))^2 - 1)) + real((b*k*sinh(k*f(x, y))*diff(f(x, y), x))/cosh(k*f(x, y))^2) + imag(b*k*diff(f(x, y), x)*(tanh(k*f(x, y))^2 - 1)))*(imag(a*tanh(k*f(x, y))) + real(b*tanh(k*f(x, y))) - imag(b/cosh(k*f(x, y))) + real(a/cosh(k*f(x, y)))))/(imag(b*tanh(k*f(x, y))) - real(a*tanh(k*f(x, y))) + imag(a/cosh(k*f(x, y))) + real(b/cosh(k*f(x, y))))^2)*(imag(b*tanh(k*f(x, y))) - real(a*tanh(k*f(x, y))) + imag(a/cosh(k*f(x, y))) + real(b/cosh(k*f(x, y))))^2)/((imag(a*tanh(k*f(x, y))) + real(b*tanh(k*f(x, y))) - imag(b/cosh(k*f(x, y))) + real(a/cosh(k*f(x, y))))^2 + (imag(b*tanh(k*f(x, y))) - real(a*tanh(k*f(x, y))) + imag(a/cosh(k*f(x, y))) + real(b/cosh(k*f(x, y))))^2)
while calculation by hand gives
-a*k*sech(k*f(x,y))
which is correct.
I tried options for simplification (rewrite, steps, criterion) but with no luck.
Any answer will be greatly appreciated.
Best Answer