## equation solving – Instability (divergence) in NIntegrate solution

I am facing a problem with the solution of NIntegrate. Here is my NIntegrate command:

For(i = 2, i <= Length(t), i++,
x = coef *NIntegrate((1 - (ah*θ((i - 1)))^m)/Sqrt(t((i)) - t0), {t0,0, t((i))});
θ = Insert(θ, x, -1));


And here is the solution:

The solution diverges from the real answer at around t=2.5. When I increase the time step, it happens later but still happens. I have changed my AccuracyGoal and PrecisionGoal but they didn’t work.
Any help would be appreciated!

## equation solving – How to remove unnecessary answers from NSolve without losing speed?

This code:

eqs =
{Ca/u^2 +
r (6 a (c^2 - d^2) + 12 b c d + 6 (a^2 + b^2 + c^2 + d^2) Ca +
Ca^3) == 0,
a (1/u^2 - 1) +
r (3 a (a^2 + b^2) + 6 a (c^2 + d^2) + 3 c^2 Ca - 3 d^2 Ca +
3 a Ca^2) == 1/2,
b (1/u^2 - 1) +
r (3 b (a^2 + b^2) + 6 b (c^2 + d^2) + 6 c d Ca + 3 b Ca^2) == 0,
c (1/u^2 - 1/4) +
r (6 (a^2 + b^2) c + 3 c (c^2 + d^2) + 6 (a c + b d) Ca +
3 c Ca^2) == 0,
d (1/u^2 - 1/4) +
r (6 (a^2 + b^2) d + 3 d (c^2 + d^2) + 6 (-a d + b c) Ca +
3 d Ca^2) == 0, c > 0, d >= 0,
QQQ == c^2 + d^2, QQQ != 0
} // Rationalize(#, 0) &;
NSolve(eqs /. {u -> 5, r -> 0.04}, {a, b, c, d, Ca, QQQ}, Reals)


{{a -> -0.732167, b -> 0, c -> 1.06332, d -> 0, Ca -> 0.443594,
QQQ -> 1.13066},
{a -> -0.732167, b -> 0, c -> 1.06332, d -> 0,
Ca -> 0.443594, QQQ -> 1.13066},
{a -> -0.732167, b -> 0,
c -> 1.06332, d -> 0, Ca -> 0.443594,
QQQ -> 1.13066}, {a -> -0.732167, b -> 0, c -> 1.06332, d -> 0,
Ca -> 0.443594, QQQ -> 1.13066}, {a -> -0.698614, b -> 0,
c -> 0.622043, d -> 0.622043, Ca -> 0,
QQQ -> 0.773876}, {a -> -0.698614, b -> 0, c -> 0.622043,
d -> 0.622043, Ca -> 0, QQQ -> 0.773876}, {a -> -0.698614, b -> 0,
c -> 0.622043, d -> 0.622043, Ca -> 0,
QQQ -> 0.773876}, {a -> -0.698614, b -> 0, c -> 0.622043,
d -> 0.622043, Ca -> 0, QQQ -> 0.773876}, {a -> -0.698614, b -> 0,
c -> 0.622043, d -> 0.622043, Ca -> 0,
QQQ -> 0.773876}, {a -> -0.698614, b -> 0, c -> 0.622043,
d -> 0.622043, Ca -> 0, QQQ -> 0.773876}, {a -> -0.698614, b -> 0,
c -> 0.622043, d -> 0.622043, Ca -> 0, QQQ -> 0.773876}}


But as you see, there are several identical answers.
And if a make WorkingPrecision -> 3, for example, this code is slow down.
Maybe there is other methods to make this code faster?

## Solving nonlinear PDE by using numerical methods in python

Is there any method to solve the nonlinear partial differential equation(e g. Gross-Pitaevskii equation) in python?

## asymptotics – Solving the recurrence $T(n)=T(n-2)+n^2$ with the iterative method

Thanks for contributing an answer to Computer Science Stack Exchange!

But avoid

• Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

