fitting – Finding the best fit: Mathematica vs. Excel

My data is:

data = {{0, 0.05}, {40, 0.079}, {80, 0.113}, {120, 0.18}, {160, 0.31}, {200, 0.5}, {240, 0.71}, {280,0.86}, {320, 1.02}};

With Excel we can fit the data with $0.0548996* e^{0.0099675 x}$ which is more or less good: (blue curve is the fit)

enter image description here

Now, if we try with Mathematica:

FindFit(data, a*E^(b x), {a, b}, x)

it returns: Working precision MachinePrecision is insufficient to achieve the
requested accuracy or precision; ${a -> 2.76357*10^{-76}, b -> 1.}$, which is obviously wrong.

How can one find the best fit with Mathematica for this data?

usa – Why does this US to UK adapter not fit properly?

The shape of the plug is keyed for 120V only. (North America has other plug keyings intended for 240V). Does “the present” say in its labeling or instructions that it is able to run on 240V? Many things can, many more cannot. If not, you should not use an adapter like this, which will straight-shot 240V into your device.

They make larger and more complex adapters which convert voltage. Such adapters either have some electronics onboard (which can serve only limited load capacity, in watts), or are a bulky and very dense transformer (the larger, the higher the capacity in watts, clear up to the 1800W max a US device might draw if you don’t mind a 15kg transformer).

That plug is a NEMA 1-15 plug that is polarized. That means “the present” is not double-insulated and it is much safer when the wide blade is connected to neutral. Neutral is a worldwide concept (except Philippines), it is a wire (typically 1 of 2) in the supply loop which is manipulated to be near natural earth, so does not present a shock hazard if your body got between neutral and earth. It is not to be confused with the safety ground, that third pin on US and UK plugs.

Whoever sold that to you sells cheap Cheese junk. It is unfit to be marketed as a US to UK adapter, since it lacks the correct keying for polarized plugs, which are very common. This particular one is a highly compromised “universal” adapter meant to plug anything (even UK) to UK. Beware buying such junk, as it can create safety issues of its own, especially if you plug in something with a high power draw.

You are better off seeking a quality unit that focuses on US to UK only, and better off buying it at a local shop, where safety regulations are able to have an effect on the quality of their selection. EBay, Amazon Marketplace and AliExpress sellers do an end-run around government regs by direct shipping to the consumer.

fitting – Non Linear model Fit error: InterpolatingFunction[…] is not a valid variable

I’m very new to Mathematica and I’ve been working on a project for some weeks. I tried to fit a sinusoidal equation to output voltage data from an oscilloscope on NI Multisim. I managed to import my data into Mathematica and then fit the equation to it. This didn’t work initially but then after some tinkering, it seemed to work. I have no idea what I did to make it work, but it did.

My data is as follows:

