Related
I have a unitary Matrix which consists of Complex coefficients like A, B C etc
I want to have a complex repres. For A like A = a0* Exp (i Phi) and saying that a0 is real and positiv.
I tried the Assumption option but everytime it doesn't work when i try to look at ComplexConj(A) * A - i alwayd get sth like a0 * Conjugate a0 but it should be a0^2.
Can you please help me?
As shown in the image below, I'm creating a program that will make a 2D animation of a truck that is made up of two articulated parts.
The truck pulls the trailer.
The trailer moves according to the docking axis on the truck.
Then, when the truck turns, the trailer should gradually align itself with the new angle of the truck, as it does in real life.
I would like to know if there is any formula or algorithm that does this calculation in an easy way.
I've already seen inverse kinematics equations, but I think for just 2 parts it would not be so complex.
Can anybody help me?
Let A be the midpoint under the front axle, B be the midpoint under the middle axle, and C be the midpoint under the rear axle. For simplicity assume that the hitch is at point B. These are all functions of time t, for example A(t) = (a_x(t), a_y(t).
The trick is this. B is moving directly towards A with the component of A's velocity in that direction. Or in symbols, dB/dt = (dA/dt).(A-B)/||A-B|| And similarly, dC/dt = (dB/dt).(B-C)/||B-C|| where . is the dot product.
This turns into a non-linear first-order system in 6 variables. This can be solved with normal techniques, such as https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods.
UPDATE: Added code
Here is a Python implementation. You can replace it with https://rosettacode.org/wiki/Runge-Kutta_method for your favorite language and your favorite linear algebra library. Or even hand-roll that.
For my example I started with A at (1, 1), B at (2, 1) and C at (2, 2). Then pulled A to the origin in steps of size 0.01. That can be altered to anything that you want.
#! /usr/bin/env python
import numpy
# Runga Kutta method.
def RK4(f):
return lambda t, y, dt: (
lambda dy1: (
lambda dy2: (
lambda dy3: (
lambda dy4: (dy1 + 2*dy2 + 2*dy3 + dy4)/6
)( dt * f( t + dt , y + dy3 ) )
)( dt * f( t + dt/2, y + dy2/2 ) )
)( dt * f( t + dt/2, y + dy1/2 ) )
)( dt * f( t , y ) )
# da is a function giving velocity of a at a time t.
# The other three are the positions of the three points.
def calculate_dy (da, A0, B0, C0):
l_ab = float(numpy.linalg.norm(A0 - B0))
l_bc = float(numpy.linalg.norm(B0 - C0))
# t is time, y = [A, B, C]
def update (t, y):
(A, B, C) = y
dA = da(t)
ab_unit = (A - B) / float(numpy.linalg.norm(A-B))
# The first term is the force. The second is a correction to
# cause roundoff errors in length to be selfcorrecting.
dB = (dA.dot(ab_unit) + float(numpy.linalg.norm(A-B))/l_ab - l_ab) * ab_unit
bc_unit = (B - C) / float(numpy.linalg.norm(B-C))
# The first term is the force. The second is a correction to
# cause roundoff errors in length to be selfcorrecting.
dC = (dB.dot(bc_unit) + float(numpy.linalg.norm(B-C))/l_bc - l_bc) * bc_unit
return numpy.array([dA, dB, dC])
return RK4(update)
A0 = numpy.array([1.0, 1.0])
B0 = numpy.array([2.0, 1.0])
C0 = numpy.array([2.0, 2.0])
dy = calculate_dy(lambda t: numpy.array([-1.0, -1.0]), A0, B0, C0)
t, y, dt = 0., numpy.array([A0, B0, C0]), .02
while t <= 1.01:
print( (t, y) )
t, y = t + dt, y + dy( t, y, dt )
By the answers I saw, I realized that the solution is not really simple and will have to be solved by an Inverse Kinematics algorithm.
This site is an example and it is a just a start, although it still does not solve everything, since the point C is fixed and in the case of the truck it should move.
Based on this Analytic Two-Bone IK in 2D article, I made a fully functional model in Geogebra, where the nucleus consists of two simple mathematical equations.
When i execute this code(shown below) , it always sets implicit kind of constraint.
As you can see below , it always says that D1 = D2 but there is no such explicit constraints nor any pattern matching which forces this.
Or in otherwords there is some reference between D1 and D2 such that whenever D1 gets initialized, D2 gets automatically initialized. I can't see how this is happening. Can someone explain me, i tried ot figure it out with debugger but it did not help.
It's a puzzle "GERALD + DONALD = ROBERT", initially three lists contains these variables.
I add code below if anyone wants to test it:
sum(N1,N2,N):-
sum1(N1,N2,N,0,0,[0,1,2,3,4,5,6,7,8,9],_).
sum1([],[],[],0,0,Digits,Digits).
sum1([D1|N1],[D2|N2],[D|N],C1,C,Digs1,Digs2):-
sum1(N1,N2,N,C1,C2,Digs1,Digs2),
digitSum(D1,D2,C2,D,C,Digs2,Digs).
digitSum(D1,D2,C1,D,C,Digs1,Digs):-
del(D1,Digs1,Digs2),
del(D2,Digs2,Digs3),
del(D,Digs3,Digs),
S is D1 + D2 + C1,
D is S mod 10,
C is D div 10.
del(A,L,L):-
nonvar(A),!.
del(A,[A|L],L).
del(A,[B|L],[B|L1]):-
del(A,L,L1).
Query:
?- sum( [D,O,N,A,L,D], [G,E,R,A,L,D], [R,O,B,E,R,T] ).
When it says D1 = D2 then you should see that both D1 and D2 have same variable from the list and List is a functor and one variable is visible in whole functor.
You should see that when the recursion ends, then you have have D's(last element) from GERALD and DONALD , since this D is visible in whole functor, D1 and D2 both refer to same variable.
I need help finding the grammar of these languages.
I feel like I am getting nowhere with these solution
1) {a^h b^k a^m b^n | h + k = m + n}
2) {a^i b^j a^k | (i = j and k ≥ 0) or (i ≥ 0 and j > k)}
any help would be appreciated
I assume you're looking for context-free grammars. I'll use the convention that S is the root production rule and that upper-case words are rules (like S, AB, A, etc.), the empty production is written empty and that literals are written as 'a' and 'b'.
The first grammar is:
S := AB
AB := 'a' AB 'b' | AA | BB
AA := 'a' AA 'a' | BA
BB := 'b' BB 'b' | BA
BA := 'b' BA 'a' | empty
The trick here is to realise that to keep the two halves the same length, one has to define grammar productions that add one symbol on either side. Then to note that we start by adding 'a' to the left, and 'b' to the right, and from there we proceed either adding 'a' to both sides, or 'b' to both sides, and finally proceed to adding 'b' to the left and 'a' to the right.
The second grammar is:
S := AB A | A B BA
AB := 'a' AB 'b' | empty
A := 'a' A | empty
B := 'b' B | 'b'
BA := 'b' BA 'a' | empty
This is easier than the first: the root production is already given as a choice of two things, so it's natural to express that in the rule. The first choice to to generate some number of 'a's followed by the same number of 'b's and then any number of 'a's. The second choice is to generate some number of 'a's, then some positive number of 'b's and then an equal number of 'b's and 'a's. That guarantees that "j>k" in the description of that choice.
Neither grammar here is unambiguous, although it's only a little more complicated to remove the ambiguities.
I am trying to get to grips with how to do the candidate elimination algorithm by hand. I know the answer, but I dont the steps on how to get there. Can anyone guide me or point me in the right direction. Here is the question that I am working on:
Consider a concept description language with three attributes predened as follows:
attribute1 attribute2 attribute3
---------- ------------ ------------
| | | | | | |
a b c d e f g
Demonstrate version space learning using the following positive and negative training examples:
1. ( a c f ) +)
2. ( b c f ) +)
3. ( a e g ) -)
4. ( a c g ) -)
5. ( b d f ) -)
Show how the candidate elimination algorithm changes the boundary sets after
processing each example.
This is what I have so far:
1. ( a c f ) +) Generalize..
G:(???)
S:(acf)
2. ( b c f ) +) Generalize...
G:(a??), (?e?), (?d?), (??g) - Not even sure if this is correct
S:(?cf)
Can someone guide me or give me advice please? Thanks
here: http://www2.cs.uregina.ca/~dbd/cs831/notes/ml/vspace/vs_prob1.html
this website really helps !
I made the tree for this exercise and the answer I got is G=S= (?cf)
it goes like this:
G: (???)
S: (acf)
2.
G: (???)
S: (?cf)
G: (???)
becomes
(b??),(?c?),(?d?),(??f)
after pruning =
(?c?),(??f)
S: (?cf)
4.
G: (?c?),(??f)
becomes (?cf),(??f)
(because (?c?) no longer holds for this example)
S: (?cf)
5.
G: (?cf),(??f)
becomes (?cf),(?cf)
(because < ??f > no longer holds for this example)
S: (?cf)
Final answer is:
G: (?cf),(?cf) = (?cf)
S: (?cf)
the final hypothesis is (?cf)
Hope this helps.