## equation solving – Problems with NSolve

In `12.2.0 for Microsoft Windows (64-bit) (December 12, 2020)`, once defined:

``````f(t_) := Sin(t)
eqn1 = {f'(t) == 0, 0 < t < Pi};
eqn2 = {TrigToExp(f'(t)) == 0, 0 < t < Pi};
``````

solving the respective equations:

``````sol1 = NSolve(eqn1, WorkingPrecision -> 5)
sol2 = NSolve(eqn2, WorkingPrecision -> 5)
``````

we get:

{{t -> 1.5708}}

{}

therefore, through the checks:

``````f'(t) == TrigToExp(f'(t)) // Simplify
eqn1 /. sol1
eqn2 /. sol1
``````

we get:

True

{{True, True}}

{{True, True}}

Am I missing something or is something wrong in `NSolve`?

## plotting – Solving non-linear equations self consistently

I am trying to solve two nonlinear equations self consistently and I have other fourth order algebraic equation. Such equations are important to calculate phase diagram in superconductors in co-existence region. I would like to have a plot of y and z for given x.

I am trying to make following plot.

The blue curve in inset is z(M/Tco) versus x and blue curve in whole figure is y(T/Tco) versus x

My code are:

x = {0.057, 0.058, 0.0585, 0.06};
n = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
solvegn = NSolve(1/gn – Sqrt(1 + z^2/(Pi*(2n + 1)y + 4.4xPi*gn)^2) == 0, gn);

sceq1 = NSolve(2PiSum(((2n + 1)Pi(gn – 1))/(((2n + 1)Pi + 0.4Pi*(x/y))((2n + 1)Pi + 0.4Pix(gn/y))), {n, 0, 20}) – PolyGamma(0.5 + 0.2*(x/y)) + PolyGamma(0.5 + 0.2*(x/w)) – Log(y/1.02) == 0, {y});

sceq2 = NSolve(2PiSum(((2n + 1)Pi(gn – 1))/(((2n + 1)Pi + 4.4Pi*(x/y))((2n + 1)Pi + 4.4Pix(gn/y))), {n, 0, 20}) – PolyGamma(0.5 + 2.2*(x/y)) + PolyGamma(0.5) – Log(y/1.7) == 0, {z});

My approach is to solve first equation numerically which will give me four gn roots and I need to choose only real positive roots giving me in terms of y and z. For each n I need gn.

Then plugging gn in equation second and third gives me two nonlinear equations in terms of y and z and need to solve self consistently for y and z and sum here is Matsubara sum.

I used NSolve like above then FindRoot but didn’t work out.
NSolve::ratnz: NSolve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.

I am wondering how to get y and z for different x and make a plot, any suggestions with the code would really be appreciable.

Thank you

## beginner – Error in solving the two coupled equation using the odeint subroutine written in fortran90

In the given code I tried to solve the two non linear coupled rate equations using Odeint subroutine. Odient subroutine is pre-written by someone else. I have written derivs subroutine and main part of the program. The derivs subroutine contains the information of the non-linear ordinary differential equations, given as:

By solving these equation, I am interested to find $$T(tau)$$. But below given code is giving too many errors. For example

Error: Unclassifiable statement at (1) ode_v3.f90:29:65:

| 1

Error: Invalid character in name at (1) ode_v3.f90:2:13:

``````2 | implicit none
|             1
``````

31 | implicit real*8 (a-h,o-z)
| 2

Error: Two main PROGRAMs at (1) and (2)

Please help me to remove these errors. Any help is highly appreciated. Just want to let you know that I am not much familiar with FORTRAN language and its way of working.

``````program main
implicit none
double precision T
double precision x1, x2, y0, x !x stands for tau and y(1) for T and y(2) for phi
integer :: n

open(2,file='data.txt',status='unknown')

ystart(1) = 1000.0 ! Initial Temperature T0 = 1000 MeV
ystart(2) = 10.0 ! Initial condition for phi
x1 = 0.07 ! Initial Thermalization time tau_i
x2 = 10 ! Upper limit on, can be read as  tau_qgp if T(tau_qgp) = 155 MeV
nvar = 2

write(2,901)
write(2,905)x,y(1)
901   format(4x, 'tau', 4x, 'Temp.',/)

do n=1,100
2   y(1)=ystart(1)
end do
end

c.............................................................
c       subtoutine odeint
c.............................................................
1   derivs,rkqc)
implicit real*8 (a-h,o-z)
external derivs
external rkqc
parameter (maxstp=10000,nmax=10,two=2.0,zero=0.0,
1  tiny=1.e-30)
common/path/kmax,kount,dxsav,xp(200),yp(10,200)
dimension ystart(nvar),yscal(nmax),y(nmax),dydx(nmax)
x=x1
h=dsign(h1,x2-x1)
nok=0
kount=0
do 11 i=1,nvar
y(i)=ystart(i)
11     continue
if(kmax.gt.0.0)xsav=x-dxsav*two
do 16 nstp=1,maxstp
call derivs(x,y,dydx)
do 12 i=1,nvar
yscal(i)=dabs(y(i))+dabs(h*dydx(i))+tiny
12     continue
if(kmax.gt.0.0)then
if(dabs(x-xsav).gt.dabs(dxsav))then
if(kount.lt.kmax-1)then
kount=kount+1
xp(kount)=x
do 13 i=1,nvar
yp(i,kount)=y(i)
13     continue
xsav=x
endif
endif
endif
if((x+h-x2)*(x+h-x1).gt.zero)h=x2-x
call rkqc(y,dydx,nvar,x,h,eps,yscal,hdid,hnext,derivs)
if(hdid.eq.h)then
nok=nok+1
else
endif
if((x-x2)*(x2-x1).ge.zero)then
do 14 i=1,nvar
ystart(i)=y(i)
14     continue
if(kmax.ne.0.0)then
kount=kount+1
xp(kount)=x
do 15 i=1,nvar
yp(i,kount)=y(i)
15     continue
endif
return
endif
if(dabs(hnext).lt.hmin)pause 'stepsize smaller than minimum.'
h=hnext
16     continue
pause 'too many step'
return
end

c...................................................................
c       subroutine rkqc
c...................................................................
subroutine rkqc(y,dydx,n,x,htry,eps,yscal,hdid,hnext,derivs)
implicit real*8 (a-h,o-z)
parameter (nmax=10,pgrow=-0.20,pshrnk=-0.25,fcor=1./15.,
1  one=1.,safety=0.9,errcon=6.0e-04)
external derivs
dimension y(n),dydx(n),yscal(n),ytemp(nmax),ysav(nmax),
1  dysav(nmax)
xsav=x
do 11 i=1,n
ysav(i)=y(i)
dysav(i)=dydx(i)
11     continue
h=htry
1     hh=0.5*h
call rk4(ysav,dysav,n,xsav,hh,ytemp,derivs)
x=xsav+hh
call derivs(x,ytemp,dydx)
call rk4(ytemp,dydx,n,x,hh,y,derivs)
x=xsav+h
if(x.eq.xsav)pause 'stepsize not significant in rkqc'
call rk4(ysav,dysav,n,xsav,h,ytemp,derivs)
errmax=0.0
do 12 i=1,n
ytemp(i)=y(i)-ytemp(i)
errmax=dmax1(errmax,dabs(ytemp(i)/yscal(i)))
12     continue
errmax=errmax/eps
if(errmax.gt.one)then
h=safety*h*(errmax**pshrnk)
go to 1
else
hdid=h
if(errmax.gt.errcon)then
hnext=safety*h*(errmax**pgrow)
else
hnext=4.0*h
endif
endif
do 13 i=1,n
y(i)=y(i)+ytemp(i)*fcor
13     continue
return
end

c....................................................
c       subroutine rk4
c....................................................
subroutine rk4(y,dydx,n,x,h,yout,derivs)
implicit real*8 (a-h,o-z)
external derivs
parameter (nmax=10)
dimension y(n),dydx(n),yout(n),yt(nmax),dyt(nmax),dym(nmax)
hh=h*0.5
h6=h/6.0
xh=x+hh
do 11 i=1,n
yt(i)=y(i)+hh*dydx(i)
11     continue
call derivs(xh,yt,dyt)
do 12 i=1,n
yt(i)=y(i)+hh*dyt(i)
12     continue
call derivs(xh,yt,dym)
do 13 i=1,n
yt(i)=y(i)+h*dym(i)
dym(i)=dyt(i)+dym(i)
13     continue
call derivs(x+h,yt,dyt)
do 14 i=1,n
yout(i)=y(i)+h6*(dydx(i)+dyt(i)+2.0*dym(i))
14     continue
return
end

c--------------------------------------------------------
c   SUBROUTINE derivs for coupled rate Equation
c.......................................................
subroutine derivs(x,y,dydx)
implicit real*8 (a-h,o-z)
dimension y(10),dydx(10)
common/root/ct,rms,hc,pi,T0,x1,Tc
pi2=pi*pi

c       alphas=6.*pi/((33-2*nf)*dlog(8.*y(2)/Tc))  !coupling for strange parti.
alphas=0.5
alphas2=alphas**2
nf=3              !no. of flavour

a=(32 + (21*nf))*pi2/180 !parameter a
b1=1 + (1.70*nf)
b2=1 + (nf/6)
b3=alphas2*log(alphas**-1)
b=0.342*b1/(b2*b3)       !parameter b

c defining first order deriviate of T
c1=y(1)/(3*x)
c2=y(2)*(y(1)**-3)
c3=18*a*x
c4=c2/c3
dydx(1)=-c1+c4 !First order derivative of Temperature --eq12

c defining first order deriviate of phi
d1=2*a*y(1)*y(2)/(3*b)
d2=y(2)/2.
d3=1/x
d4=(5/y(1))*dydx(1)
d5=8*a*(T**4)
d6=9*x
d7=d5/d6
dydx(2)=-d1- d2*(d3-d4) + d7 !First order derivative of Phi --eq13

write(123,*)x,y(2)
write(500,*)x,y(1)
return
end
c.......................................................
``````

## equation solving – Solve using PolyGamma function

`Solve` is a symbolic solver of algebraic as well as various types of transcendental equations, as the problem at hand, and so we should use exact numbers.

``````x = Rationalize(0.165);
f(y_) := -Log(y) - PolyGamma(1/2 + 1/5 (x/y)) + PolyGamma(1/2)
``````

Next we should restrict the domain of `y`, a natural assumption is `y > 0`, nevertheless one should also add a bound from above (it is not always necessary). Taking a look at the plot e.g. `Plot(f(y), {y, 0, 5})`, we should be satisfied with `0 < y < 5`, and so `Solve`
provides an exact solution in terms of the `Root` object:

``````Solve(f(y) == 0 && 0 < y < 5, y)
``````
``````{{y -> Root({Log(#) - PolyGamma(0, Rational(1, 2))
+ PolyGamma(0, Rational(1, 2) + Rational(33, 1000)/#)& ,
0.8324921392608209131327584577663713541314494518823960255129`30.
102999566398122})}}
``````

This solution can be further transformed symbolically for more detailed purposes.
Using a bound for `y` we could use `NSolve` as well without rationalizing inexact coefficients to get a numerical solution, however an exact solution is a full information we can get from given equation.

## assembly – Solving a quadratic function using mips

I want to make a simple program with mips assembly to learn the language. I have the function ax²+bx. The user has to input the a,b and the domain of function.I want to print the values that the function is zero but only the integers of the domain. I thought that the simplest way is to loop all the integers from (x1,x2) and print the values that the function=zero.I get an error “Unknown system call 268501060”.

``````    .data

riza: .asciiz"h sunartish mhdenizetai sto: n"

.text
main:

li \$v0,4
syscall
li \$v0,5
syscall
move \$t0,\$v0

li \$v0,4
syscall
li \$v0,5
syscall
move \$t1,\$v0

li \$v0,4
syscall
li \$v0,5
syscall
move \$t2,\$v0

li \$v0,4
syscall
li \$v0,5
syscall
move \$t3,\$v0

move \$t4, \$t2 #πρωτο χ για επαναληψη

while:
beq \$t4, \$t3, exit

mul \$t6,\$t4,\$t4  #x^2
mul \$t7,\$t0,\$t6 #a*x^2
mul \$t6,\$t1,\$t4   #b*x

add \$t8, \$t7, \$t6 #τ8 τελικη τιμη συναρτησης

beq \$t8,0,isioi #if(t8=0)

isioi:
li \$v0, 1
la \$v0, riza
syscall
move \$a0, \$t8
li \$v0, 1
syscall
j while

exit:
li \$v0, 10
syscall
``````

## equation solving – Command to find the pre-image of a set that is mapped to by the function \$f(x)=3^x mod{17}\$

$$f(x)=3^x mod{17}$$

How to find the pre-image of the set if this function maps from real numbers to real numbers. What command would I use, to see the pre-image if the function would map from integers to integers.

It is easy to compute with mathematica, but the command to find the pre-image I cannot find.

What I tried, and there are no methods available to solve it:

``````Solve(y == 3^x - 17 Floor(3^x/17), x)
``````

Output:

## Selling – Private Dedicated API for Faster CAPTCHA Solving | Proxies123.com

We have a new special offer for you our valued customers, The offer is titled, “CAPTCHAs.IO’s Private Dedicated API, Reliable Dedicated Private API for faster reCAPTCHA and Image CAPTCHA Solving”.

reCAPTCHA v2, v3 and invisible solving time is 10 to 60 seconds on average, depending on the complexity of reCAPTCHA set in the Google Admin Console for reCAPTCHA. For image CAPTCHAs solving time is 0 to 1 second on average.

Our datacenter is a European colocation datacenter strategically located in the Netherlands, and connected to globally based Points of Presence. Constructed, owned and operated by sister company Greenhouse Datacenters, these Tier 3 designed facilities enable flexible, sustainable, secure and highly connected IT infrastructure deployments. Servers enjoy a connection of 10 Tbit/s global network with only 45% utilization with 10g DDoS protection.

Best of all these servers are genuine hardware and no fake virtual hardware shared, operates fast and stable 24/7/365.

## Solving a complex equation analytically

In my attempt to find a solution to my own question over at CrossValidated, I want to solve the following equation for $$p$$:

$$t^2=p^2left(1 – frac{m}{p}Y-Y^2right)$$

where

$$Y=frac{frac{1}{sqrt{2pi}p}expleft(-frac{1}{2}frac{m^2}{p^2}right)}{1 – frac{1}{1 + expleft(0.007056frac{m^3}{p^3}+1.5976frac{m}{p}right)}}$$

$$m$$ and $$p$$ are parameters.

The following should be the equivalent in Mathematica/Wolfram language:

``````solve t^2=p^2*(1-((m/p)*(((1/(p*sqrt(2*pi)))*exp(-0.5*m^2/p^2)) / (1 - (1 / (1 + exp(0.007056*m^3/p^3 + 1.5976*m/p))))))-((((1/(p*sqrt(2*pi)))*exp(-0.5*m^2/p^2)) / (1 - (1 / (1 + exp(0.007056*m^3/p^3 + 1.5976*m/p)))))^2)) for p
``````

I tried this with the Online Wolfram Equation Solver, but it doesn’t even display the formatted equation, even though I’m quite sure it is correct.

I’m not a mathematician, so I have no idea whether solving this equation is hopeless. Any hints as how to approach this problem (in Mathematica or otherwise) are much appreciated; also if it involves simplifying / approximating the solution. I need an analytic solution though.

## Problem with initial conditions for numerically solving the Sine-Gordon equation using finite differences method (in MatLab).

We are trying to solve numerically a kink solution in matlab using the sine-gordon equation, therefore followed the steps according to the paper (1) listed below. The sine gordon equation is a non-linear pde and the numerical solution was clearly explained in the paper (1). However, the problem is that if we use the initial conditions f(x) and g(x) (page 6 of the paper), the solution will have a disturbance and is not as clean as figure 5.4a (p. 6) from the paper it self. To solve this we ‘doubled’ the size of the soliton by replacing ‘x’ in the initial conditions for ‘x/2’. Therefore my question: What is the explanition that dividing x by 2 instead of taking just x justifies? Perhaps we made a mistake in the numerical model?

Source

1. The paper used: https://www.uni-muenster.de/imperia/md/content/physik_tp/lectures/ws2016-2017/num_methods_i/sinegordon.pdf
2. There are a few references from source 1 to chapter 4: https://www.uni-muenster.de/imperia/md/content/physik_tp/lectures/ws2016-2017/num_methods_i/wave.pdf

Matlab code

The changes of the inital conditions are cleary commented in the matlab code.

```clear all; clc; close all;
%% Define variables
L = 40; %Choosing a bigger L can make it look nicer, also change it in the function at the bottom of the code
delta_x = 0.05;
delta_t = 0.01;
c = 0.2;
t_end = 90;
T = t_end/delta_t;
M = L/delta_x;
N = M+1;
x = linspace(-L,L,M+1);
t = linspace(0,t_end,T+1);
%end
%% Calculate first time row

u_0 = transpose(f(x));
gamma_1 = transpose(g(x));
beta_1 = sin(u_0);
alpha = delta_t/delta_x;

a = 1-alpha^2;
b = alpha^2/2;
c = b;
A = diag(a*ones(1,N)) + diag(b*ones(N-1,1),1) + diag(c*ones(1,N-1),-1);
A(1,2) = A(1,2) + b;
A(N,M) = A(N,M) + b;
B = 2*A;

%% Calculate second time row
u_1 = delta_t*gamma_1 + A*u_0 - (delta_t^2/2)*beta_1;
u = zeros(N,T);
u(:,1) = u_0;
u(:,2) = u_1;

%% Calculate the full matrix
beta = zeros(N,T);
beta(:,1) = beta_1;

for j = 2:(T)
beta(:,j) = sin(u(:,j));
u(:,j+1) = -u(:,j-1) + B*u(:,j) - (delta_t^2)*beta(:,j);
end

%figure
mesh(x(1:10:end),t(1:10:end),transpose(u(1:10:end,1:10:end)))
xlabel('x')
ylabel('t')
zlabel('u')

for n = 1:T-1
for l = 1:N-1
e(l,n) = (1/2*((u(l,n+1)-u(l,n))/delta_t)^2+1/2*((u(l+1,n+1)-u(l,n+1))/delta_x)*((u(l+1,n)-u(l,n))/delta_x)+(1-cos(u(l,n+1)+1-cos(u(l,n))))/2);
end
E(n) = delta_x*sum(e(:,n));

end

%% Define the functions
% Single soliton
function f = f(x)
c = 0.2; %This can be varied to create a nicer picture, also change it in the 'g'function
L = 20; %This can be varied to create a nicer picture, also change it in the 'g'function
f = 4*atan(exp((x/2)/sqrt(1-c^2))); % the '+L/2' can also be changed to have a different starting point for the soliton, don't forget to also change it in the 'g'function
end
function g = g(x)
c = 0.2;
L = 20;
g = -2*c/sqrt(1-c^2)*sech((x/2)/sqrt(1-c^2));
end```

## Trying to find name of a problem solving technique

I heard the name of a problem solving technique, sounds like iso(s)? I believe it focuses on dividing different levels of a technical problem.