Voutdatalist = {{7.132564286390*10^-10, 
    4.3581*10^-3}, {3.838256428639*10^-9, 
    2.3292*10^-2}, {6.963256428639*10^-9, 
    4.1334*10^-2}, {1.008825642864*10^-8, 
    5.7789*10^-2}, {1.321325642864*10^-8, 
    7.2024*10^-2}, {1.633825642864*10^-8, 
    8.3490*10^-2}, {1.946325642864*10^-8, 
    9.1748*10^-2}, {2.258825642864*10^-8, 
    9.6477*10^-2}, {2.571325642864*10^-8, 
    9.7496*10^-2}, {2.883825642864*10^-8, 
    9.4766*10^-2}, {3.196325642864*10^-8, 
    8.8392*10^-2}, {3.508825642864*10^-8, 
    7.8619*10^-2}, {3.821325642864*10^-8, 
    6.5824*10^-2}, {4.133825642864*10^-8, 
    5.0500*10^-2}, {4.446325642864*10^-8, 
    3.3236*10^-2}, {4.758825642864*10^-8, 
    1.4696*10^-2}, {5.071325642864*10^-8, -4.4051*10^-3},
{5.383825642864*10^-8, -2.3335*10^-2}, {5.696325642864*10^-8,
-4.1365*10^-2}, {6.008825642864*10^-8, -5.7803*10^-2},
{6.321325642864*10^-8, -7.2020*10^-2}, {6.633825642864*10^-8,
-8.3469*10^-2}, {6.946325642864*10^-8, -9.1711*10^-2},
{7.258825642864*10^-8, -9.6431*10^-2}, {7.571325642864*10^-8,
-9.7448*10^-2}, {7.883825642864*10^-8, -9.4723*10^-2},
{8.196325642864*10^-8, -8.8360*10^-2}, {8.508825642864*10^-8,
-7.8603*10^-2}, {8.821325642864*10^-8, -6.5826*10^-2},
{9.133825642864*10^-8, -5.0520*10^-2}, {9.446325642864*10^-8,
-3.3271*10^-2}, {9.758825642864*10^-8, -1.4741*10^-2},
{1.007132564286*10^-7, 4.3581*10^-3}, {1.038382564286*10^-7, 
    2.3292*10^-2}, {1.069632564286*10^-7, 
    4.1334*10^-2}, {1.100882564286*10^-7, 
    5.7789*10^-2}, {1.132132564286*10^-7, 
    7.2024*10^-2}, {1.163382564286*10^-7, 
    8.3490*10^-2}, {1.194632564286*10^-7, 
    9.1748*10^-2}, {1.225882564286*10^-7, 
    9.6477*10^-2}, {1.257132564286*10^-7, 
    9.7497*10^-2}, {1.288382564286*10^-7, 
    9.4766*10^-2}, {1.319632564286*10^-7, 
    8.8392*10^-2}, {1.350882564286*10^-7, 
    7.8619*10^-2}, {1.382132564286*10^-7, 
    6.5824*10^-2}, {1.413382564286*10^-7, 
    5.0500*10^-2}, {1.444632564286*10^-7, 
    3.3236*10^-2}, {1.475882564286*10^-7, 
    1.4696*10^-2}, {1.507132564286*10^-7, -4.4051*10^-3},{1.538382564286*10^-7, -2.3335*10^-2}, {1.569632564286*10^-7,
-4.1365*10^-2}, {1.600882564286*10^-7, -5.7803*10^-2},
{1.632132564286*10^-7, -7.2020*10^-2}, {1.663382564286*10^-7,
-8.3469*10^-2}, {1.694632564286*10^-7, -9.1711*10^-2},
{1.725882564286*10^-7, -9.6431*10^-2}};```

This is the function that I shall be fitting to the data:
V(A_, f_, phi_, t_) := A*Cos(2*pi*f*t + phi)

And here is the fit
VoutF = NonlinearModelFit(
  Voutdatalist, {V(A, f, phi, t)}, {{A, (10*10^-3)}, {f, 
    10000000}, {phi, (Phi)}}, t)

And the initial value for phi was calculated prior to this and is 180 degrees in this case.

As of late, I have been getting this error:

NonlinearModelFit::ivar: InterpolatingFunction({{-0.888,0.}},{5,7,0,{9},{4},0,0,0,0,Automatic,<<3>>},{{-0.888,-0.777,-0.666,-0.555,-<<6>>,-0.333,-0.222,-0.111,0.}},{Developer`PackedArrayForm,{0,1,2,3,4,5,6,7,8,9},{13319.5,1884.73,771.722,436.527,288.812,209.484,161.357,129.639,107.446}},{Automatic}) is not a valid variable.

But this exact code has worked before!

Can anyone spot any issues with my code? And would anyone be able to explain what this error is referring to and how to fix it?

Appreciate any help that can be given!

How do real numbers like Pi, golden ratio, etc fit into type theory

In type theory, all computable functions must terminate, however, numbers like Pi are non-terminating real numbers, hence a non-terminating function is required to compute this number, even though one would never compute the full sequence.

How does type theory view/deal with such non-terminating numbers/object?

hard drive – Which washers fit the screws in a PC case?

I’m building a case to be extra quiet and would like to add washers to the case and drive screws. As I understand it, washers made of silicone, neoprene, rubber, etc. can assist with vibrations and dampen case noise slightly. There are a few types of screws in a case. To find washers for them my question is: what sized washers go with what sized screws, or what is the name for these washers?

fitting – How to fit my data to error function?

I asked this question yesterday about fitting my data to logistic function and I received the right answer, but now I have to fit my data

set1={-9.21034037198, -6.90775527898, -4.60517018599, -2.30258509299, 0., 2.30258509299, 4.60517018599, 6.90775527898, 9.21034037198}
set2= {0.50000, 0.50000, 0.49970, 0.48471, 0.43806, 0.41499, 0.40731, 0.40486, 0.40409}

to the error function which is in sigmoid functions family again, but I don’t know how to do so? I tried this

mod3 = NonlinearModelFit(
  data, {(2*a)/Sqrt((Pi))*Integrate(-b*Exp(-d*t^2), {t, 0, x}) - 
    c}, {a, b, c, d}, x, Method -> NMinimize)
