## How do i differentiate a cosx function when x is in degrees?

i have been having a hard trouble working on excercise 4a since i cannot understand how to differentiate a trig function that has x in degrees. How is it done?

.

## Integer linear programming can’t find global minimum

I was working with Project Euler Problem 418 using Mathematica and got in trouble.

I wrote a function to find the unique factorization triple which minimizes c / a for integer n.

FactorizationTriple[n_] :=   Block[{factor, base, exponent, l, e, varmat, vars, cons1, cons2, cons3, solve, a, b, c},   factor = FactorInteger[n];   base = factor[[All, 1]];   exponent = factor[[All, 2]];   l = Length[factor];   varmat = Table[e[i, j], {i, 1, 3}, {j, 1, l}];   vars = Flatten[varmat];   cons1 = Thread[0 <= vars];   cons2 = Thread[exponent == Total[varmat, {1}]];   cons3 = {varmat[[1]].N[Log[base]] <= varmat[[2]].N[Log[base]] <= varmat[[3]].N[Log[base]]};   solve = FindMinimum[{varmat[[3]].N[Log[base]] - varmat[[1]].N[Log[base]], Join[cons1, cons2, cons3], Element[vars, Integers]}, vars];   a = Times @@ (Power @@@ ({base, Table[e[1, j], {j, 1, l}] /. solve[[2]]}\[Transpose]));   b = Times @@ (Power @@@ ({base, Table[e[2, j], {j, 1, l}] /. solve[[2]]}\[Transpose]));   c = Times @@ (Power @@@ ({base, Table[e[3, j], {j, 1, l}] /. solve[[2]]}\[Transpose]));   {a, b, c}] 

Since both f and cons in FindMinum are linear, I thought it uses Method->"LinearProgramming" and I expected it to return a global minimum.

FactorizationTriple does work when n = 165 or 100100 or 20!, but it can’t give me the correct answer when n = 43!:

AbsoluteTiming[FactorizationTriple[43!]] {1044.17, {392385912744443904, 392388272221065120, 392389380337500000}} 

The correct answer is {a, b, c} = {392386762388275200, 392388272221065120, 392388530688000000}.

Questions:

1. Should I use NMinimize or LinearProgramming instead? (I had some try but failed.)
2. How to set the options in FindMinum?
3. How to improve the efficiency of FactorizationTriple? (It’s too slow now.)

## Is this really prime number?

Using the primality test on this site (www.javascripter.net/math/calculators/100digitbigintcalculator.htm) I found that the concatenation of the digit reversal of the first 548 odd primes in the reverse order is a prime(!). It is a 1998-digit prime, but it took more than an hour for this ‘calculator’ to stated that it is a prime, it was a ‘super-slowly’ calculation. Could you confirm that this result is correct?. that prime is 7693749334931393…91713111753. Thanx.

## HoldFirst being overridden by Activate

So here’s the problem a=1;a=2 works because of the HoldFirst attribute of Set, so that it does not become 1=2 But a=1;Activate[Inactivate[a=2]] does not because the attributes of Set is lost during Inactivate. So how do I avoid this problem?

## Using list of rules from imported .mat file

I’m attempting to learn Mathematica to replace MATLAB. However, I have some data in .mat files which contains named variables.

Whenever I import the .mat file, I get a list of rules. What’s the best way to go about using these? Let’s say I wanted to plot some of the LabeledData, say “n2_den”. Would I do something like ListLinePlot[data]/.n2_den? Or would I be better off just converting the list of rules to a list like one of the recommendations shows when I import?

## How to solve a system of two equations and two variables in function of others terms

I want to Find C1 and C2 in terms of a and e from the following system of equations:

60 + 31 a + 4 a^2 + 4 C1 C2 (4 + a) (873 + 444 a + 56 a^2) e + 128 C1^2 C2^2 (3 + a) (4 + a) (9 + 2 a) (33 + 8 a) e^2 - 3072 C1^3 C2^3 (4 + a)^2 (9 + 2 a)^3 e^3 == 0  60 + 31 a + 4 a^2 + C1 C2 (4 + a) (3267 + 8 a (207 + 26 a)) e + 16 C1^2 C2^2 (4 + a) (9 + 2 a) (837 + 468 a + 64 a^2) e^2 - 4 C1^3 C2^3 (4 + a) (9 + 2 a)^2 (18333 + 8472 a + 976 a^2) e^3 == 0 

When I used “Solve”,

Solve[{60 + 31 a + 4 a^2 + 4 C1 C2 (4 + a) (873 + 444 a + 56 a^2) e +  128 C1^2 C2^2 (3 + a) (4 + a) (9 + 2 a) (33 + 8 a) e^2 -  3072 C1^3 C2^3 (4 + a)^2 (9 + 2 a)^3 e^3 == 0, 60 + 31 a + 4 a^2 + C1 C2 (4 + a) (3267 + 8 a (207 + 26 a)) e + 16 C1^2 C2^2 (4 + a) (9 + 2 a) (837 + 468 a + 64 a^2) e^2 - 4 C1^3 C2^3 (4 + a) (9 + 2 a)^2 (18333 + 8472 a + 976 a^2) e^3 == 0}, {C1, C2}] 

I got: {}

Thanks for helping!!!

## How to set up patterns when using SequenceSplit

Given a list

lst={0,0,0,0,0,"A1",0,0,0,"B2",0,0,"C3","D4","E5",0,0,0,"F6"} 

How to split it as

{{0,0,0,0,0},{"A1",0,0,0},{"B2",0,0},{"C3"},{"D4"},{"E5",0,0,0},{"F6"}} 

I want to use SequenceSplit but didn’t know how to set up the right pattern.

SequenceSplit[lst, {_String} -> {}] 

Thanks!

## Evaluating part(s) of a function which outputs another function [duplicate]

• Evaluation in lambda function 2 answers

I would like to define a function f(n) which outputs another function as follows:

f[n_] := PolynomialRemainder[#,ChebyshevT[n,x],x]& 

However, I would like the ChebyshevT[n,x] part of the function to be evaluated when f is called, so that for instance when f(2) is evaluated I get PolynomialRemainder[#,-1+2x^2,x]& instead of PolynomialRemainder[#,ChebyshevT[2,x],x]&.

How do I do that? If I wrap the function body in an Evaluate as follows:

f[n_] := Evaluate[PolynomialRemainder[#,ChebyshevT[n,x],x]]& 

then the whole definition gets evaluated, and the input # is assumed to be free of x, resulting in f[2] = #&.

## Transform a field with derivatives

Given a function of Cartesian coordinates $$(x, y)$$ in $$g(x, y) = \frac{d}{dx}f(x, y)-y\frac{d}{dy}f(x, y)$$, I want to transform this expression to polar coordinates $$(r,\phi)$$. I saw a solution using built-in chain rule here: Change variables in differential expressions and a possible solution using replacement here: Transformation of Derivatives under change of coordinates. I also came across FransformedField , which seems very succinct but it would only tranform $$(x, y)$$ in the expression but not the derivatives, i.e. it gives me the following:

TransformedField["Cartesian" -> "Polar",    D[f[x, y], x] - x*D[f[x, y], y], {x, y} -> {r, \[Phi]} ]  

output

$$f^{(1,0)}(r \cos (\phi ),r \sin (\phi ))-r \cos (\phi ) f^{(0,1)}(r \cos (\phi ),r \sin (\phi ))$$.

I wonder why this is the case? Or if there is any trick to make it work with TransformedField?