## equation solving – Approaches to expression reduction

I am still learning how to use Mathematica more efficiently, but something that I keep bumping into is problems with it reducing formulas. Often, I’ll ask it to compute a certain formula (take a derivative, Fourier transform, etc.) and the output is sometimes very messy, but could easily be reduced to something much neater.

It’s usually not a big deal, because I can carry the simplification on my own, but it would still be convenient to have a systematic way of reducing everything, and not have to little tricks on a case by case basis. In some cases, I have tried, FullSimplify or TrigReduce without much success, or even using certain assumptions. For example, this should reduce

Cos((Theta)) ((Sqrt(-((g H)/(-1 + Sin((Theta)))))Sqrt(-g H (-1 + Sin((Theta)))))/g - (H Sin((Theta)))/(-1 + Sin((Theta))))


$$cos (theta ) left(frac{sqrt{-frac{g H}{sin (theta )-1}} sqrt{-g H (sin (theta )-1)}}{g}-frac{H sin (theta )}{sin (theta )-1}right)$$

to this

Cos((Theta)) (H-(H Sin((Theta)))/(-1+Sin((Theta))))


$$cos (theta ) left(H-frac{H sin (theta )}{sin (theta )-1}right)$$

But even when doing FullSimplify on it, it just outputs the same expression. I don’t have examples on top of my head, but I have been in similar situations before, where I want to reduce something, but I jut can’t seem to do anything to reduce it.

Are there extra ways of forcing it into ‘seeing’ the possible simplifications? Or is it possible that from its perspective the expression is reduced enough? To be honest, I am not asking for a specific case of simplification, but more on the general approaches one would take to simplify/reduce an expression.

## python – Solving a System of linear equations with 3 variables without numpy

Thanks for contributing an answer to Stack Overflow!

But avoid

• Making statements based on opinion; back them up with references or personal experience.

## Why should 3-Opt be used over 2-opt for solving TSP?

I know the working of 2-opt and 3-opt local search algorithm. But I could not find any example where solution improvement is not possible using 2-opt but 3-opt. I am looking for a proper explanation along with diagrams where TSP solution is not improved by 2-opt but 3-Opt can improve it.

## Solving limit without L’hopital $lim_{xto0} left(frac{frac{xe^x}{e^x-1}-1}{x}right)$

I’m trying to solve this limit using transformations & common limits but I’ve been unable to:
$$lim_{xto0}left( frac{frac{xe^x}{e^x-1}-1}{x}right)$$

This limit simplifies to $$1/2$$ using L’Hôpital’s rule but I had to use it 3 times in order to get the result. (I’m trying to prove that the function is differentiable at $$x=0$$.)

So if anyone is able to solve it using transformations only without L’hopital I would be grateful.

Thanks for your time and stay safe…

## asymptotics – Solving $T(n) = 4T(n/2) + n^3$ with substituton method

I am trying to solve the following recurrence $$T(n) = 4T(n/2) + n^3$$ with substitution method. My guess is $$T(n) = Theta (n^3)$$ (I used master theorem) and I tried to show that $$T(n) leq cn^3$$. But, when i substitute i got $$T(n) leq c frac{n^3}{2} + n^3$$ and that’s it not the exact form of the guess, so it doesn’t work. How can I solve this recurrence? Thanks.

## equation solving – How to code this iterative process?

I am facing difficulty to realize this double iterative process.

The equations in question are

The flow chart for the iterative process is given as

The different parameters are defined as

alphan=1.72*10^(-4);
alphap=2.037*10^(-4);
L=1.3*10^(-3);
A=2.08*10^(-6);
kp=1.265;
kn=1.011;
sigmap=1.314e-5;
sigman=1.119e-5;
alphapn=alphap-alphan;
Rpn=L/(A)*(sigmap+sigman);
RL=1;
Kpn=(A/L)*(kp+kn);
cf=4205;
cc=4153;
hf=80;
hc=1000;
Tfin=773;
Tcin=353;
mf=20;
mc=20;