I was wondering if Turing had a logarithmic function and what it was. If not, I was wondering how I could create my own logarithmic function without a table look up or brute force if it is possible. Thanks in advance.
Turns out there is no way to do it. Better off using brute force.
Actually there is a solution: Turing has natural log function. You can use base conversions to get log of other bases
EDIT: bass conversion:
function getlog:
6*log(6)=666
logcycle(6)
end function
function logcycle:
return getlog(logcycle(getlog(6))
end function
Related
The image shows my problem (link)
I want to use that to do a Jacobian for a Multivariable method of aproximation. So There is a way to use that easily? or I have to put manually the partial derivatives like new functions?
I'm sorry for my english.
Firstly, you dont have to use images here, you can easily insert code pieces. As for your problem, i didnt understand it. Im sure you already know that you can define a Jacobian matrix function of 2 variables:
j2_fun(f1,f2):=[[derivative(f1,x),derivative(f1,y)][derivative(f2,x),derivative(f2,y)]]
... and call it later with specific arguments, and evaluate for some x,y:
g1:=x^2+y^2
g2:=x^2-y^2
d2:=j2_fun(g1,g2)
d2|x=3 and y=1
So staring from here, please define more clearly what would you like to do with this.
I want to sweep the variable Q from -.4 to +.4 and then plot the variable V for each individual value of Q.
0.188Q^2+.44*V^2*Q+.0221+V^4+(.2-1.05^2)*V^2=0
But I am not sure how to go about solving this problem, as I have never faced something like this before. Can someone please advice on how to code this?
This is job for ezplot!
As you have your function in implicit form, unless you write it in explicit form (i.e. y=..) you can not use plot. But you can use ezplot!
just do
ezplot('x.*0.188*x.^2+.44*y.^2*x+.0221+y.^4+(.2-1.05^2)*y^2',[-4 4])
I keep getting this error. I received this error after I corrected for logical integer error. The only way I could think of programming this was defining the initial value and then start euler's method at the next t value since it uses the previous solution to find the next one. But by doing this I am getting this error? I'm unsure how to fix it. I tried to end one step from my final value but that didn't work either. Thanks for the help. For the problem we had to create the function and call it. I was initially using n=8.
function [exeuler] = pb3(n)
%using explicit euler to solve ODE with input n and outputting exeuler as
%the answer
%n=steps t,y are initial conditions
h=3/n;
t=logical((1+h):h:4);
back=logical(t-h);
exeuler(1)=2; %defines the initial value
exeuler(t)=exeuler(back)+h*(t.^2-(2*exeuler(back)/t));
end
Well, I am sorry, but you haven't showed much of effort. For the future, please provide the complete code (i.e. with example function and so on). This is very unclear.
I think your problem is in these lines:
t=logical((1+h):h:4);
exeuler(t)=exeuler(back)+h*(t.^2-(2*exeuler(back)/t));
cause t is a vector. You are calling vector with non-integer values as index. Then, I guess, you get the wrong amount of exeuler(t)'s which leads to the error.
And for-loop is missing, isn't it? Because you don't use the Euler method stepwise andd therefore f(t+1) doesn't really depend on f(t).
So, my advice in general would be not to correct this error, but to rethink your algorithm.
I wish to perform an integration as indicated below.
I am facing an error because the I am using the integration variable 'u' inside interpolation function. (If I replace 'u' inside interpolation function by some constant, the integration runs fine.)
>>syms u
>>double(int(2*interp1(x,y,u),u,0,0.1))
Error using interp1>Interp1D (line 330)
Inputs must be floats, namely single or double.
Error in interp1 (line 220)
Vq = Interp1D(X,V,Xq,method);
Can you please provide some pointers to fix it.
P.S.: For clarification, y=f(x) [piecewise function] which is why I am interpolating to determine intermediate values.
Thanks a lot !!
You should replace int by a simpler integration routine, and forget about syms. Try the build-in integrate, or https://ece.uwaterloo.ca/~dwharder/NumericalAnalysis/13Integration/romberg/matlab.html
Alternatively, you may find an alternative to interp1, and call int on each of its subintervals.
Thanks folks for help,
I figured out that integral() fixes the issue instead of symbolic integ. Thanks a lot !!
My teacher in the signal analysis course has given me some Matlab code that I have to execute in order to complete a home assignment. I have always been using GNU Octave without troubles, but this time there is this command that is giving me headaches.
[c8,g8]=fit(time, sin_4_harmonic,’fourier8’)
I cannot find the function "fit" in GNU Octave, which is referenced for Matlab at the following url http://www.mathworks.se/help/curvefit/fit.html
Does anyone knows which package should I load, or if there is any equivalent?
Thanks =)
As far as I know, that function is not present in any of the Octave packages. However, the best place to look for something similar would be the optim package, probably the function nonlin_curvefit. Looking at the documentation, the model fourier8 is of the type Y = a0+a1*cos(x*p)+b1*sin(x*p)... +a8*cos(8*x*p)+b8*sin(8*x*p).
A work-around may be using "polyfit" function. To get the values, use "polyval".