## Need help with making code work on Mathematica

    Num = 150;     arr = ConstantArray[1, Num + 1];     For[m = 2, m <= Floor[Sqrt[Num/2] + 1], m++,      For[n = 1, n <= m, n++,      If[! OddQ[m + n], If[GCD[m, n] != 1, L = Min[2*m*(n + m), Num];     arr[[L+1 ;; All ;; L]] = arr[[L+1 ;; All ;; L]] - 1]]]]     Num + 1 - Count[arr, u_ /; u != 0] 

this is the question, its suppose to be written in mathematica but this one doesnt work..

Question

It turns out that 12 cm is the smallest length of wire that can be bent to form an integer sided right angle triangle in exactly one way, but there are many more examples.

12 cm: (3,4,5) 24 cm: (6,8,10) 30 cm: (5,12,13) 36 cm: (9,12,15) 40 cm: (8,15,17) 48 cm: (12,16,20)

In contrast, some lengths of wire, like 20 cm, cannot be bent to form an integer sided right angle triangle, and other lengths allow more than one solution to be found; for example, using 120 cm it is possible to form exactly three different integer sided right angle triangles.

120 cm: (30,40,50), (20,48,52), (24,45,51)

Given that L is the length of the wire, for how many values of L ≤ 1,500,000 can exactly one integer sided right angle triangle be formed?

## How to run Facebook Prophet in Mathematica?

I would like to use the Facebook Prophet API for timeseries forecasting in Mathematica.

I’m trying to make a function prophetM which takes a list of date, and integer pairs (or a Timeseries object), and returns a list of length N of date and integer pairs for N future periods.

An exmaple of the code in python is given below, where:

LIST_IMPORTED_FROM_MATHEMATICA = {{"2020-01",1},{"2020-02",2},{"2020-03",3},….}

(the data could also have a day, or be a DateObject[] — but that isn’t needed)

Would anyone have any idea how to do that?

Thanks!!

Exmaple python code:

import pandas as pd from fbprophet import Prophet  df = LIST_IMPORTED_FROM_MATHEMATICA  m = Prophet()  m.fit(df)   future = m.make_future_dataframe(periods=N, freq='MS')   forecast = m.predict(future)   $$$$ 

## Evaluate the limit of a subsequence: Compute the limit $\lim_{n\to\infty} \cos\left( \pi \sqrt{4n^2 + 5n + 1} \right)$ Integer $n$ on Mathematica

I want to compute the limit $$\lim \limits_{n\to\infty} \cos\left( \pi \sqrt{4n^2 + 5n + 1} \right)$$for integer $$n$$. By completing the square, we can determine that this limit is equal to $$– \tfrac1{\sqrt2} \approx -0.7071$$.

But if we don’t restrict $$n$$ to an integer, then the limit is indeterminate / does not exist. And can be easily found by typing it on WolframAlpha. Or in Mathematica:

However, I do not know how to compute the limit (on Mathematica) with the original constraint that $$n$$ must be an integer.

I know that we can plot a graph on Mathematica:

The graph suggests that the limit is equal to $$-\tfrac1{\sqrt2}$$. However, this doesn’t look like a convincing result because we can’t know that the limit is exactly equal to $$-\tfrac1{\sqrt2}$$.

Question: Is there a way to compute this limit in Mathematica where it spits out a single numerical value (of $$-1/{\sqrt2}$$)?

## What can I do to get Mathematica to solve this equation?

I am trying to solve an equation on Mathematica 12.1 to get angles in radians as part of some analysis:

forceToStrain[in_] := in/(51.76*10^9); strainFromTheta[in_] := ((in/(2*Sin[in/2])) - 1) // N (*thickness = 0.28 * 16 ply = 4.48 mm = 4.48*10^(-2 m)*)  Solve[((x/(2*Sin[x/2])) - 1) == forceToStrain[10], x] 

But I am getting this error:

Reduce::inex: Reduce was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Reduce require exact input, providing Reduce with an exact version of the system may help. 

It doesn’t seem complicated as an equation as I can solve it by hand:

strainFromTheta[.00007] forceToStrain[10] Output: 2.04167*10^-10 and 1.93199*10^-10 

Can anyone tell me whether I could use a different function or rearrange the equation differently to get the angles?

## Defining an mathematical operator in Mathematica

I’m trying to learn mathematica to use in my thesis. I have basic problems with definitions, calculations etc. Let me ask a question.

I want to define anti derivative operator and derivative operator, then a new operator with composition of these operators. Compositions must be identity, so if I give a function into new operator it will turn out the function what I gave it.

To explain better, I will try to write these in mathematical sense;

Here $$D^m$$ denotes standard derivative operator $$m$$ times and anti-derivative operator $$I_m$$ defined with

$$\begin{cases} f(x), & m=0 \ \int_0^{x} \dfrac{(x-y)^{m-1}}{(m-1)!}f(u)du, & m\geq 1 \end{cases}$$ 

which seems

Now, if we composite these functions, $$[D^m\circ I_m](f)(x)$$ these will give us directly $$f(x)$$. I want to define these operators in Mathematica and see composition of operators.

Actually these problem is not my main problem but the answers will shows me what I need, then I will try to learn myself again.

Thanks for your helps, if I wrote incomprehensible or wrong forgive me.

## Phase portrait plotting by mathematica

I am trying to do the phase space plot of the following expression

$$\frac{dy}{dt} = -0.006y (1-0.001 y^{2})^ {2.003}$$

Anyone can suggest me an appropriate code in mathematica?

## Why does Mathematica crash at a certain recursion depth?

If I enter

Block[{$RecursionLimit = 70000}, x = x + 1]  I get $  RecursionLimit: Recursion depth of 70000 exceeded during evaluation of 1+x. 

But at \$ RecursionLimit = 80000, Mathematica crashes (i.e. goes unresponsive for a little while and then clears all variables). Why is this? Is there some limiting factor that I can increase to go even further?

## Why doesn’t Mathematica ComplexExpand integrals?

Consider this code example:

ComplexExpand[Re[Integrate[f[t], {t, a, b}]]] 

Mathematica gives me the result as

Re[Integrate[f[t], {t, a, b}]] 

which is obviously not helpful and not what should happen in my understanding. If all variables are real – and that’s what ComplexExpand assumes according to the documentation – then Re can be dropped from the expression. The same happens for Im. This seems to confuse FullSimplify which leaves me with a long expression that could be shorted. Why is this the case?

## Cycle detection with Mathematica

Suppose we have a recurrent process. And we know for sure that it is cyclical. That it has a period.

How do I find this period using Wolfram Mathematica?

An example process is provided here.

I am using code like this:

iteratedStates[init_]: = NestWhileList[process[#]&, init, Unequal, All];  period[init_]: = With[{data = iteratedStates[init]},     First@Differences@Flatten@Position[data, Last@data]     ]; 

It is not effective. I tried to implement various algorithms but their implementations were even slower ((

UPD. Yes, there is FindTransientRepeat
But here what we have:

data = ContinuedFraction[(Sqrt[12] + 2)/7, 10004]; Timing[Length@Last@FindTransientRepeat[data, 2]] {0.0624004, 6} Timing[First@Differences@Flatten@Position[data, Last@data]] {0.0156001, 6} 

I need store all data. So NestWhileList` is needed. And it seems that my implementation is good enough

## Solving indexed ODE in Mathematica

I would like to solve an ODE with indexed variables symbolically. Is there a way to do that? $$\frac{dp_{\beta\alpha}}{dt}=m\left(p_{1\alpha}p_{\beta2}+p_{2\alpha}p_{\beta1}\right)$$ m is called mass and is constant. t is time.