Problem With Matrix. (help)
#1
Posted 24 October 2007 - 01:54 AM
(To resolve newtom-raphson)
In LUA9E running the code in CPLUA.EXE
The results are correct but CPLua.cpa are incorrect ...
My OS is V3.02
--------------------------------------------------------
Tengo un problema con Cplua0.9E no me entrega los resultados correctos de la matriz
y el CPlua.exe la aplicacion para windows si me da los resultadfos correctos
The code
require("cas")
F=input("ingrese la funcion")
f1=cas(F)
a=input("x0=")
ite=input("numero de Iteraciones")
d=cas.diff(F,"x")
f2=cas(d)
MZ={}
for n=2,ite do
MZ[n]={}
MZ =a
MZ[n]=MZ[n-1]-f1(MZ[n-1])/f2(MZ[n-1])
print(MZ[n-1])
end
Dowload cade
http://www.udec.cl/~friquelme/save.mcs
#2
Posted 24 October 2007 - 10:35 PM
X0=1
numero de iteraciones=10
1
1.5
1.4166666666667
1.4142156859408
1.4142135623155
1.4142135626886
1.4142135620617
1.4142135624348
1.4142135628079
Done.
Press [<-] or EXE' />...
In CPlua.cpa shows this error
1
1.5
Rumtime error:
main:12: attempt to
perform arithmetic on a nil
value
Press [<-] or EXE' />...
I do not understand to be someone can help me
____________________________________________
no entiendo a que se debe alguien me puede ayudar
#3
Posted 30 October 2007 - 06:48 PM
Apparently those who know more lua not help others o quizas sea por mi mal ingles
#4
Posted 30 October 2007 - 08:29 PM
It gives nil for 1.41666 but not for 1.42666 nor 2.4166. Nil for 1.4144 but nor for 1.41999... If you use x^2+2, 1.41666 won't give nil... That is, on OS 3.02 (w/ CPLua .9E)require("cas")
f=cas("x^2-2")
print(f(a)) --replace a with a number
One way to resolve the problem would be:
By the way, I got a mem error while running the second code mixed with the first one multiple times with different values for d.require("cas")
F=input("ingrese la funcion")
a=input("x0=")
ite=input("numero de Iteraciones")
d=cas.diff(F,"x")
MZ={}
MZ =a --MZ won't change in the loop, so no need to put it into it
for n=2,ite do
--MZ[n]={} I can't see what this would be good for as MZ[n] is going to be overwritten in the very next line anyway...
MZ[n]=MZ[n-1]-cas(F .. "|x=" .. tostring(MZ[n-1]))/cas(d .. "|x=" .. tostring(MZ[n-1]))
print(MZ[n-1])
end
#5
Posted 31 October 2007 - 04:43 AM
Up here all goes well
Muchas Gracias
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users