Show({Plot({(2*a)/Sqrt((Pi))*Integrate(-b*Exp(-d*t^2), {t, 0, x}) - 
     c}, {x, -10, 10}, PlotStyle -> {Red, Blue}), ListPlot(data)})

but it doesn’t work! We know the value of function tends to 1 for x goes to infinity and -1 for x goes to -infinity. In previous question the problem was solved by adding a c constantm but in this case what is the problem?

Should I use Erf built-in function instead of the explicit form of error function which I have used above?

unity – How can I set perspective camera in portrait to fit screen sizes

I want to fit a perspective camera in different mobile portrait resolutions to see always the same objects in screen.

Doing a research about my problem I have found this post Scale camera to fit screen size unity that have a similar problem than mine, but he ask for an ortographic camera also horizontal.

My problem is the same but in perspective and vertical, I have tryed to adapt the solution code to my project but I don’t know why isn’t working, can someone explain to me the code or helpme to understand the maths behind them so I can figure how to do it?

My code for vertical

public float VerticalFoV = 60.0f;

// ...


void Update() {
   float halfHeight = Mathf.Tan(0.5f * VerticalFoV * Mathf.Deg2Rad);

   float halfWidth = halfHeight * Screen.width/ Screen.height;

   float horizontalFoV = 2.0f * Mathf.Atan(halfWidth) * Mathf.Rad2Deg;

   Camera.main.fieldOfView = horizontalFoV;
}

Sample code for horizontal

public float horizontalFoV = 90.0f;

// ...

void Update() {
   float halfWidth = Mathf.Tan(0.5f * horizontalFoV * Mathf.Deg2Rad);

   float halfHeight = halfWidth * Screen.height / Screen.width;

   float verticalFoV = 2.0f * Mathf.Atan(halfHeight) * Mathf.Rad2Deg;

   camera.fieldOfView = verticalFoV;
}

unity – How can I set perspective camera in portrait to fit screen sizes

I want to fit a perspective camera in different mobile portrait resolutions to see always the same objects in screen.

Doing a research about my problem I have found this post Scale camera to fit screen size unity that have a similar problem than mine, but he ask for an ortographic camera also horizontal.

My problem is the same but in perspective and vertical, I have tryed to adapt the solution code to my project but I don’t know why isn’t working, can someone explain to me the code or helpme to understand the maths behind them so I can figure how to do it?

My code for vertical

public float VerticalFoV = 60.0f;

// ...


void Update() {
   float halfHeight = Mathf.Tan(0.5f * VerticalFoV * Mathf.Deg2Rad);

   float halfWidth = halfHeight * Screen.width/ Screen.height;

   float horizontalFoV = 2.0f * Mathf.Atan(halfWidth) * Mathf.Rad2Deg;

   Camera.main.fieldOfView = horizontalFoV;
}

Sample code for horizontal

public float horizontalFoV = 90.0f;

// ...

void Update() {
   float halfWidth = Mathf.Tan(0.5f * horizontalFoV * Mathf.Deg2Rad);

   float halfHeight = halfWidth * Screen.height / Screen.width;

   float verticalFoV = 2.0f * Mathf.Atan(halfHeight) * Mathf.Rad2Deg;

   camera.fieldOfView = verticalFoV;
}

opengl – OpenGLHow to fit a texture to a curved plane with GL_CLAMP

I’m trying to fit a texture on a curved plane made from some triangles with GL_CLAMP, because GL_CLAMP_TO_EDGE is not available in my OPenGL version, but the texture (512 x 512 pixels) appears so small when render:

     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); // If the u,v coordinates overflow the range 0,1 the image is repeated
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // The magnification function ("linear" produces better results)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //The minifying function

    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE,  GL_OBJECT_LINEAR);
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);

enter image description here

I load the texture like this:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECR );    
glTexImage2D(GL_TEXTURE_2D, 0, 4, infoheader.biWidth, infoheader.biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, l_texture);
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, infoheader.biWidth, infoheader.biHeight, GL_RGBA, GL_UNSIGNED_BYTE, l_texture);

optics – What shutter can fit a lens element with large glass?

I am building a camera using a very large front glass element for the lens (diameter is 70mm).

At first, I thought I should try to find a shutter that is 70mm in diameter as well, one that can function like older cameras (set the speed and aperture, push a lever, release shutter).

But now I wonder if I really have to use a shutter that is 70mm in diameter or larger, or if I can I use a smaller one?
I am assuming that if I use a shutter of a smaller diameter than the lens, the properties of the lens will change (for example, it will become less fast), because of the smaller aperture ring behind it?

That said, are there shutters that are 70mm in diameter?