Simplify Difference of Conjugate Pairs

Is it possible to easily simplify the difference of conjugate pairs?

In particular, if there’s just a single variable, then

FullSimplify[a - Conjugate[a]] 
2 I Im[a] 

But trying to do the same thing with a slightly more complex expression fails:

FullSimplify[a Conjugate[b] - Conjugate[a] b] 
a Conjugate[b] - Conjugate[a] b 

I have found one solution (answered below) but it relies on a FullSimplify which doesn’t seem very optimal.

Difficultly importing GeoTiff format

I downloaded Earth data from here. It is a GeoTiff file, which is a map of solar radiation falling on earth.

enter image description here

Mathematica claims to import GeoTiff files. However, when I import,

SetDirectory[NotebookDirectory[]] files = FileNames["*", "./diffuse/"][[1]] diffuse = Import[files, {"GeoTIFF", "Image"}] 

The output is an error:

LinkObject::linkd: Unable to communicate with closed link LinkObject['/Applications/',6300,8]. Import::fmterr: Cannot import data as GeoTIFF format. 

I can get the file to open using other GeoTiff programs such as QCIS. So it does seem to be a Mathematica issue. Any ideas? It is an error which I have not encountered before.

Can the new HatchShading and StippleShading plotstyles be used without color?

I wanted (PlotStyles) HatchShading or StippleShading for figures that will be printed in black and white, but these options end up color by default. I tried combining with a GrayTones ColorFunction, like so:

scap = {Sin[#1] Cos[#2], Sin[#1] Sin[#2], Cos[#1]} & ; {ParametricPlot3D[ {Sin[t]^2 scap[t, p]}, {t, 0, Pi}, {p, 0, 2 Pi}   , Lighting -> "Accent"   , ColorFunction -> "GrayTones"   ],  ParametricPlot3D[ {Sin[t]^2 scap[t, p]}, {t, 0, Pi}, {p, 0, 2 Pi}   , Lighting -> "Accent"   , ColorFunction -> "GrayTones"   , PlotStyle -> HatchShading[0.7, Black]   ],  ParametricPlot3D[ {Sin[t]^2 scap[t, p]}, {t, 0, Pi}, {p, 0, 2 Pi}   , Lighting -> "Accent"   , ColorFunction -> "GrayTones"   , PlotStyle -> StippleShading[]   ]} 

but the GrayTones ColorFunction seems to be ignored when using these PlotStyles.

some plots

Is there a way to avoid the use of a color background in the plot image when using HatchShading or StippleShading?

Writing generalized hypergeometric function ${_nF}_{n-1}(\cdot)$ as a function of $n$

How can we code the hypergeometric function $ $ f(n,k,z)={_nF}_{n-1}{\huge(}{1-k,\overbrace{2,\dots,2}^{n-1\ \text{times}} \atop \underbrace{1,\dots,1}_{n-1\ \text{times}}};z{\huge)} $ $ as a function that accepts any $ n=1,2,3,\dots$ ? This function reduces to a rational function in $ z$ but that is not what I’m after. I apologize for lack of an attempt here…did not have any idea where to start.

Set: in part assignment is not a symbol

This is probably a basic question but I am new to Mathematica, so please help me out here.

I have the following piece of code:

lmax = 2; arrlen = lmax + 1; xarr[x_] = Array[x^# &, arrlen, 0]; parr[p_] = Array[p^# &, arrlen, 0]; arr[x_, p_] = Join[xarr[x], parr[p]]; mboot[x_, p_] := Outer[NonCommutativeMultiply, arr[x, p], arr[x, p]] 

Now, I want to set a few particular elements of mboot[x,p] to 0. But when I try, for example:


I get an error saying Set: mboot[x,p] in the part assignment is not a symbol.

It would be great if someone could help me figure out what is going wrong and how I can fix it.

Parallelize import of many files

I’m trying to speed up the import of a large number of files, using ParallelTable to store them in a indexed variable, eqDump. The files are in the folder “Frames” and are named “Conf_Run.1000”, “Conf_Run.2000”, … Here is what I’ve tried,

    Clear[eqDump];         SetSharedFunction[eqDump];     ParallelTable[       eqDump[t] = Import["Frames/Conf_Run." <> ToString[t]                     ,"Table"                     ,HeaderLines -> 9]     ,{t, 5000, 1000000, 5000}]; 

But the execution doesn’t even seems to start, the kernels remain idle. I don’t know whats happening, since I think it should work in the same way as here for example. I’ve tried also to SetSharedVariable[t] since I supposed each kernel should know the current t value, but doesn’t seem to help.

Thank you very much!

check if one expression can be transformed into another

My question is how to use Mathematica to check if one expression can be transformed into another:

Example 1: $ ax^2+bx+c$ into $ K\cdot(x+\alpha)^2+\beta$ , and then show me $ K(a,b,c)$ and so on.

Example 2: Say I have the Maxwell equations:

$ \nabla \cdot \mathbf{E} = \frac{\rho}{\varepsilon_0}$ , $ \nabla \times \mathbf{E} = -\dot {\mathbf{B}}$ , $ \nabla \cdot \mathbf{B} = 0$ , $ \nabla \times \mathbf{B} = \mu_0 (\varepsilon_0 \mathbf{j} + \dot{\mathbf{E}})$ .

Can I follow from this an expression of the form $ \alpha \ddot {\mathbf{E}}+\beta \mathbf{E}=0$ ?

Example 3: $ c_1 \cos(\omega t) + c_2 \sin(\omega t)$ into $ A cos (\omega t + \delta)$ . How do I mark the dependencies, so that $ A$ is $ A(c_1, c_2)$ but not $ A(t)$ ?

Replacement rules which for elements of a vector which meet conditions

I’m trying to create a function which will replace elements of a list with their values modulo 1, i.e. Mod[x,1], but only if Abs[x]>1. So, for example, the function would yield:


I’m trying to do this in an elegant way. For example, I have a function for a related purpose:

C1[v_] := v /. _?Negative -> 0;.

This replaces negative elements of a list with 0, and it’s very clean.

I’d like to do something similar. My efforts so far have included breaking it into two functions:

CLim[x_] := Mod[x, 1] /; Abs[x] > 1;

C2[v_] := CQubitLim /@ v; But then, when I apply C2 to a list, it only seems to apply on some elements, for example


My other idea was to use a conditional rule


But this doesn’t seem to evaluate when I put a vector through it.

Any ideas much appreciated.

Why does NMaxmize miss this true maximum?

I am having trouble with maximizing a function which appears as a curvature of a planar curve.

{tmin, tmax} = {0, 2 Pi}  f=-((6-3 Cos[t]-Cos[3 t])/((-11+6 Cos[t]+8 Cos[2 t]-6 Cos[3 t]+Cos[4 t])   Sqrt[Cos[t]^2+9 Sin[t]^2-12 Cos[t] Sin[t]^2+4 Cos[t]^2 Sin[t]^2]));  NMaximize[{f, tmin <= t <= tmax}, t] 

says that the maximum of f is attained at

{1.37888, {t -> 5.78352}} 


Plot[f, {t, tmin, tmax}, PlotRange -> Full] 

plot of f

indicates that the true maximum is attained at t=Pi

Why is this happening? I’m using Mathematica version 12.0.0 for Microsoft Windows (64-bit).